feat: Integrate consult with xref and enhance denote backlink commands
- Configure consult-xref for xref-show-definitions and xref-show-xrefs - Add custom denote backlink commands with consult preview support - Replace denote-backlinks keybindings with new consult-enabled versions - Fix hardcoded org path to use org-directory variable
This commit is contained in:
@@ -35,9 +35,14 @@
|
||||
(*is-linux*
|
||||
(setq consult-locate-args "plocate --basename --ignore-case")))
|
||||
|
||||
;; help
|
||||
(define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
|
||||
(setq consult-narrow-key "<")
|
||||
|
||||
;; xref
|
||||
(setq xref-show-definitions-function #'consult-xref)
|
||||
(setq xref-show-xrefs-function #'consult-xref)
|
||||
|
||||
;; set some buffer filter
|
||||
(setq consult-buffer-filter
|
||||
(cl-union consult-buffer-filter
|
||||
|
||||
@@ -110,7 +110,7 @@ otherwise toggle global-jinx-mode."
|
||||
`~/org/my-org-note/20260508T220745==metanote--all-my-metanotes__org.org'"
|
||||
(interactive)
|
||||
(find-file
|
||||
"~/org/my-org-note/20260508T220745==metanote--all-my-metanotes__org.org"))
|
||||
(concat org-directory "/20260508T220745==metanote--all-my-metanotes__org.org")))
|
||||
|
||||
(defun my-denote-find-file ()
|
||||
"Find file use denote-file-prompt."
|
||||
@@ -118,6 +118,27 @@ otherwise toggle global-jinx-mode."
|
||||
(let ((denote-excluded-files-regexp "=journal"))
|
||||
(find-file (denote-file-prompt))))
|
||||
|
||||
(defun my-denote-find-backlink-with-location ()
|
||||
"Like `denote-find-backlink-with-location' but with consult preview."
|
||||
(interactive)
|
||||
(when-let* ((current-file buffer-file-name)
|
||||
(id (or (denote-retrieve-filename-identifier current-file)
|
||||
(user-error "The current file does not have a Denote identifier")))
|
||||
(files (denote-directory-files nil :omit-current :text-only))
|
||||
(fetcher (lambda () (xref-matches-in-files id files))))
|
||||
(consult-xref fetcher nil)))
|
||||
|
||||
(defun my-denote-org-find-backlink-for-heading-with-location ()
|
||||
"Like `denote-org-backlinks-for-heading' but with consult preview."
|
||||
(interactive)
|
||||
(unless (featurep 'denote-org)
|
||||
(require 'denote-org))
|
||||
(when-let* ((heading-id (or (denote-org--get-file-id-and-heading-id-or-context)
|
||||
(user-error "The current file does not have a denote identifier")))
|
||||
(files (denote-directory-files nil :omit-current :text-only))
|
||||
(fetcher (lambda () (xref-matches-in-files heading-id files))))
|
||||
(consult-xref fetcher nil)))
|
||||
|
||||
(defun my-org-table-align-all ()
|
||||
"Ajust all table in current buffer."
|
||||
(interactive)
|
||||
|
||||
@@ -232,8 +232,8 @@
|
||||
"C-," 'crux-duplicate-current-line-or-region
|
||||
"C-c o l" 'denote-link
|
||||
"C-c o L" 'denote-org-link-to-heading
|
||||
"C-c o b" 'denote-backlinks
|
||||
"C-c o B" 'denote-org-backlinks-for-heading
|
||||
"C-c o b" 'my-denote-find-backlink-with-location
|
||||
"C-c o B" 'my-denote-org-find-backlink-for-heading-with-location
|
||||
"C-c o t" 'my-org-tree-slide-start)
|
||||
|
||||
;; org-tree-slide-mode
|
||||
|
||||
Reference in New Issue
Block a user