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:
User
2026-07-02 22:17:25 +08:00
parent ddd2ba4905
commit 58e01139b5
3 changed files with 29 additions and 3 deletions

View File

@@ -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)