fix: SPC RET always shows globals, SPC p RET project
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 ()
|
||||
|
||||
Reference in New Issue
Block a user