fix: SPC RET always shows globals, SPC p RET project

This commit is contained in:
2026-07-17 16:46:40 -04:00
parent 40f8d57609
commit 48d04ba73a
2 changed files with 92 additions and 42 deletions

View File

@@ -3634,26 +3634,7 @@ Project bookmarks go to .bookmarks file in project root."
(message "Project bookmark \"%s\" saved to .bookmarks" name))
(user-error "Not in a Projectile project"))))))
(defun gortium/list-project-bookmarks ()
"Show project bookmarks from .bookmarks in project root."
(interactive)
(if (not (projectile-project-p))
(user-error "Not in a project")
(let ((proj-file (expand-file-name ".bookmarks" (projectile-project-root))))
(if (not (file-exists-p proj-file))
(message "No .bookmarks file in this project.")
(let ((saved-alist (copy-tree bookmark-alist))
(saved-file bookmark-default-file))
(setq bookmark-default-file proj-file)
(bookmark-load proj-file t)
(bookmark-bmenu-list)
(with-current-buffer "*Bookmark List*"
(add-hook 'kill-buffer-hook
(lambda ()
(ignore-errors (bookmark-save))
(setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist))
nil t)))))))
(defun gortium//sync-plan-to-bookmark-file (bookmarks)
"Write BOOKMARKS alist back to the Plan file under * Bookmarks."
(when-let* ((plan-file (gortium//project-plan-file)))
@@ -3701,10 +3682,54 @@ Project bookmarks go to .bookmarks file in project root."
(message "No project bookmarks to transfer."))))
;; Bindings
(defun gortium/list-global-bookmarks ()
"Show global bookmarks, saving project changes first."
(interactive)
(let ((proj-root (and (projectile-project-p) (projectile-project-root))))
(when proj-root
(let ((proj-file (expand-file-name ".bookmarks" proj-root)))
(when (file-exists-p proj-file)
;; Save any pending project bookmark changes
(let ((current-file bookmark-default-file))
(setq bookmark-default-file proj-file)
(ignore-errors (bookmark-save))
(setq bookmark-default-file current-file))))))
;; Reload globals and show menu
(bookmark-load bookmark-default-file t)
(bookmark-bmenu-list))
(defun gortium/list-project-bookmarks ()
"Show project bookmarks from .bookmarks in project root."
(interactive)
(if (not (projectile-project-p))
(user-error "Not in a project")
(let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root)))
(saved-alist (copy-tree bookmark-alist))
(saved-file bookmark-default-file))
(if (not (file-exists-p proj-file))
(message "No .bookmarks file in this project.")
;; Save any pending global changes
(bookmark-save)
;; Switch to project bookmarks
(setq bookmark-default-file proj-file)
(bookmark-load proj-file t)
(bookmark-bmenu-list)
(with-current-buffer "*Bookmark List*"
(add-hook 'kill-buffer-hook
(lambda ()
;; Save project changes
(ignore-errors (bookmark-save))
;; Restore global
(setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist))
nil t))))))
(map! :leader
:desc "List global bookmarks"
"RET" #'gortium/list-global-bookmarks
:desc "Set bookmark (global/project)"
"b m" #'gortium/bookmark-set
:desc "Jump to project bookmark"
:desc "List project bookmarks"
"p RET" #'gortium/list-project-bookmarks)
#+end_src

View File

@@ -2704,26 +2704,7 @@ Project bookmarks go to .bookmarks file in project root."
(message "Project bookmark \"%s\" saved to .bookmarks" name))
(user-error "Not in a Projectile project"))))))
(defun gortium/list-project-bookmarks ()
"Show project bookmarks from .bookmarks in project root."
(interactive)
(if (not (projectile-project-p))
(user-error "Not in a project")
(let ((proj-file (expand-file-name ".bookmarks" (projectile-project-root))))
(if (not (file-exists-p proj-file))
(message "No .bookmarks file in this project.")
(let ((saved-alist (copy-tree bookmark-alist))
(saved-file bookmark-default-file))
(setq bookmark-default-file proj-file)
(bookmark-load proj-file t)
(bookmark-bmenu-list)
(with-current-buffer "*Bookmark List*"
(add-hook 'kill-buffer-hook
(lambda ()
(ignore-errors (bookmark-save))
(setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist))
nil t)))))))
(defun gortium//sync-plan-to-bookmark-file (bookmarks)
"Write BOOKMARKS alist back to the Plan file under * Bookmarks."
(when-let* ((plan-file (gortium//project-plan-file)))
@@ -2771,10 +2752,54 @@ Project bookmarks go to .bookmarks file in project root."
(message "No project bookmarks to transfer."))))
;; Bindings
(defun gortium/list-global-bookmarks ()
"Show global bookmarks, saving project changes first."
(interactive)
(let ((proj-root (and (projectile-project-p) (projectile-project-root))))
(when proj-root
(let ((proj-file (expand-file-name ".bookmarks" proj-root)))
(when (file-exists-p proj-file)
;; Save any pending project bookmark changes
(let ((current-file bookmark-default-file))
(setq bookmark-default-file proj-file)
(ignore-errors (bookmark-save))
(setq bookmark-default-file current-file))))))
;; Reload globals and show menu
(bookmark-load bookmark-default-file t)
(bookmark-bmenu-list))
(defun gortium/list-project-bookmarks ()
"Show project bookmarks from .bookmarks in project root."
(interactive)
(if (not (projectile-project-p))
(user-error "Not in a project")
(let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root)))
(saved-alist (copy-tree bookmark-alist))
(saved-file bookmark-default-file))
(if (not (file-exists-p proj-file))
(message "No .bookmarks file in this project.")
;; Save any pending global changes
(bookmark-save)
;; Switch to project bookmarks
(setq bookmark-default-file proj-file)
(bookmark-load proj-file t)
(bookmark-bmenu-list)
(with-current-buffer "*Bookmark List*"
(add-hook 'kill-buffer-hook
(lambda ()
;; Save project changes
(ignore-errors (bookmark-save))
;; Restore global
(setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist))
nil t))))))
(map! :leader
:desc "List global bookmarks"
"RET" #'gortium/list-global-bookmarks
:desc "Set bookmark (global/project)"
"b m" #'gortium/bookmark-set
:desc "Jump to project bookmark"
:desc "List project bookmarks"
"p RET" #'gortium/list-project-bookmarks)
(defun gortium/refile-to-today-daily ()