diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/doc/jao-org-notes.el | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el index 391fa47..2c328c5 100644 --- a/lib/doc/jao-org-notes.el +++ b/lib/doc/jao-org-notes.el @@ -24,35 +24,36 @@ ;; backlinks approximation. ;;; Code: - (require 'org) (require 'consult) (defvar jao-org-notes-dir (expand-file-name "notes" org-directory)) -(defvar jao-org-notes--rg - (concat "rg --null --line-buffered --color=ansi --max-columns=250" - " --no-heading --line-number --smart-case" - " . -e \"^(#.(title|filetags): .*)ARG\" OPTS")) +(defun jao-org-notes--rg (str) + `("rg" "--null" "--line-buffered" "--color=never" "--max-columns=250" + "--no-heading" "--line-number" "--smart-case" "." "-e" + ,(format "^(#.(title|filetags): .*)%s" str))) -(defvar jao-org-notes--trx ":[0-9]+:#\\+\\(file\\)?\\(title\\|tags\\):") +(defvar jao-org-notes--trx "[0-9]+:#\\+\\(file\\)?\\(title\\|tags\\):") (defun jao-org-notes--clean-match (m) - (cons (replace-regexp-in-string jao-org-notes--trx " (\\2)" (car m)) (cdr m))) + (cons (format "%s %s" + (replace-regexp-in-string "^\\./" "" (car m)) + (replace-regexp-in-string jao-org-notes--trx " (\\2)" (cadr m))) + (expand-file-name (car m) default-directory))) (defun jao-org-notes--matches (lines) - (let ((ms (consult--grep-matches lines))) - (mapcar #'jao-org-notes--clean-match ms))) + (mapcar (lambda (l) (jao-org-notes--clean-match (split-string l "\0" t))) lines)) (defun jao-org-notes--lookup (_ cands cand) - (or (cadr (assoc cand cands)) cand)) + (or (cdr (assoc cand cands)) cand)) (defvar jao-org-notes--grep-history nil) (defun jao-org--grep (prompt &optional cat no-req) (let ((default-directory (expand-file-name (or cat "") jao-org-notes-dir))) (consult--read - (consult--async-command jao-org-notes--rg + (consult--async-command #'jao-org-notes--rg (consult--async-transform jao-org-notes--matches)) :prompt prompt :lookup #'jao-org-notes--lookup |