diff --git a/doom/.config/doom/README.org b/doom/.config/doom/README.org index 896dce3..9efc603 100644 --- a/doom/.config/doom/README.org +++ b/doom/.config/doom/README.org @@ -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 diff --git a/doom/.config/doom/config.el b/doom/.config/doom/config.el index 211c1b9..fd6b2f7 100644 --- a/doom/.config/doom/config.el +++ b/doom/.config/doom/config.el @@ -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 ()