Fix: (org-ql-completing-read) Propertize strings with markers

Fixes #350.  Closes #357.
This commit is contained in:
Adam Porter 2023-09-06 16:09:18 -05:00
commit f9b60d8ef8
3 changed files with 41 additions and 34 deletions

View file

@ -546,6 +546,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Fixes* *Fixes*
+ Function ~org-ql-completing-read~ is more compatible with default Emacs completion. (See [[https://github.com/alphapapa/org-ql/issues/338][#338]]. Thanks to [[https://github.com/arozbiz][arozbiz]] for reporting.) + Function ~org-ql-completing-read~ is more compatible with default Emacs completion. (See [[https://github.com/alphapapa/org-ql/issues/338][#338]]. Thanks to [[https://github.com/arozbiz][arozbiz]] for reporting.)
+ Function ~org-ql-completing-read~ would sometimes stop updating with changes in input. (See [[https://github.com/alphapapa/org-ql/issues/350][#350]]. Thanks to [[https://github.com/anpandey][Ankit Raj Pandey]] for reporting and fixing, and to [[https://github.com/minad][Daniel Mendler]] for advising.)
+ In ~org-ql-completing-read~, format links for display, and use ~org-entry-get~ internally rather than ~org-get-heading~. + In ~org-ql-completing-read~, format links for display, and use ~org-entry-get~ internally rather than ~org-get-heading~.
** 0.7 ** 0.7

View file

@ -123,7 +123,8 @@ single predicate)."
(if-let ((suffix (gethash heading disambiguations))) (if-let ((suffix (gethash heading disambiguations)))
(setf heading (format "%s <%s>" heading (cl-incf suffix))) (setf heading (format "%s <%s>" heading (cl-incf suffix)))
(setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations))))) (setf heading (format "%s <%s>" heading (puthash heading 2 disambiguations)))))
(puthash heading (point-marker) table))) (let ((marker (point-marker)))
(puthash (propertize heading 'org-marker marker) marker table))))
(path (marker) (path (marker)
(org-with-point-at marker (org-with-point-at marker
(let* ((path (thread-first (org-get-outline-path nil t) (let* ((path (thread-first (org-get-outline-path nil t)
@ -140,7 +141,7 @@ single predicate)."
(affix (completions) (affix (completions)
;; (debug-message "AFFIX:%S" completions) ;; (debug-message "AFFIX:%S" completions)
(cl-loop for completion in completions (cl-loop for completion in completions
for marker = (gethash completion table) for marker = (get-text-property 0 'org-marker completion)
for prefix = (todo marker) for prefix = (todo marker)
for suffix = (concat (path marker) " " (snippet marker)) for suffix = (concat (path marker) " " (snippet marker))
collect (list completion prefix suffix))) collect (list completion prefix suffix)))
@ -150,7 +151,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 (gethash candidate table)) ""))) (or (snippet (get-text-property 0 'org-marker completion)) "")))
(snippet (snippet
(marker) (when-let (marker) (when-let
((snippet ((snippet
@ -161,7 +162,7 @@ single predicate)."
'face 'org-ql-completing-read-snippet))) 'face 'org-ql-completing-read-snippet)))
(group (candidate transform) (group (candidate transform)
(pcase transform (pcase transform
(`nil (buffer-name (marker-buffer (gethash candidate table)))) (`nil (buffer-name (marker-buffer (get-text-property 0 'org-marker candidate))))
(_ candidate))) (_ candidate)))
(try (string _collection _pred point &optional _metadata) (try (string _collection _pred point &optional _metadata)
;; (debug-message "TRY: STRING:%S" string) ;; (debug-message "TRY: STRING:%S" string)

View file

@ -1030,6 +1030,11 @@ File: README.info, Node: 071-pre, Next: 07, Up: Changelog
Emacs completion. (See #338 Emacs completion. (See #338
(https://github.com/alphapapa/org-ql/issues/338). Thanks to (https://github.com/alphapapa/org-ql/issues/338). Thanks to
arozbiz (https://github.com/arozbiz) for reporting.) arozbiz (https://github.com/arozbiz) for reporting.)
• Function org-ql-completing-read would sometimes stop updating
with changes in input. (See #350
(https://github.com/alphapapa/org-ql/issues/350). Thanks to Ankit
Raj Pandey (https://github.com/anpandey) for reporting and fixing,
and to Daniel Mendler (https://github.com/minad) for advising.)
• In org-ql-completing-read, format links for display, and use • In org-ql-completing-read, format links for display, and use
org-entry-get internally rather than org-get-heading. org-entry-get internally rather than org-get-heading.
@ -1754,36 +1759,36 @@ Node: Links37243
Node: Tips37930 Node: Tips37930
Node: Changelog38254 Node: Changelog38254
Node: 071-pre39025 Node: 071-pre39025
Node: 0739507 Node: 0739834
Node: 06342435 Node: 06342762
Node: 06242966 Node: 06243293
Node: 06143271 Node: 06143598
Node: 0643839 Node: 0644166
Node: 05246893 Node: 05247220
Node: 05147193 Node: 05147520
Node: 0547616 Node: 0547943
Node: 04949145 Node: 04949472
Node: 04849427 Node: 04849754
Node: 04749776 Node: 04750103
Node: 04650185 Node: 04650512
Node: 04550593 Node: 04550920
Node: 04450954 Node: 04451281
Node: 04351313 Node: 04351640
Node: 04251516 Node: 04251843
Node: 04151677 Node: 04152004
Node: 0451924 Node: 0452251
Node: 03256025 Node: 03256352
Node: 03156428 Node: 03156755
Node: 0356625 Node: 0356952
Node: 02359925 Node: 02360252
Node: 02260159 Node: 02260486
Node: 02160439 Node: 02160766
Node: 0260644 Node: 0260971
Node: 0164722 Node: 0165049
Node: Notes64823 Node: Notes65150
Node: Comparison with Org Agenda searches64985 Node: Comparison with Org Agenda searches65312
Node: org-sidebar65874 Node: org-sidebar66201
Node: License66153 Node: License66480
 
End Tag Table End Tag Table