mirror of
https://github.com/org-roam/org-roam
synced 2025-09-24 16:30:55 -05:00
(fix)completion: minor fixes around completing-read (#1893)
* (fix)org-roam-node-default-sort: Add choice nil * (fix)Ensure that annotation functions are compiled * (fix)org-roam-node-read: Preserve sorting if sort-fn is non-nil If the nodes are sorted by org-roam we don't want the completion UI to change the order. In order to disable org-roam sorting set org-roam-node-default-sort to nil. Then the sorting of the completion UI is used. * (fix)org-roam-graph--build: Use ephermeral buffer name Ephemeral buffers are hidden by default in the completion lists, which is usually desired for background processes. * (fix)capfs: Do not use completion-table-dynamic completion-table-dynamic serves a different purpose. it should only be used if the candidates are dynamically generated based on the input. This is not the case for org-roam where we the list of nodes is already available right at the beginning of the completion. This change should improve performance.
This commit is contained in:
@@ -147,8 +147,8 @@ CALLBACK is passed the graph file as its sole argument."
|
||||
(temp-graph (make-temp-file "graph." nil (concat "." org-roam-graph-filetype))))
|
||||
(org-roam-message "building graph")
|
||||
(make-process
|
||||
:name "*org-roam-graph--build-process*"
|
||||
:buffer "*org-roam-graph--build-process*"
|
||||
:name "*org-roam-graph*"
|
||||
:buffer " *org-roam-graph*"
|
||||
:command `(,org-roam-graph-executable ,temp-dot "-T" ,org-roam-graph-filetype "-o" ,temp-graph)
|
||||
:sentinel (when callback
|
||||
(lambda (process _event)
|
||||
|
@@ -76,7 +76,9 @@ It takes a single argument NODE, which is an `org-roam-node' construct."
|
||||
|
||||
(defcustom org-roam-node-default-sort 'file-mtime
|
||||
"Default sort order for Org-roam node completions."
|
||||
:type '(choice (const :tag "file-mtime" file-mtime)
|
||||
:type '(choice
|
||||
(const :tag "none" nil)
|
||||
(const :tag "file-mtime" file-mtime)
|
||||
(const :tag "file-atime" file-atime))
|
||||
:group 'org-roam)
|
||||
|
||||
@@ -460,8 +462,13 @@ If REQUIRE-MATCH, the minibuffer prompt will require a match."
|
||||
"Node: "
|
||||
(lambda (string pred action)
|
||||
(if (eq action 'metadata)
|
||||
'(metadata
|
||||
(annotation-function . (lambda (title)
|
||||
`(metadata
|
||||
;; Preserve sorting in the completion UI if a sort-fn is used
|
||||
,@(when sort-fn
|
||||
'((display-sort-function . identity)
|
||||
(cycle-sort-function . identity)))
|
||||
(annotation-function
|
||||
. ,(lambda (title)
|
||||
(funcall org-roam-node-annotation-function
|
||||
(get-text-property 0 'node title))))
|
||||
(category . org-roam-node))
|
||||
@@ -695,9 +702,7 @@ We use this as a substitute for `org-link-bracket-re', because
|
||||
start (match-beginning 2)
|
||||
end (match-end 2))
|
||||
(list start end
|
||||
(completion-table-dynamic
|
||||
(lambda (_)
|
||||
(funcall #'org-roam--get-titles)))
|
||||
(org-roam--get-titles)
|
||||
:exit-function
|
||||
(lambda (str &rest _)
|
||||
(delete-char (- 0 (length str)))
|
||||
@@ -718,9 +723,7 @@ hence \"everywhere\"."
|
||||
(not (save-match-data (org-in-regexp org-link-any-re))))
|
||||
(let ((bounds (bounds-of-thing-at-point 'word)))
|
||||
(list (car bounds) (cdr bounds)
|
||||
(completion-table-dynamic
|
||||
(lambda (_)
|
||||
(funcall #'org-roam--get-titles)))
|
||||
(org-roam--get-titles)
|
||||
:exit-function
|
||||
(lambda (str _status)
|
||||
(delete-char (- (length str)))
|
||||
@@ -915,10 +918,9 @@ filtered out."
|
||||
(ref (completing-read "Ref: "
|
||||
(lambda (string pred action)
|
||||
(if (eq action 'metadata)
|
||||
'(metadata
|
||||
(annotation-function . (lambda (ref)
|
||||
(funcall org-roam-ref-annotation-function
|
||||
ref)))
|
||||
`(metadata
|
||||
(annotation-function
|
||||
. ,org-roam-ref-annotation-function)
|
||||
(category . org-roam-ref))
|
||||
(complete-with-action action refs string pred)))
|
||||
nil t initial-input)))
|
||||
|
Reference in New Issue
Block a user