fix: restore bookmark key bindings
This commit is contained in:
@@ -3462,8 +3462,7 @@ Otherwise, prompts for a single directory, defaulting to the item under the curs
|
||||
** Project-Aware Agenda
|
||||
|
||||
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
|
||||
get a context-scoped agenda.
|
||||
project-specific custom agenda command.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun gortium/read-dir-local (var)
|
||||
@@ -3529,25 +3528,29 @@ to .org files under the project root."
|
||||
#'gortium/inject-project-agenda)
|
||||
;; Also inject at startup and on file open in a project
|
||||
(add-hook 'find-file-hook #'gortium/inject-project-agenda)
|
||||
#+end_src
|
||||
|
||||
** Bookmarks
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defvar gortium/project-bookmark-names nil
|
||||
"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."
|
||||
(when-let* ((root (projectile-project-root)))
|
||||
(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."
|
||||
(when (projectile-project-p)
|
||||
(let ((default-directory (projectile-project-root)))
|
||||
(gortium/read-dir-local 'gortium/project-tag))))
|
||||
|
||||
(defun gortium//read-plan-bookmarks ()
|
||||
(defun gortium/read-plan-bookmarks ()
|
||||
"Parse * Bookmarks from the Plan file.
|
||||
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)))
|
||||
(with-temp-buffer
|
||||
(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))
|
||||
(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.
|
||||
Saves only project bookmarks without contaminating global list."
|
||||
(when (projectile-project-p)
|
||||
@@ -3587,9 +3590,9 @@ Saves only project bookmarks without contaminating global list."
|
||||
;; Restore globals
|
||||
(setq bookmark-alist saved-alist)
|
||||
(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."
|
||||
(when-let* ((plan-file (gortium//project-plan-file)))
|
||||
(when-let* ((plan-file (gortium/project-plan-file)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents plan-file)
|
||||
(goto-char (point-min))
|
||||
@@ -3613,7 +3616,7 @@ Project bookmarks go to .bookmarks file in project root."
|
||||
(?g (call-interactively 'bookmark-set))
|
||||
(?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)))
|
||||
(proj-file (expand-file-name
|
||||
".bookmarks" (projectile-project-root)))
|
||||
@@ -3635,9 +3638,9 @@ Project bookmarks go to .bookmarks file in project root."
|
||||
(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."
|
||||
(when-let* ((plan-file (gortium//project-plan-file)))
|
||||
(when-let* ((plan-file (gortium/project-plan-file)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents plan-file)
|
||||
(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))
|
||||
(file (bookmark-location 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-save)
|
||||
(message "Transferred '%s' to project %s" name
|
||||
(or (gortium//project-tag) ""))))
|
||||
(or (gortium/project-tag) ""))))
|
||||
(user-error "Not in a Projectile project")))
|
||||
|
||||
(defun gortium/transfer-to-global ()
|
||||
"Transfer a project bookmark to the global bookmarks list."
|
||||
(interactive)
|
||||
(let* ((bookmarks (gortium//read-plan-bookmarks))
|
||||
(let* ((bookmarks (gortium/read-plan-bookmarks))
|
||||
(names (mapcar #'car bookmarks)))
|
||||
(if names
|
||||
(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)))
|
||||
(bookmark-store name `((filename . ,url)) t)
|
||||
(bookmark-save)
|
||||
(gortium//remove-bookmark-from-plan name)
|
||||
(gortium/remove-bookmark-from-plan name)
|
||||
(message "Transferred '%s' to global" name)))
|
||||
(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-alist saved-alist))
|
||||
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 ()
|
||||
"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
|
||||
@@ -3725,9 +3738,7 @@ is created with Org-roam’s templates (including :ID:)."
|
||||
(insert "\n")
|
||||
(org-paste-subtree (+ 1 parent-level))))))
|
||||
(message "Task refiled under '%s' in today’s daily note." headline))))
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun gortium/refile-to-daily-of-close ()
|
||||
"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,
|
||||
@@ -3762,6 +3773,7 @@ fallback to today's daily note. Ensures the daily has an Org-roam ID."
|
||||
headline
|
||||
(file-name-nondirectory daily-file)))))
|
||||
#+end_src
|
||||
|
||||
** Emacs-Everywhere for Hyprland
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
||||
@@ -2603,21 +2603,21 @@ to .org files under the project root."
|
||||
(defvar gortium/project-bookmark-names nil
|
||||
"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."
|
||||
(when-let* ((root (projectile-project-root)))
|
||||
(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."
|
||||
(when (projectile-project-p)
|
||||
(let ((default-directory (projectile-project-root)))
|
||||
(gortium/read-dir-local 'gortium/project-tag))))
|
||||
|
||||
(defun gortium//read-plan-bookmarks ()
|
||||
(defun gortium/read-plan-bookmarks ()
|
||||
"Parse * Bookmarks from the Plan file.
|
||||
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)))
|
||||
(with-temp-buffer
|
||||
(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))
|
||||
(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.
|
||||
Saves only project bookmarks without contaminating global list."
|
||||
(when (projectile-project-p)
|
||||
@@ -2657,9 +2657,9 @@ Saves only project bookmarks without contaminating global list."
|
||||
;; Restore globals
|
||||
(setq bookmark-alist saved-alist)
|
||||
(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."
|
||||
(when-let* ((plan-file (gortium//project-plan-file)))
|
||||
(when-let* ((plan-file (gortium/project-plan-file)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents plan-file)
|
||||
(goto-char (point-min))
|
||||
@@ -2683,7 +2683,7 @@ Project bookmarks go to .bookmarks file in project root."
|
||||
(?g (call-interactively 'bookmark-set))
|
||||
(?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)))
|
||||
(proj-file (expand-file-name
|
||||
".bookmarks" (projectile-project-root)))
|
||||
@@ -2705,9 +2705,9 @@ Project bookmarks go to .bookmarks file in project root."
|
||||
(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."
|
||||
(when-let* ((plan-file (gortium//project-plan-file)))
|
||||
(when-let* ((plan-file (gortium/project-plan-file)))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents plan-file)
|
||||
(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))
|
||||
(file (bookmark-location 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-save)
|
||||
(message "Transferred '%s' to project %s" name
|
||||
(or (gortium//project-tag) ""))))
|
||||
(or (gortium/project-tag) ""))))
|
||||
(user-error "Not in a Projectile project")))
|
||||
|
||||
(defun gortium/transfer-to-global ()
|
||||
"Transfer a project bookmark to the global bookmarks list."
|
||||
(interactive)
|
||||
(let* ((bookmarks (gortium//read-plan-bookmarks))
|
||||
(let* ((bookmarks (gortium/read-plan-bookmarks))
|
||||
(names (mapcar #'car bookmarks)))
|
||||
(if names
|
||||
(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)))
|
||||
(bookmark-store name `((filename . ,url)) t)
|
||||
(bookmark-save)
|
||||
(gortium//remove-bookmark-from-plan name)
|
||||
(gortium/remove-bookmark-from-plan name)
|
||||
(message "Transferred '%s' to global" name)))
|
||||
(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-alist saved-alist))
|
||||
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 ()
|
||||
"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
|
||||
|
||||
Reference in New Issue
Block a user