(fix)completions: improve completion-at-point slightly (#1896)

* Allow capfs to run after org-roam-complete-everywhere. This is
  necessary since org-roam-complete-everywhere gets triggered on every
  word, even if no match has been found.
* Simpler hook setup. org-roam-complete-at-point is unnecessary, better
  add the capfs directly.
This commit is contained in:
Daniel Mendler
2021-10-11 07:57:24 +02:00
committed by GitHub
parent 3a54182bb1
commit 5b933bd8ec

View File

@@ -727,16 +727,17 @@ hence \"everywhere\"."
:exit-function
(lambda (str _status)
(delete-char (- (length str)))
(insert "[[roam:" str "]]"))))))
(defun org-roam-complete-at-point ()
"Try get completion candidates at point using `org-roam-completion-functions'."
(run-hook-with-args-until-success 'org-roam-completion-functions))
(insert "[[roam:" str "]]"))
;; Proceed with the next completion function if the returned titles
;; do not match. This allows the default Org capfs or custom capfs
;; of lower priority to run.
:exclusive 'no))))
(add-hook 'org-roam-find-file-hook #'org-roam--register-completion-functions-h)
(defun org-roam--register-completion-functions-h ()
"Setup `org-roam-completion-functions' for `completion-at-point'."
(add-hook 'completion-at-point-functions #'org-roam-complete-at-point nil t))
(dolist (f org-roam-completion-functions)
(add-hook 'completion-at-point-functions f nil t)))
;;;; Editing
(defun org-roam-demote-entire-buffer ()