Fix: Use of org-ql-completing-read--snippet-regexp
* org-ql-completing-read.el (org-ql-completing-read-snippet): Call snippet function with argument (org-ql-completing-read): Call snippet function passed in rather than hard-coded function. (org-ql-completing-read--snippet-simple): Accept optional, ignored argument. (org-ql-completing-read--snippet-regexp): Make argument optional; rename for clarity. Fixes #419. Reported-by: tpeacock19 <https://github.com/tpeacock19>
This commit is contained in:
parent
3c1dd36990
commit
04b3bd2664
3 changed files with 56 additions and 58 deletions
|
|
@ -106,11 +106,13 @@ value, or nil."
|
|||
;; responsive as, e.g. Helm while typing, but it seems to
|
||||
;; help a little when using the org-rifle-style snippets.
|
||||
(org-with-point-at marker
|
||||
(or (funcall org-ql-completing-read-snippet-function)
|
||||
(or (funcall org-ql-completing-read-snippet-function
|
||||
org-ql-completing-read-input-regexp)
|
||||
(org-ql-completing-read--snippet-simple))))
|
||||
(`t ;; Interrupted: return nil (which can be concatted).
|
||||
nil)
|
||||
(else else)))
|
||||
(else (propertize (concat " " else)
|
||||
'face 'org-ql-completing-read-snippet))))
|
||||
|
||||
(defun org-ql-completing-read-path (marker)
|
||||
"Return formatted outline path for entry at MARKER."
|
||||
|
|
@ -214,15 +216,7 @@ single predicate)."
|
|||
;; Using `while-no-input' here doesn't make it as responsive as,
|
||||
;; e.g. Helm while typing, but it seems to help a little when using the
|
||||
;; org-rifle-style snippets.
|
||||
(or (snippet (get-text-property 0 'org-marker candidate)) "")))
|
||||
(snippet (marker)
|
||||
(when-let
|
||||
((snippet
|
||||
(org-with-point-at marker
|
||||
(or (funcall org-ql-completing-read-snippet-function org-ql-completing-read-input-regexp)
|
||||
(org-ql-completing-read--snippet-simple)))))
|
||||
(propertize (concat " " snippet)
|
||||
'face 'org-ql-completing-read-snippet)))
|
||||
(or (funcall snippet (get-text-property 0 'org-marker candidate)) "")))
|
||||
(group (candidate transform)
|
||||
(pcase transform
|
||||
(`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate))))
|
||||
|
|
@ -368,7 +362,7 @@ single predicate)."
|
|||
(car (hash-table-values table))
|
||||
(user-error "No results for input"))))))
|
||||
|
||||
(defun org-ql-completing-read--snippet-simple ()
|
||||
(defun org-ql-completing-read--snippet-simple (&optional _input-regexp)
|
||||
"Return a snippet of the current entry.
|
||||
Returns up to `org-ql-completing-read-snippet-length' characters."
|
||||
(save-excursion
|
||||
|
|
@ -382,15 +376,15 @@ Returns up to `org-ql-completing-read-snippet-length' characters."
|
|||
t t)
|
||||
50 nil nil t))))))
|
||||
|
||||
(defun org-ql-completing-read--snippet-regexp (regexp)
|
||||
"Return a snippet of the current entry's matches for REGEXP."
|
||||
(defun org-ql-completing-read--snippet-regexp (&optional input-regexp)
|
||||
"Return a snippet of the current entry's matches for INPUT-REGEXP."
|
||||
;; REGEXP may be nil if there are no qualifying tokens in the query.
|
||||
(when regexp
|
||||
(when input-regexp
|
||||
(save-excursion
|
||||
(org-end-of-meta-data t)
|
||||
(unless (org-at-heading-p)
|
||||
(let* ((end (org-entry-end-position))
|
||||
(snippets (cl-loop while (re-search-forward regexp end t)
|
||||
(snippets (cl-loop while (re-search-forward input-regexp end t)
|
||||
concat (match-string 0) concat "…"
|
||||
do (goto-char (match-end 0)))))
|
||||
(unless (string-empty-p snippets)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue