fix: restore globals after RET jump too, not just q

This commit is contained in:
2026-07-17 18:07:13 -04:00
parent b6d4a3e257
commit bcdb6e8120
2 changed files with 30 additions and 29 deletions

View File

@@ -3684,9 +3684,8 @@ Project bookmarks go to .bookmarks file in project root."
(message "Transferred '%s' to global" name)))
(message "No project bookmarks to transfer."))))
;; Bindings
(defun gortium/list-project-bookmarks ()
"Show .bookmarks menu. Switches bookmark-default-file, restores ref on quit."
"Show project bookmarks menu — restores globals after RET jump and on q."
(interactive)
(if (not (projectile-project-p))
(user-error "Not in a project")
@@ -3695,25 +3694,25 @@ Project bookmarks go to .bookmarks file in project root."
(saved-file bookmark-default-file))
(if (not (file-exists-p proj-file))
(message "No .bookmarks file in this project.")
(setq bookmark-default-file proj-file)
(bookmark-load proj-file t)
;; Read project bookmarks directly (read, not bookmark-load)
(setq bookmark-alist
(with-temp-buffer
(insert-file-contents proj-file)
(read (current-buffer))))
(bookmark-bmenu-list)
;; Restore globals after each RET jump AND on q
(with-current-buffer "*Bookmark List*"
(local-set-key (kbd "RET")
(lambda ()
(interactive)
(bookmark-bmenu-this-window)
(setq bookmark-alist saved-alist)
(setq bookmark-default-file saved-file)))
(add-hook 'kill-buffer-hook
(lambda ()
(setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist))
(setq bookmark-alist saved-alist)
(setq bookmark-default-file saved-file))
nil t))))))
(map! :leader
:desc "Set bookmark (global/project)"
"b m" #'gortium/bookmark-set
:desc "List project bookmarks"
"p RET" #'gortium/list-project-bookmarks)
#+end_src
** Refile done task
#+begin_Src emacs-lisp
(defun gortium/refile-to-today-daily ()
"Refile the current subtree under the 'Journal' headline in today's daily note.
This version uses `org-roam-dailies-capture-today` to ensure the daily note

View File

@@ -2751,9 +2751,8 @@ Project bookmarks go to .bookmarks file in project root."
(message "Transferred '%s' to global" name)))
(message "No project bookmarks to transfer."))))
;; Bindings
(defun gortium/list-project-bookmarks ()
"Show .bookmarks menu. Switches bookmark-default-file, restores ref on quit."
"Show project bookmarks menu — restores globals after RET jump and on q."
(interactive)
(if (not (projectile-project-p))
(user-error "Not in a project")
@@ -2762,22 +2761,25 @@ Project bookmarks go to .bookmarks file in project root."
(saved-file bookmark-default-file))
(if (not (file-exists-p proj-file))
(message "No .bookmarks file in this project.")
(setq bookmark-default-file proj-file)
(bookmark-load proj-file t)
;; Read project bookmarks directly (read, not bookmark-load)
(setq bookmark-alist
(with-temp-buffer
(insert-file-contents proj-file)
(read (current-buffer))))
(bookmark-bmenu-list)
;; Restore globals after each RET jump AND on q
(with-current-buffer "*Bookmark List*"
(local-set-key (kbd "RET")
(lambda ()
(interactive)
(bookmark-bmenu-this-window)
(setq bookmark-alist saved-alist)
(setq bookmark-default-file saved-file)))
(add-hook 'kill-buffer-hook
(lambda ()
(setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist))
(setq bookmark-alist saved-alist)
(setq bookmark-default-file saved-file))
nil t))))))
(map! :leader
:desc "Set bookmark (global/project)"
"b m" #'gortium/bookmark-set
:desc "List project bookmarks"
"p RET" #'gortium/list-project-bookmarks)
(defun gortium/refile-to-today-daily ()
"Refile the current subtree under the 'Journal' headline in today's daily note.
This version uses `org-roam-dailies-capture-today` to ensure the daily note