emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
502 stars 54 forks source link

citar-open-entry from embark menu does not jump to bibtex entry #715

Closed fleimgruber closed 1 year ago

fleimgruber commented 1 year ago

Describe the bug citar-open-entry from embark menu does not jump to the bibtex entry at point, but only opens the bibtex file with point on first line.

To Reproduce Steps to reproduce the behavior:

  1. Press RET on a citation key in org-mode
  2. Press e for citar-open-entry

Expected behavior Point moves to referenced citation in opened bibtex file

Screenshots

Emacs version: 28.2.50

Additional context Using citar from github via Spacemacs with this configuration:

(defun pbz/init-citar()
  (use-package citar
    :no-require
    :init
    (use-package oc)
    (use-package citar-embark
      :after citar embark
      :no-require
      :config (citar-embark-mode))
    :custom
    (org-cite-global-bibliography '("~/the.bib"))
    (org-cite-insert-processor 'citar)
    (org-cite-follow-processor 'citar)
    (org-cite-activate-processor 'citar)
    (citar-bibliography org-cite-global-bibliography)
    (citar-at-point-function 'embark-act)
    ;; optional: org-cite-insert is also bound to C-c C-x C-@
    :bind
    (:map org-mode-map :package org ("C-c b" . #'org-cite-insert))))
bdarcus commented 1 year ago

If I invoke embark-act at point, and choose e, it opens to the correct location in the file.

Am not really sure what to suggest, then.

fleimgruber commented 1 year ago

Thanks for checking back so quickly. Could you give me a heads up on where I should try to debug this, i.e. in which function do you think I could see the problem manifest?

bdarcus commented 1 year ago

What happens if you invoke the command directly, without embark-act?

And are you on the latest citar code?

fleimgruber commented 1 year ago

What happens if you invoke the command directly, without embark-act?

When doing M-x citar-open-entry a helm menu opens up and when I select the reference in question it jumps to the reference in the bibtex as expected.

And are you on the latest citar code?

Yes: 6df14e352a0e63c723c22d66152e7d77fb2e5615.

bdarcus commented 1 year ago

Weird.

You're using helm for completion, and not vertico?

Not sure why, but perhaps that could have something to do with it?

fleimgruber commented 1 year ago

Yes, I use helm via Spacemacs and I am quite happy with it. The default completion list with helm did not quite work with citar though so I tried with embark.

bdarcus commented 1 year ago

Is helm known to work reliably with embark? This issue may suggest not?

https://github.com/oantolin/embark/issues/6

If not, you could always try a hydra processor.

https://github.com/emacs-citar/citar/wiki/Hydra-org-cite-follow-processor

fleimgruber commented 1 year ago

From quick skimming I understood that embark is focused on "at point" problems. For me in the failing case embark seems to work fine and I guess helm is not even involved.

But thanks for mentioning the hydra processor, will try that.

fleimgruber commented 1 year ago

I noticed an error with the code on the wiki: Symbol’s function definition is void: citar-key-finder

bdarcus commented 1 year ago

From quick skimming I understood that embark is focused on "at point" problems.

Embark provides contextual actions, both in the minibuffer (like helm/ivy actions) and at-point (like hydra). It does so through completing-read. That's why I'm speculating there's some incompatibility with helm there.

I'll take a look at the error.

fleimgruber commented 1 year ago

I see, thanks for clarification.

bdarcus commented 1 year ago

Can you try replacing that function with citar-key-at-point?

I edited that wiki page just now, though haven't tested it.

fleimgruber commented 1 year ago

citar-hydra-open-entry: Wrong number of arguments: citar--open-entry, 1

bdarcus commented 1 year ago

OK, I'll actually test it in a bit and figure it out ;-)

bdarcus commented 1 year ago

Alright, give it another try.

I don't have time to fully test it, but the e menu option works for me (as, now, does n) :-)

EDIT: I fixed the other options too. We had a major API update a few months back, and forgot to update this example code.

If you do tweak it, feel free to update the wiki page, so others may benefit?

fleimgruber commented 1 year ago

Thanks for you prompt replies and the fast fix, the hydra works for me.

If you do tweak it, feel free to update the wiki page, so others may benefit?

Sure, will do in case.