diff --git a/lisp/init-completion.el b/lisp/init-completion.el index 072fce1..19b65bb 100644 --- a/lisp/init-completion.el +++ b/lisp/init-completion.el @@ -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 diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el index d4b495c..8f62754 100644 --- a/lisp/init-kbd-func.el +++ b/lisp/init-kbd-func.el @@ -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) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index 4fe9697..84fdade 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -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