fix: restore bookmark key bindings

This commit is contained in:
2026-07-17 17:57:55 -04:00
parent bab18715a5
commit b6d4a3e257
2 changed files with 51 additions and 32 deletions

View File

@@ -3462,8 +3462,7 @@ Otherwise, prompts for a single directory, defaulting to the item under the curs
** Project-Aware Agenda ** Project-Aware Agenda
Reads =.dir-locals.el= from the current Projectile root and injects the Reads =.dir-locals.el= from the current Projectile root and injects the
project-specific custom agenda command. Use ~SPC o P~ instead of ~SPC o a~ to project-specific custom agenda command.
get a context-scoped agenda.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun gortium/read-dir-local (var) (defun gortium/read-dir-local (var)
@@ -3529,25 +3528,29 @@ to .org files under the project root."
#'gortium/inject-project-agenda) #'gortium/inject-project-agenda)
;; Also inject at startup and on file open in a project ;; Also inject at startup and on file open in a project
(add-hook 'find-file-hook #'gortium/inject-project-agenda) (add-hook 'find-file-hook #'gortium/inject-project-agenda)
#+end_src
** Bookmarks
#+begin_src emacs-lisp
(defvar gortium/project-bookmark-names nil (defvar gortium/project-bookmark-names nil
"Bookmark names currently in the Plan file for the active project.") "Bookmark names currently in the Plan file for the active project.")
(defun gortium//project-plan-file () (defun gortium/project-plan-file ()
"Return the first .org file under 1-Plan/ at the project root, or nil." "Return the first .org file under 1-Plan/ at the project root, or nil."
(when-let* ((root (projectile-project-root))) (when-let* ((root (projectile-project-root)))
(car (directory-files (expand-file-name "1-Plan" root) t "\.org\'" t)))) (car (directory-files (expand-file-name "1-Plan" root) t "\.org\'" t))))
(defun gortium//project-tag () (defun gortium/project-tag ()
"Read the project tag from .dir-locals.el in the current project." "Read the project tag from .dir-locals.el in the current project."
(when (projectile-project-p) (when (projectile-project-p)
(let ((default-directory (projectile-project-root))) (let ((default-directory (projectile-project-root)))
(gortium/read-dir-local 'gortium/project-tag)))) (gortium/read-dir-local 'gortium/project-tag))))
(defun gortium//read-plan-bookmarks () (defun gortium/read-plan-bookmarks ()
"Parse * Bookmarks from the Plan file. "Parse * Bookmarks from the Plan file.
Returns alist ((NAME . URL) ...) where URL is the link target." Returns alist ((NAME . URL) ...) where URL is the link target."
(when-let* ((plan-file (gortium//project-plan-file)) (when-let* ((plan-file (gortium/project-plan-file))
(_ (file-exists-p plan-file))) (_ (file-exists-p plan-file)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents plan-file) (insert-file-contents plan-file)
@@ -3571,7 +3574,7 @@ Returns alist ((NAME . URL) ...) where URL is the link target."
(setq gortium/project-bookmark-names (mapcar #'car bookmarks)) (setq gortium/project-bookmark-names (mapcar #'car bookmarks))
(nreverse bookmarks)))))) (nreverse bookmarks))))))
(defun gortium//append-bookmark-to-plan (name url) (defun gortium/append-bookmark-to-plan (name url)
"Add a bookmark NAME with URL to the project's .bookmarks file. "Add a bookmark NAME with URL to the project's .bookmarks file.
Saves only project bookmarks without contaminating global list." Saves only project bookmarks without contaminating global list."
(when (projectile-project-p) (when (projectile-project-p)
@@ -3587,9 +3590,9 @@ Saves only project bookmarks without contaminating global list."
;; Restore globals ;; Restore globals
(setq bookmark-alist saved-alist) (setq bookmark-alist saved-alist)
(message "Bookmark added to .bookmarks")))) (message "Bookmark added to .bookmarks"))))
(defun gortium//remove-bookmark-from-plan (name) (defun gortium/remove-bookmark-from-plan (name)
"Remove a bookmark entry from * Bookmarks in the Plan file." "Remove a bookmark entry from * Bookmarks in the Plan file."
(when-let* ((plan-file (gortium//project-plan-file))) (when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents plan-file) (insert-file-contents plan-file)
(goto-char (point-min)) (goto-char (point-min))
@@ -3613,7 +3616,7 @@ Project bookmarks go to .bookmarks file in project root."
(?g (call-interactively 'bookmark-set)) (?g (call-interactively 'bookmark-set))
(?p (?p
(if (projectile-project-p) (if (projectile-project-p)
(let* ((tag (or (gortium//project-tag) "project")) (let* ((tag (or (gortium/project-tag) "project"))
(name (read-string (format "[%s] Bookmark name: " tag))) (name (read-string (format "[%s] Bookmark name: " tag)))
(proj-file (expand-file-name (proj-file (expand-file-name
".bookmarks" (projectile-project-root))) ".bookmarks" (projectile-project-root)))
@@ -3635,9 +3638,9 @@ Project bookmarks go to .bookmarks file in project root."
(user-error "Not in a Projectile project")))))) (user-error "Not in a Projectile project"))))))
(defun gortium//sync-plan-to-bookmark-file (bookmarks) (defun gortium/sync-plan-to-bookmark-file (bookmarks)
"Write BOOKMARKS alist back to the Plan file under * Bookmarks." "Write BOOKMARKS alist back to the Plan file under * Bookmarks."
(when-let* ((plan-file (gortium//project-plan-file))) (when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents plan-file) (insert-file-contents plan-file)
(when (re-search-forward "^\* Bookmarks" nil t) (when (re-search-forward "^\* Bookmarks" nil t)
@@ -3659,17 +3662,17 @@ Project bookmarks go to .bookmarks file in project root."
(let* ((name (completing-read "Transfer to project: " (bookmark-all-names) nil t)) (let* ((name (completing-read "Transfer to project: " (bookmark-all-names) nil t))
(file (bookmark-location name))) (file (bookmark-location name)))
(when (and name file (y-or-n-p (format "Transfer '%s' to project? " name))) (when (and name file (y-or-n-p (format "Transfer '%s' to project? " name)))
(gortium//append-bookmark-to-plan name file) (gortium/append-bookmark-to-plan name file)
(bookmark-delete name) (bookmark-delete name)
(bookmark-save) (bookmark-save)
(message "Transferred '%s' to project %s" name (message "Transferred '%s' to project %s" name
(or (gortium//project-tag) "")))) (or (gortium/project-tag) ""))))
(user-error "Not in a Projectile project"))) (user-error "Not in a Projectile project")))
(defun gortium/transfer-to-global () (defun gortium/transfer-to-global ()
"Transfer a project bookmark to the global bookmarks list." "Transfer a project bookmark to the global bookmarks list."
(interactive) (interactive)
(let* ((bookmarks (gortium//read-plan-bookmarks)) (let* ((bookmarks (gortium/read-plan-bookmarks))
(names (mapcar #'car bookmarks))) (names (mapcar #'car bookmarks)))
(if names (if names
(let* ((name (completing-read "Transfer to global: " names nil t)) (let* ((name (completing-read "Transfer to global: " names nil t))
@@ -3677,7 +3680,7 @@ Project bookmarks go to .bookmarks file in project root."
(when (and name url (y-or-n-p (format "Transfer '%s' to global? " name))) (when (and name url (y-or-n-p (format "Transfer '%s' to global? " name)))
(bookmark-store name `((filename . ,url)) t) (bookmark-store name `((filename . ,url)) t)
(bookmark-save) (bookmark-save)
(gortium//remove-bookmark-from-plan name) (gortium/remove-bookmark-from-plan name)
(message "Transferred '%s' to global" name))) (message "Transferred '%s' to global" name)))
(message "No project bookmarks to transfer.")))) (message "No project bookmarks to transfer."))))
@@ -3701,6 +3704,16 @@ Project bookmarks go to .bookmarks file in project root."
(setq bookmark-default-file saved-file) (setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist)) (setq bookmark-alist saved-alist))
nil t)))))) 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 () (defun gortium/refile-to-today-daily ()
"Refile the current subtree under the 'Journal' headline in today's daily note. "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 This version uses `org-roam-dailies-capture-today` to ensure the daily note
@@ -3725,9 +3738,7 @@ is created with Org-roams templates (including :ID:)."
(insert "\n") (insert "\n")
(org-paste-subtree (+ 1 parent-level)))))) (org-paste-subtree (+ 1 parent-level))))))
(message "Task refiled under '%s' in todays daily note." headline)))) (message "Task refiled under '%s' in todays daily note." headline))))
#+end_src
#+begin_src emacs-lisp
(defun gortium/refile-to-daily-of-close () (defun gortium/refile-to-daily-of-close ()
"Refile the current subtree under the 'Journal' headline in the daily note "Refile the current subtree under the 'Journal' headline in the daily note
corresponding to the task's CLOSED date. If no CLOSED property is found, corresponding to the task's CLOSED date. If no CLOSED property is found,
@@ -3762,6 +3773,7 @@ fallback to today's daily note. Ensures the daily has an Org-roam ID."
headline headline
(file-name-nondirectory daily-file))))) (file-name-nondirectory daily-file)))))
#+end_src #+end_src
** Emacs-Everywhere for Hyprland ** Emacs-Everywhere for Hyprland
#+begin_src emacs-lisp #+begin_src emacs-lisp

View File

@@ -2603,21 +2603,21 @@ to .org files under the project root."
(defvar gortium/project-bookmark-names nil (defvar gortium/project-bookmark-names nil
"Bookmark names currently in the Plan file for the active project.") "Bookmark names currently in the Plan file for the active project.")
(defun gortium//project-plan-file () (defun gortium/project-plan-file ()
"Return the first .org file under 1-Plan/ at the project root, or nil." "Return the first .org file under 1-Plan/ at the project root, or nil."
(when-let* ((root (projectile-project-root))) (when-let* ((root (projectile-project-root)))
(car (directory-files (expand-file-name "1-Plan" root) t "\.org\'" t)))) (car (directory-files (expand-file-name "1-Plan" root) t "\.org\'" t))))
(defun gortium//project-tag () (defun gortium/project-tag ()
"Read the project tag from .dir-locals.el in the current project." "Read the project tag from .dir-locals.el in the current project."
(when (projectile-project-p) (when (projectile-project-p)
(let ((default-directory (projectile-project-root))) (let ((default-directory (projectile-project-root)))
(gortium/read-dir-local 'gortium/project-tag)))) (gortium/read-dir-local 'gortium/project-tag))))
(defun gortium//read-plan-bookmarks () (defun gortium/read-plan-bookmarks ()
"Parse * Bookmarks from the Plan file. "Parse * Bookmarks from the Plan file.
Returns alist ((NAME . URL) ...) where URL is the link target." Returns alist ((NAME . URL) ...) where URL is the link target."
(when-let* ((plan-file (gortium//project-plan-file)) (when-let* ((plan-file (gortium/project-plan-file))
(_ (file-exists-p plan-file))) (_ (file-exists-p plan-file)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents plan-file) (insert-file-contents plan-file)
@@ -2641,7 +2641,7 @@ Returns alist ((NAME . URL) ...) where URL is the link target."
(setq gortium/project-bookmark-names (mapcar #'car bookmarks)) (setq gortium/project-bookmark-names (mapcar #'car bookmarks))
(nreverse bookmarks)))))) (nreverse bookmarks))))))
(defun gortium//append-bookmark-to-plan (name url) (defun gortium/append-bookmark-to-plan (name url)
"Add a bookmark NAME with URL to the project's .bookmarks file. "Add a bookmark NAME with URL to the project's .bookmarks file.
Saves only project bookmarks without contaminating global list." Saves only project bookmarks without contaminating global list."
(when (projectile-project-p) (when (projectile-project-p)
@@ -2657,9 +2657,9 @@ Saves only project bookmarks without contaminating global list."
;; Restore globals ;; Restore globals
(setq bookmark-alist saved-alist) (setq bookmark-alist saved-alist)
(message "Bookmark added to .bookmarks")))) (message "Bookmark added to .bookmarks"))))
(defun gortium//remove-bookmark-from-plan (name) (defun gortium/remove-bookmark-from-plan (name)
"Remove a bookmark entry from * Bookmarks in the Plan file." "Remove a bookmark entry from * Bookmarks in the Plan file."
(when-let* ((plan-file (gortium//project-plan-file))) (when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents plan-file) (insert-file-contents plan-file)
(goto-char (point-min)) (goto-char (point-min))
@@ -2683,7 +2683,7 @@ Project bookmarks go to .bookmarks file in project root."
(?g (call-interactively 'bookmark-set)) (?g (call-interactively 'bookmark-set))
(?p (?p
(if (projectile-project-p) (if (projectile-project-p)
(let* ((tag (or (gortium//project-tag) "project")) (let* ((tag (or (gortium/project-tag) "project"))
(name (read-string (format "[%s] Bookmark name: " tag))) (name (read-string (format "[%s] Bookmark name: " tag)))
(proj-file (expand-file-name (proj-file (expand-file-name
".bookmarks" (projectile-project-root))) ".bookmarks" (projectile-project-root)))
@@ -2705,9 +2705,9 @@ Project bookmarks go to .bookmarks file in project root."
(user-error "Not in a Projectile project")))))) (user-error "Not in a Projectile project"))))))
(defun gortium//sync-plan-to-bookmark-file (bookmarks) (defun gortium/sync-plan-to-bookmark-file (bookmarks)
"Write BOOKMARKS alist back to the Plan file under * Bookmarks." "Write BOOKMARKS alist back to the Plan file under * Bookmarks."
(when-let* ((plan-file (gortium//project-plan-file))) (when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents plan-file) (insert-file-contents plan-file)
(when (re-search-forward "^\* Bookmarks" nil t) (when (re-search-forward "^\* Bookmarks" nil t)
@@ -2729,17 +2729,17 @@ Project bookmarks go to .bookmarks file in project root."
(let* ((name (completing-read "Transfer to project: " (bookmark-all-names) nil t)) (let* ((name (completing-read "Transfer to project: " (bookmark-all-names) nil t))
(file (bookmark-location name))) (file (bookmark-location name)))
(when (and name file (y-or-n-p (format "Transfer '%s' to project? " name))) (when (and name file (y-or-n-p (format "Transfer '%s' to project? " name)))
(gortium//append-bookmark-to-plan name file) (gortium/append-bookmark-to-plan name file)
(bookmark-delete name) (bookmark-delete name)
(bookmark-save) (bookmark-save)
(message "Transferred '%s' to project %s" name (message "Transferred '%s' to project %s" name
(or (gortium//project-tag) "")))) (or (gortium/project-tag) ""))))
(user-error "Not in a Projectile project"))) (user-error "Not in a Projectile project")))
(defun gortium/transfer-to-global () (defun gortium/transfer-to-global ()
"Transfer a project bookmark to the global bookmarks list." "Transfer a project bookmark to the global bookmarks list."
(interactive) (interactive)
(let* ((bookmarks (gortium//read-plan-bookmarks)) (let* ((bookmarks (gortium/read-plan-bookmarks))
(names (mapcar #'car bookmarks))) (names (mapcar #'car bookmarks)))
(if names (if names
(let* ((name (completing-read "Transfer to global: " names nil t)) (let* ((name (completing-read "Transfer to global: " names nil t))
@@ -2747,7 +2747,7 @@ Project bookmarks go to .bookmarks file in project root."
(when (and name url (y-or-n-p (format "Transfer '%s' to global? " name))) (when (and name url (y-or-n-p (format "Transfer '%s' to global? " name)))
(bookmark-store name `((filename . ,url)) t) (bookmark-store name `((filename . ,url)) t)
(bookmark-save) (bookmark-save)
(gortium//remove-bookmark-from-plan name) (gortium/remove-bookmark-from-plan name)
(message "Transferred '%s' to global" name))) (message "Transferred '%s' to global" name)))
(message "No project bookmarks to transfer.")))) (message "No project bookmarks to transfer."))))
@@ -2771,6 +2771,13 @@ Project bookmarks go to .bookmarks file in project root."
(setq bookmark-default-file saved-file) (setq bookmark-default-file saved-file)
(setq bookmark-alist saved-alist)) (setq bookmark-alist saved-alist))
nil t)))))) 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 () (defun gortium/refile-to-today-daily ()
"Refile the current subtree under the 'Journal' headline in today's daily note. "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 This version uses `org-roam-dailies-capture-today` to ensure the daily note