(feat): add case sensitivity for Org-roam completions (#1056)

Completions are now case-insensitive by default.
`org-roam-completion-case-sensitive` can be set to `t` to allow
case-sensitive completions.
This commit is contained in:
Jethro Kuan 2020-08-22 20:21:01 +08:00 committed by GitHub
parent 4e5b52fbd3
commit 38234b491d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1112,6 +1112,11 @@ This function hooks into `org-open-at-point' via
nil)))))
;;; Completion at point
(defcustom org-roam-completion-case-sensitive nil
"If t, completions for Org-roam become case sensitive."
:group 'org-roam
:type 'boolean)
(defconst org-roam-fuzzy-link-regexp
(rx (seq "[["
(group
@ -1160,7 +1165,10 @@ This function hooks into `org-open-at-point' via
(if (functionp collection)
(completion-table-dynamic
(lambda (_)
(cl-remove-if (apply-partially 'string= prefix) (funcall collection))))
(cl-remove-if (if org-roam-completion-case-sensitive
(apply-partially 'string= prefix)
(lambda (s) (string-collate-equalp prefix s nil t)))
(funcall collection))))
collection)
:exit-function exit-fn)))))