summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2025-11-23 16:06:44 +0000
committerjao <jao@gnu.org>2025-11-23 16:06:44 +0000
commit28c7b82eb5430af794191e37e1adba6f7728ac62 (patch)
treee8771edc05c8a70f19499b7ad75db215820006e0
parenta04d19d6713c2e254b77b66648e99683e0fc54b2 (diff)
downloadelibs-28c7b82eb5430af794191e37e1adba6f7728ac62.tar.gz
elibs-28c7b82eb5430af794191e37e1adba6f7728ac62.tar.bz2
org-notes: search for individual terms in input string
-rw-r--r--lib/doc/jao-org-notes.el23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el
index bd45723..af8f10a 100644
--- a/lib/doc/jao-org-notes.el
+++ b/lib/doc/jao-org-notes.el
@@ -45,7 +45,8 @@
(default-directory
(if (file-directory-p d) (expand-file-name d) default-directory))
(ts (mapconcat #'identity (split-string str "[:,]+" t) ":|"))
- (rgx (format "^#.(title: .*%s|(tags:.*(%s:)))" str ts)))
+ (s (mapconcat #'identity (cons str (split-string str nil t)) "|"))
+ (rgx (format "^#.(title: .*(%s)|(tags:.*(%s:)))" s ts)))
(jao-org-notes--rg-cmd rgx "-m" "2")))
(defun jao-org-notes--clean-match (m)
@@ -122,7 +123,8 @@
(defvar jao-org-notes--tag-history nil)
(defun jao-org-notes--read-tags ()
- (let* ((tags (completing-read-multiple "Tags: " jao-org-notes--tags nil nil nil
+ (let* ((tags (completing-read-multiple "Tags: "
+ jao-org-notes--tags nil nil nil
'jao-org-notes--tag-history)))
(setq jao-org-notes--tags (seq-union jao-org-notes--tags tags #'string=))
tags))
@@ -142,7 +144,8 @@
(let* ((file-name (or file-name buffer-file-name))
(bn (file-name-base file-name))
(rx (format "%s\\.org$" (regexp-quote bn)))
- (pred (lambda () (string-prefix-p jao-org-notes-dir buffer-file-name))))
+ (pred (lambda ()
+ (string-prefix-p jao-org-notes-dir buffer-file-name))))
(save-some-buffers nil pred)
(or (car (directory-files-recursively jao-org-notes-dir rx))
(let* ((d (completing-read "Notes subdir: " (jao-org-notes-cats) nil t))
@@ -150,9 +153,17 @@
(expand-file-name (concat d bn ".org") jao-org-notes-dir)))))
(defun jao-org-notes-open ()
- "Search for a note file, matching tags and titles with completion."
+ "Search for a note file, matching tags and titles with completion.
+
+If the search string starts with a folder name followed by a
+slash (e.g. `emacs/foo'), the search is performed only in the given
+notes folder (when it exists).
+
+Search terms that start with a colon are interpreted as tags, and can
+appear in any order in the tags list.
+"
(interactive)
- (when-let (f (jao-org-notes--consult-rg "Search notes: "))
+ (when-let (f (jao-org-notes--consult-rg "Search tags and titles: "))
(find-file f)))
(defun jao-org-notes-consult-tags ()
@@ -214,7 +225,7 @@
;;;###autoload
(defun jao-org-notes-setup (mnemonic)
- "Set up the notes system, providing a mnemonic character for its org template."
+ "Set up the notes system, providing a mnemonic char for its org template."
(setq org-capture-templates
(add-to-list 'org-capture-templates
(jao-org-notes--template mnemonic))