Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make citar-open more configurable #833

Open
Risto-Stevcev opened this issue Jun 11, 2024 · 9 comments
Open

Make citar-open more configurable #833

Risto-Stevcev opened this issue Jun 11, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@Risto-Stevcev
Copy link

Is your feature request related to a problem? Please describe.
I want to be able to get to the bibliography entry when I click on a citation or via citar-dwim or citar-open, but the menu that pops up only shows a link if there's a url associated with the bibliography entry, and/or one or more nodes if there's a node associated with the citation key. It's a common workflow to want to get to the entry, and it feels wonky to have to have a separate (citar-open-entry (citar-key-at-point)) for something like this.

Describe the solution you'd like
If going to the bibtex entry were an option in the menu, I could just do citar-dwim, bind that to a key like C-c o, and then select it from the menu of actions for that citation key.

Describe alternatives you've considered
Citar-embark doesn't solve the issue, because the ROAM_REFS keys are in the form of @foo @bar, which don't show up as actual highlighted links that I can click on or to C-c C-o. It does solve it sort of for [cite:@foo] links, but there's a bunch of extra stuff with embark that I don't want around because I can accidentally press a key or click on some embark menu entry that's unrelated to citar.

@Risto-Stevcev Risto-Stevcev added the enhancement New feature or request label Jun 11, 2024
@bdarcus
Copy link
Contributor

bdarcus commented Jun 13, 2024

You're going to have to clarify this, as I don't really understand your issue, or what you would like.

Examples:

  • what type of buffer? (Org?)
  • what menu? (Embark?)

You don't mention at all org-roam until the alternatives?

And on that, while org doesn't highlight the refs, citar-embark should still work on them.

Finally, your config?

I will try to come back to this later next week.

@Risto-Stevcev
Copy link
Author

Risto-Stevcev commented Jun 14, 2024

It's in an org mode file/buffer, it's not the embark menu. I attached a screenshot of the menu I'm talking about, I don't know what this menu is called:
Screenshot from 2024-06-14 08-51-29

This is my config:

(use-package citar-org-roam
 :after (citar org-roam)
 :custom
 (citar-org-roam-note-title-template "${title}")
 (citar-org-roam-capture-template-key "d") ;; Use the default org-roam capture template
 :config (citar-org-roam-mode))
(use-package citar
  :no-require
  :init
  (defun citar-open-entry-at-point ()
    "Open the citation entry at point in another window, reusing an existing window if possible."
    (interactive)
    (let ((key (citar-key-at-point)))
      (when key
        (let ((other-window (if (one-window-p)
                                (split-window-right)
                              (next-window))))
          (select-window other-window)
          (citar-open-entry key)))))

  :bind
  (("C-c o" . citar-open-entry-at-point))

  :custom
  (org-cite-global-bibliography '("~/projects/notes/references.bib"))
  (org-cite-insert-processor 'citar)
  (org-cite-follow-processor 'citar) ;; citar-open-entry will open bibtex
  (org-cite-activate-processor 'citar)
  (citar-bibliography org-cite-global-bibliography)

  :custom
  (add-hook 'org-roam-mode-hook
            (lambda ()
              (setq citar-notes-paths (list org-roam-directory))))
  )

My config shows the workaround, where I have C-c o bound to the function I made called citar-open-entry-at-point, which lets me open up the bibtex entry. I would be nice though if the bibtex entry were in that menu in the screenshot instead, so that I could click there to get to the entry and just do everything with C-c C-o and it's all in that one menu in the screenshot.

My workaround solves the issue with [cite:@foo] style links, but it also solves another use case as well. Which is to be able to click the citation(s) in :ROAM_REFS:, which is :ROAM_REFS: @minikanren in the screenshot, and then it takes me right to the citation entry.

I thought it was very likely that there's probably already a way to do these things, given how common it is to want to get to the bibliography entry, but I couldn't find anything in these and other (org, org-cite, org-roam) docs.

Embark did work for the [cite:@foo] type references in an org file, but it doesn't work for getting to the citation entry in :ROAM_REFS:, and it also has a bunch of extra commands in there that make it easy to accidentally press the wrong thing which slows down workflow. And then another downside to embark is that it's a second type of menu that increase the cognitive load vs just everything being in one menu.

@bdarcus
Copy link
Contributor

bdarcus commented Jun 14, 2024 via email

@Risto-Stevcev
Copy link
Author

Embark did work for the [cite:@foo] type references in an org file, but it doesn't work for getting to the citation entry in :ROAM_REFS:, and it also has a bunch of extra commands in there that make it easy to accidentally press the wrong thing which slows down workflow. And then another downside to embark is that it's a second type of menu that increase the cognitive load vs just everything being in one menu.

@bdarcus
Copy link
Contributor

bdarcus commented Jun 18, 2024

Am back with access to a computer.

Embark did work for the [cite:@foo] type references in an org file, but it doesn't work for getting to the citation entry in :ROAM_REFS: ...

Both work for me as expected. This is the menu embark presents after running embark-act on the reference (you can see where point is on the left buffer).

image

That config is here.

So there may be something wrong with your config here, though I've not yet looked at that.

And then another downside to embark is that it's a second type of menu that increase the cognitive load vs just everything being in one menu.

Well, this is all a matter of opinion, and the design of citar and related packages like embark aim for flexibility and configurability.

Here's an example of using a hydra or transient menu alterative at point, but it has its own limitations, which you can feel free to play with if you like.

https://gist.github.com/bdarcus/09dff264a75ae78330d8ee1a1ee5e1b2

But I still don't really understand what you're asking for.

If you use citar-embark, embark provides the contextual actions and menus in the minibuffer and at point. And you have room to configure that via embark.

citar-open is just an interactive command that uses completing-read and the minibuffer to provide a UI.

I suppose there's a reasonable argument to be made that opening the source entry should be an option in citar-open, but we've so far resisted that view.

@Risto-Stevcev
Copy link
Author

I'm probably not explaining it well, I did manage to get embark to work, but I'd ideally like to keep it all in that one menu that's in the screenshot I uploaded. I saw that citar-org-roam extends that menu like so:

citar-org-roam

I understand that embark is supposed to fulfill the role I'm asking about, but is there a way to programmatically extend that bottom menu like citar-org-roam does? I want to add a section for bibtex so it's all there.

@bdarcus
Copy link
Contributor

bdarcus commented Jun 18, 2024

... is there a way to programmatically extend that bottom menu like citar-org-roam does? I want to add a section for bibtex so it's all there.

You're asking for the last thing I mentioned in my latest reply: either to add the entry to citar-open, or to make it all configurable.

The notes section in that command menu alone is configurable. But beyond that, it's fixed.

So the title of this issue should really be something like "Make citar-open more configurable"?

Am not sure even how that might work. In the notes case, we have an API that notes sources code according to.

EDIT: I've changed the description accordingly, but will need to think about this, and I'm not sure when that might happen. In the meantime, If anyone else has input, feel free to add it.

I will say you can always write your own shadow command, borrowing that code as a starting point. And if you come up with an elegant solution, can always submit a PR.

@bdarcus bdarcus changed the title Go to bibliography entry in menu Make citar-open more configurable Jun 18, 2024
@Risto-Stevcev
Copy link
Author

Yeah, I guess the real question is how to make it more configurable. I didn't ask that initially because I thought that maybe I was using the library wrong. I guess I could copy whatever citar-org-roam is doing to add those new sections in the menu for my use case.

@bdarcus
Copy link
Contributor

bdarcus commented Jun 18, 2024

I guess I could copy whatever citar-org-roam is doing to add those new sections in the menu for my use case.

Actually no. Citar-org-roam is just providing a configuration that bundles some functions that citar calls.

You'd want to look at citar-open.

Other thing I forgot to mention: I encourage people to use the wiki to document custom config solution, as a possible interim bridge between user config and upstream code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants