diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/doc/jao-org-notes.el | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el index dde2b8c..4b45eab 100644 --- a/lib/doc/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el @@ -35,7 +35,7 @@ (defun jao-org-notes--rg-cmd (rgx &rest args) `("rg" "--null" "--line-buffered" "--color=never" "--max-columns=250" - "--type=org" "--line-number" "--no-heading" "--smart-case" + "--type=org" "--line-number" "--no-heading" "--smart-case" "--follow" ,@args ,default-directory "-e" ,rgx)) (defun jao-org-notes--rg-title-or-tags (str) @@ -93,7 +93,7 @@ :history '(:input jao-org-notes--grep-history)))) (defun jao-org-notes-cats () - (seq-difference (directory-files jao-org-notes-dir) '("." ".." "attic"))) + (directory-files jao-org-notes-dir nil "^[^.]")) (defun jao-org-notes--cat () (let* ((cat (completing-read "Top level category: " (jao-org-notes-cats)))) @@ -166,16 +166,27 @@ appear in any order in the tags list. (when-let (f (jao-org-notes--consult-rg "Search tags and titles: ")) (find-file f))) +(defvar jao-org-notes-consult-ripgrep-args + (format "%s -L" consult-ripgrep-args)) + +(defun jao-org-notes-consult-ripgrep (&optional ask initial) + "Search over notes in given notes categories (or all of them), using rg." + (interactive "P") + (let ((cat (when ask (completing-read "Category: " (jao-org-notes-cats)))) + (consult-ripgrep-args jao-org-notes-consult-ripgrep-args)) + (consult-ripgrep (expand-file-name (or cat "") jao-org-notes-dir) initial))) + +(defun jao-org-notes-consult-ripgrep-category (&optional initial) + "Search over notes in a given notes category." + (interactive "P") + (jao-org-notes-consult-ripgrep t initial)) + (defun jao-org-notes-consult-tags () "Search for a note file, matching all tags with completion." (interactive) (let* ((tags (jao-org-notes--read-tags)) (init (concat "^..tags: " (mapconcat #'identity tags " ")))) - (consult-ripgrep jao-org-notes-dir init))) - -(defun jao-org-notes-consult-ripgrep (&optional initial cat) - (interactive) - (consult-ripgrep (expand-file-name (or cat "") jao-org-notes-dir) initial)) + (jao-org-notes-consult-ripgrep init))) (defun jao-org-notes-create (&optional title) "Create a new note file, matching tags and titles with completion." @@ -220,16 +231,14 @@ appear in any order in the tags list. (interactive) (message "%d notes, %d tags in %s" (length (jao-org-notes-list)) - (length jao-org--notes-tags) + (length jao-org-notes--tags) jao-org-notes-dir)) ;;;###autoload (defun jao-org-notes-setup (mnemonic) "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)) - jao-org-notes--tags (jao-org-notes-all-tags)) + (add-to-list 'org-capture-templates (jao-org-notes--template mnemonic)) + (setq jao-org-notes--tags (jao-org-notes-all-tags)) (when (fboundp 'org-capture-upgrade-templates) (org-capture-upgrade-templates org-capture-templates))) |
