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
|
|
@ -558,6 +558,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
|
||||||
*Fixes*
|
*Fixes*
|
||||||
+ Remove text properties from to-do keywords before displaying them in an ~org-ql-view~ buffer. (Such text properties could cause them to, e.g. display with extra leading spaces, depending on which other modes might be enabled in the source Org buffer.)
|
+ Remove text properties from to-do keywords before displaying them in an ~org-ql-view~ buffer. (Such text properties could cause them to, e.g. display with extra leading spaces, depending on which other modes might be enabled in the source Org buffer.)
|
||||||
+ Binding of ~completion-styles-alist~ in ~org-ql-completing-read~. (This fixes compatibility with Helm's ~helm~ completion style, as well as default Emacs completion in recursive minibuffers. [[https://github.com/alphapapa/org-ql/issues/337][#337]]. Thanks to [[https://github.com/progfolio][Nicholas Vollmer]], [[https://github.com/9viz][viz]], and [[https://github.com/karthink][Karthik Chikmagalur]] for reporting and suggesting fixes.)
|
+ Binding of ~completion-styles-alist~ in ~org-ql-completing-read~. (This fixes compatibility with Helm's ~helm~ completion style, as well as default Emacs completion in recursive minibuffers. [[https://github.com/alphapapa/org-ql/issues/337][#337]]. Thanks to [[https://github.com/progfolio][Nicholas Vollmer]], [[https://github.com/9viz][viz]], and [[https://github.com/karthink][Karthik Chikmagalur]] for reporting and suggesting fixes.)
|
||||||
|
+ Use of the context snippet function for ~org-ql-completing-read~. ([[https://github.com/alphapapa/org-ql/issues/419][#419]]. Thanks to [[https://github.com/tpeacock19][tpeacock19]] for reporting.)
|
||||||
|
|
||||||
** 0.8.7
|
** 0.8.7
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,11 +106,13 @@ value, or nil."
|
||||||
;; responsive as, e.g. Helm while typing, but it seems to
|
;; responsive as, e.g. Helm while typing, but it seems to
|
||||||
;; help a little when using the org-rifle-style snippets.
|
;; help a little when using the org-rifle-style snippets.
|
||||||
(org-with-point-at marker
|
(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))))
|
(org-ql-completing-read--snippet-simple))))
|
||||||
(`t ;; Interrupted: return nil (which can be concatted).
|
(`t ;; Interrupted: return nil (which can be concatted).
|
||||||
nil)
|
nil)
|
||||||
(else else)))
|
(else (propertize (concat " " else)
|
||||||
|
'face 'org-ql-completing-read-snippet))))
|
||||||
|
|
||||||
(defun org-ql-completing-read-path (marker)
|
(defun org-ql-completing-read-path (marker)
|
||||||
"Return formatted outline path for entry at 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,
|
;; 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
|
;; e.g. Helm while typing, but it seems to help a little when using the
|
||||||
;; org-rifle-style snippets.
|
;; org-rifle-style snippets.
|
||||||
(or (snippet (get-text-property 0 'org-marker candidate)) "")))
|
(or (funcall 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)))
|
|
||||||
(group (candidate transform)
|
(group (candidate transform)
|
||||||
(pcase transform
|
(pcase transform
|
||||||
(`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate))))
|
(`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate))))
|
||||||
|
|
@ -368,7 +362,7 @@ single predicate)."
|
||||||
(car (hash-table-values table))
|
(car (hash-table-values table))
|
||||||
(user-error "No results for input"))))))
|
(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.
|
"Return a snippet of the current entry.
|
||||||
Returns up to `org-ql-completing-read-snippet-length' characters."
|
Returns up to `org-ql-completing-read-snippet-length' characters."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
|
@ -382,15 +376,15 @@ Returns up to `org-ql-completing-read-snippet-length' characters."
|
||||||
t t)
|
t t)
|
||||||
50 nil nil t))))))
|
50 nil nil t))))))
|
||||||
|
|
||||||
(defun org-ql-completing-read--snippet-regexp (regexp)
|
(defun org-ql-completing-read--snippet-regexp (&optional input-regexp)
|
||||||
"Return a snippet of the current entry's matches for 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.
|
;; REGEXP may be nil if there are no qualifying tokens in the query.
|
||||||
(when regexp
|
(when input-regexp
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(org-end-of-meta-data t)
|
(org-end-of-meta-data t)
|
||||||
(unless (org-at-heading-p)
|
(unless (org-at-heading-p)
|
||||||
(let* ((end (org-entry-end-position))
|
(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 "…"
|
concat (match-string 0) concat "…"
|
||||||
do (goto-char (match-end 0)))))
|
do (goto-char (match-end 0)))))
|
||||||
(unless (string-empty-p snippets)
|
(unless (string-empty-p snippets)
|
||||||
|
|
|
||||||
87
org-ql.info
87
org-ql.info
|
|
@ -1094,6 +1094,9 @@ File: README.info, Node: 088-pre, Next: 087, Up: Changelog
|
||||||
Nicholas Vollmer (https://github.com/progfolio), viz
|
Nicholas Vollmer (https://github.com/progfolio), viz
|
||||||
(https://github.com/9viz), and Karthik Chikmagalur
|
(https://github.com/9viz), and Karthik Chikmagalur
|
||||||
(https://github.com/karthink) for reporting and suggesting fixes.)
|
(https://github.com/karthink) for reporting and suggesting fixes.)
|
||||||
|
• Use of the context snippet function for ‘org-ql-completing-read’.
|
||||||
|
(#419 (https://github.com/alphapapa/org-ql/issues/419). Thanks to
|
||||||
|
tpeacock19 (https://github.com/tpeacock19) for reporting.)
|
||||||
|
|
||||||
|
|
||||||
File: README.info, Node: 087, Next: 086, Prev: 088-pre, Up: Changelog
|
File: README.info, Node: 087, Next: 086, Prev: 088-pre, Up: Changelog
|
||||||
|
|
@ -2051,48 +2054,48 @@ Node: Links38925
|
||||||
Node: Tips39612
|
Node: Tips39612
|
||||||
Node: Changelog39936
|
Node: Changelog39936
|
||||||
Node: 088-pre40872
|
Node: 088-pre40872
|
||||||
Node: 08741735
|
Node: 08741948
|
||||||
Node: 08642967
|
Node: 08643180
|
||||||
Node: 08543201
|
Node: 08543414
|
||||||
Node: 08443857
|
Node: 08444070
|
||||||
Node: 08344309
|
Node: 08344522
|
||||||
Node: 08244650
|
Node: 08244863
|
||||||
Node: 08145043
|
Node: 08145256
|
||||||
Node: 0845464
|
Node: 0845677
|
||||||
Node: 07448188
|
Node: 07448401
|
||||||
Node: 07348413
|
Node: 07348626
|
||||||
Node: 07249147
|
Node: 07249360
|
||||||
Node: 07150068
|
Node: 07150281
|
||||||
Node: 0750879
|
Node: 0751092
|
||||||
Node: 06353745
|
Node: 06353958
|
||||||
Node: 06254278
|
Node: 06254491
|
||||||
Node: 06154585
|
Node: 06154798
|
||||||
Node: 0655155
|
Node: 0655368
|
||||||
Node: 05258211
|
Node: 05258424
|
||||||
Node: 05158513
|
Node: 05158726
|
||||||
Node: 0558938
|
Node: 0559151
|
||||||
Node: 04960469
|
Node: 04960682
|
||||||
Node: 04860751
|
Node: 04860964
|
||||||
Node: 04761100
|
Node: 04761313
|
||||||
Node: 04661509
|
Node: 04661722
|
||||||
Node: 04561917
|
Node: 04562130
|
||||||
Node: 04462278
|
Node: 04462491
|
||||||
Node: 04362637
|
Node: 04362850
|
||||||
Node: 04262840
|
Node: 04263053
|
||||||
Node: 04163001
|
Node: 04163214
|
||||||
Node: 0463248
|
Node: 0463461
|
||||||
Node: 03267349
|
Node: 03267562
|
||||||
Node: 03167752
|
Node: 03167965
|
||||||
Node: 0367949
|
Node: 0368162
|
||||||
Node: 02371249
|
Node: 02371462
|
||||||
Node: 02271483
|
Node: 02271696
|
||||||
Node: 02171763
|
Node: 02171976
|
||||||
Node: 0271968
|
Node: 0272181
|
||||||
Node: 0176046
|
Node: 0176259
|
||||||
Node: Notes76147
|
Node: Notes76360
|
||||||
Node: Comparison with Org Agenda searches76309
|
Node: Comparison with Org Agenda searches76522
|
||||||
Node: org-sidebar77198
|
Node: org-sidebar77411
|
||||||
Node: License77477
|
Node: License77690
|
||||||
|
|
||||||
End Tag Table
|
End Tag Table
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue