tweak(vertico): improve org consult source
- only add if :lang org is on - have a version that works before org is loaded
This commit is contained in:
parent
c13b59395c
commit
08f32e6d0f
1 changed files with 23 additions and 7 deletions
|
@ -136,14 +136,30 @@ orderless."
|
||||||
(consult-customize
|
(consult-customize
|
||||||
consult-theme
|
consult-theme
|
||||||
:preview-key (list (kbd "C-SPC") :debounce 0.5 'any))
|
:preview-key (list (kbd "C-SPC") :debounce 0.5 'any))
|
||||||
(after! org
|
(when (featurep! :lang org)
|
||||||
(defvar +vertico--consult-org-source
|
(defvar +vertico--consult-org-source
|
||||||
`(:name "Org"
|
(list :name "Org Buffer"
|
||||||
:narrow ?o
|
:category 'buffer
|
||||||
:hidden t
|
:narrow ?o
|
||||||
:category buffer
|
:hidden t
|
||||||
:state ,#'consult--buffer-state
|
:face 'consult-buffer
|
||||||
:items ,(lambda () (mapcar #'buffer-name (org-buffer-list)))))
|
:history 'buffer-name-history
|
||||||
|
:state #'consult--buffer-state
|
||||||
|
:new
|
||||||
|
(lambda (name)
|
||||||
|
(with-current-buffer (get-buffer-create name)
|
||||||
|
(insert "#+title: " name "\n\n")
|
||||||
|
(org-mode)
|
||||||
|
(consult--buffer-action (current-buffer))))
|
||||||
|
:items
|
||||||
|
(lambda ()
|
||||||
|
(mapcar #'buffer-name
|
||||||
|
(if (featurep 'org)
|
||||||
|
(org-buffer-list)
|
||||||
|
(seq-filter
|
||||||
|
(lambda (x)
|
||||||
|
(eq (buffer-local-value 'major-mode x) 'org-mode))
|
||||||
|
(buffer-list)))))))
|
||||||
(add-to-list 'consult-buffer-sources '+vertico--consult-org-source 'append)))
|
(add-to-list 'consult-buffer-sources '+vertico--consult-org-source 'append)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue