jgru / consult-org-roam

A bunch of convenience functions for operating org-roam with the help of consult
GNU General Public License v3.0
121 stars 6 forks source link

After using :preview-key M-., how to jump to the previewed file directly? #22

Closed Imymirror closed 1 year ago

Imymirror commented 1 year ago

thank you for your wonderful package. It help me a lot.

I have a question I don't know how to solve : After using :preview-key M-. to preview, how to jump to the previewed file directly rather than return back to the origin file when pressing enter?

jgru commented 1 year ago

Hi @Imymirror,

thank you for your message and using consult-org-roam. I tried to triage the issue. However, I cannot reproduce the described behavior unfortunately. Using the consult-preview-key (here bound to M-.) and pressing [enter] opens the previewed file.

I configured consult like so:

(use-package consult
  :straight t
  :hook (completion-list-mode . consult-preview-at-point-mode)
  :config
  ;; Use meta-dot to trigger the preview.
  (setq consult-preview-key (kbd "M-.") ))

and set up consult-org-roam as shown below:

(use-package consult-org-roam
   :straight nil
   :load-path "/media/user01/data/lab/consult-org-roam"
   :init
   (require 'consult-org-roam)
   ;; Activate the minor mode
   (consult-org-roam-mode 1)
   :bind
   ("C-c n e" . consult-org-roam-file-find)
   ("C-c n b" . consult-org-roam-backlinks)
   ("C-c n l" . consult-org-roam-forward-links)
   ("C-c n r" . consult-org-roam-search))

May I ask you to check whether the problem might be in your config? You could run emacs -Q and use the minimal config provided in the project's wiki

Best regards, jgru

Imymirror commented 1 year ago

thank you. I upgrade all related packages, now pressing [enter] can jump to the previewed file .

but, can it jump to the location of the reference rather than the first line of the previewed file when calling consult-org-roam-backlinks ?

jgru commented 1 year ago

thank you. I upgrade all related packages, now pressing [enter] can jump to the previewed file .

Good to hear, thanks for the confirmation that it has been an issue on your configuration, @Imymirror.

but, can it jump to the location of the reference rather than the first line of the previewed file when calling consult-org-roam-backlinks ?

The currently implemented functionality is to show the node that houses the link in question. That is not necessarily the first line of the file.

As far as I can tell, there is no completely straight forward way to locate the exact position of the backlink (since it is not tracked in org-roam.db). Though one could probably search for the link and set the window accordingly. However, I am not sure how easy it is to implement this. Maybe that functionality could be added somewhere around here. If it is of utter importance to you, consider opening a feature request.

Best regards, jgru