summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2025-01-19 02:05:02 +0200
committerThanos Apollo <[email protected]>2025-01-19 02:07:01 +0200
commitf4d43a0278da28e59dd4173a1d01e25bb9f160f9 (patch)
tree287bfb8905266b2995c5981c569d0a1d8f3a1c7b
parentb7ea215496969f1fc3302855e0d4f6f5da5e815b (diff)
[Rewrite] goto-id: Add support for journals.
* Add support for opening journal entries. * Rewrite using a cond statement * Make sure org-gnosis-mode is enabled.
-rw-r--r--org-gnosis.el22
1 files changed, 14 insertions, 8 deletions
diff --git a/org-gnosis.el b/org-gnosis.el
index 6d85299..ebe7983 100644
--- a/org-gnosis.el
+++ b/org-gnosis.el
@@ -468,20 +468,26 @@ TEMPLATE: Journaling template, refer to `org-gnosis-journal-templates'."
(id-link (when (and (eq (org-element-type element) 'link)
(string= (org-element-property :type element) "id"))
(org-element-property :path element))))
- (and id-link id-link)))
-
+ id-link))
(defun org-gnosis-goto-id (&optional id)
"Visit file for ID.
If file or id are not found, use `org-open-at-point'."
(interactive)
- (let* ((id (or id (org-gnosis--get-id-at-point)))
- (file (caar (org-gnosis-select 'file 'nodes `(= id ,id)))))
- (if (and id file)
- (progn (find-file (expand-file-name file org-gnosis-dir))
- (org-gnosis-mode))
- (org-open-at-point))))
+ (let* ((id (or id (org-gnosis--get-id-at-point))))
+ (cond ((org-gnosis-select 'file 'nodes `(= id ,id))
+ (find-file
+ (expand-file-name (car (org-gnosis-select 'file 'nodes `(= id ,id) t))
+ org-gnosis-dir))
+ (org-id-goto id))
+ ((org-gnosis-select 'file 'journal `(= id ,id))
+ (find-file
+ (expand-file-name (car (org-gnosis-select 'file 'journal `(= id ,id) t))
+ org-gnosis-journal-dir))
+ (org-id-goto id))
+ (t (org-open-at-point)))
+ (org-gnosis-mode 1)))
(defvar-keymap org-gnosis-mode-map
:doc "org-gnosis keymap"