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))))
|
(temp-graph (make-temp-file "graph." nil (concat "." org-roam-graph-filetype))))
|
||||||
(org-roam-message "building graph")
|
(org-roam-message "building graph")
|
||||||
(make-process
|
(make-process
|
||||||
:name "*org-roam-graph--build-process*"
|
:name "*org-roam-graph*"
|
||||||
:buffer "*org-roam-graph--build-process*"
|
:buffer " *org-roam-graph*"
|
||||||
:command `(,org-roam-graph-executable ,temp-dot "-T" ,org-roam-graph-filetype "-o" ,temp-graph)
|
:command `(,org-roam-graph-executable ,temp-dot "-T" ,org-roam-graph-filetype "-o" ,temp-graph)
|
||||||
:sentinel (when callback
|
:sentinel (when callback
|
||||||
(lambda (process _event)
|
(lambda (process _event)
|
||||||
|
@@ -76,8 +76,10 @@ It takes a single argument NODE, which is an `org-roam-node' construct."
|
|||||||
|
|
||||||
(defcustom org-roam-node-default-sort 'file-mtime
|
(defcustom org-roam-node-default-sort 'file-mtime
|
||||||
"Default sort order for Org-roam node completions."
|
"Default sort order for Org-roam node completions."
|
||||||
:type '(choice (const :tag "file-mtime" file-mtime)
|
:type '(choice
|
||||||
(const :tag "file-atime" file-atime))
|
(const :tag "none" nil)
|
||||||
|
(const :tag "file-mtime" file-mtime)
|
||||||
|
(const :tag "file-atime" file-atime))
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
(defcustom org-roam-node-template-prefixes
|
(defcustom org-roam-node-template-prefixes
|
||||||
@@ -460,10 +462,15 @@ If REQUIRE-MATCH, the minibuffer prompt will require a match."
|
|||||||
"Node: "
|
"Node: "
|
||||||
(lambda (string pred action)
|
(lambda (string pred action)
|
||||||
(if (eq action 'metadata)
|
(if (eq action 'metadata)
|
||||||
'(metadata
|
`(metadata
|
||||||
(annotation-function . (lambda (title)
|
;; Preserve sorting in the completion UI if a sort-fn is used
|
||||||
(funcall org-roam-node-annotation-function
|
,@(when sort-fn
|
||||||
(get-text-property 0 'node title))))
|
'((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))
|
(category . org-roam-node))
|
||||||
(complete-with-action action nodes string pred)))
|
(complete-with-action action nodes string pred)))
|
||||||
nil require-match initial-input)))
|
nil require-match initial-input)))
|
||||||
@@ -695,9 +702,7 @@ We use this as a substitute for `org-link-bracket-re', because
|
|||||||
start (match-beginning 2)
|
start (match-beginning 2)
|
||||||
end (match-end 2))
|
end (match-end 2))
|
||||||
(list start end
|
(list start end
|
||||||
(completion-table-dynamic
|
(org-roam--get-titles)
|
||||||
(lambda (_)
|
|
||||||
(funcall #'org-roam--get-titles)))
|
|
||||||
:exit-function
|
:exit-function
|
||||||
(lambda (str &rest _)
|
(lambda (str &rest _)
|
||||||
(delete-char (- 0 (length str)))
|
(delete-char (- 0 (length str)))
|
||||||
@@ -718,9 +723,7 @@ hence \"everywhere\"."
|
|||||||
(not (save-match-data (org-in-regexp org-link-any-re))))
|
(not (save-match-data (org-in-regexp org-link-any-re))))
|
||||||
(let ((bounds (bounds-of-thing-at-point 'word)))
|
(let ((bounds (bounds-of-thing-at-point 'word)))
|
||||||
(list (car bounds) (cdr bounds)
|
(list (car bounds) (cdr bounds)
|
||||||
(completion-table-dynamic
|
(org-roam--get-titles)
|
||||||
(lambda (_)
|
|
||||||
(funcall #'org-roam--get-titles)))
|
|
||||||
:exit-function
|
:exit-function
|
||||||
(lambda (str _status)
|
(lambda (str _status)
|
||||||
(delete-char (- (length str)))
|
(delete-char (- (length str)))
|
||||||
@@ -915,10 +918,9 @@ filtered out."
|
|||||||
(ref (completing-read "Ref: "
|
(ref (completing-read "Ref: "
|
||||||
(lambda (string pred action)
|
(lambda (string pred action)
|
||||||
(if (eq action 'metadata)
|
(if (eq action 'metadata)
|
||||||
'(metadata
|
`(metadata
|
||||||
(annotation-function . (lambda (ref)
|
(annotation-function
|
||||||
(funcall org-roam-ref-annotation-function
|
. ,org-roam-ref-annotation-function)
|
||||||
ref)))
|
|
||||||
(category . org-roam-ref))
|
(category . org-roam-ref))
|
||||||
(complete-with-action action refs string pred)))
|
(complete-with-action action refs string pred)))
|
||||||
nil t initial-input)))
|
nil t initial-input)))
|
||||||
|
Reference in New Issue
Block a user