Fix: (org-ql-completing-read) Store markers as text property

Fixes #350
This commit is contained in:
Ankit Pandey 2023-06-21 04:02:59 -07:00 committed by Adam Porter
parent 898addeee9
commit a7af6d78b2

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)