diff --git a/doom/.config/doom/README.org b/doom/.config/doom/README.org index 290aa6b..67e9941 100644 --- a/doom/.config/doom/README.org +++ b/doom/.config/doom/README.org @@ -3683,24 +3683,27 @@ Project bookmarks go to .bookmarks file in project root." ;; Bindings (defun gortium/list-project-bookmarks () - "Pick and jump to a project bookmark via completing-read. -Never touches global bookmark-alist." + "Show project bookmark menu. Switches to .bookmarks, restores globals on quit." (interactive) (if (not (projectile-project-p)) (user-error "Not in a project") (let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root))) - (proj-bms (and (file-exists-p proj-file) - (with-temp-buffer - (insert-file-contents proj-file) - (ignore-errors (read (current-buffer))))))) - (if (not proj-bms) + (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.") - (let* ((names (mapcar (lambda (b) (if (consp b) (car b) b)) proj-bms)) - (choice (completing-read "Project bookmark: " names nil t))) - (when choice - ;; Temporarily set bookmark-alist to project bookmarks for the jump - (let ((bookmark-alist proj-bms)) - (bookmark-jump choice)))))))) + ;; Switch to project bookmarks + (setq bookmark-default-file proj-file) + (bookmark-load proj-file t) + (bookmark-bmenu-list) + ;; Restore on quit + (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)))))) (map! :leader :desc "Set bookmark (global/project)" diff --git a/doom/.config/doom/config.el b/doom/.config/doom/config.el index babb210..eee376e 100644 --- a/doom/.config/doom/config.el +++ b/doom/.config/doom/config.el @@ -2753,24 +2753,27 @@ Project bookmarks go to .bookmarks file in project root." ;; Bindings (defun gortium/list-project-bookmarks () - "Pick and jump to a project bookmark via completing-read. -Never touches global bookmark-alist." + "Show project bookmark menu. Switches to .bookmarks, restores globals on quit." (interactive) (if (not (projectile-project-p)) (user-error "Not in a project") (let* ((proj-file (expand-file-name ".bookmarks" (projectile-project-root))) - (proj-bms (and (file-exists-p proj-file) - (with-temp-buffer - (insert-file-contents proj-file) - (ignore-errors (read (current-buffer))))))) - (if (not proj-bms) + (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.") - (let* ((names (mapcar (lambda (b) (if (consp b) (car b) b)) proj-bms)) - (choice (completing-read "Project bookmark: " names nil t))) - (when choice - ;; Temporarily set bookmark-alist to project bookmarks for the jump - (let ((bookmark-alist proj-bms)) - (bookmark-jump choice)))))))) + ;; Switch to project bookmarks + (setq bookmark-default-file proj-file) + (bookmark-load proj-file t) + (bookmark-bmenu-list) + ;; Restore on quit + (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)))))) (map! :leader :desc "Set bookmark (global/project)"