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

(int) Bibtex-actions support #212

Merged
merged 2 commits into from
Sep 15, 2021
Merged

(int) Bibtex-actions support #212

merged 2 commits into from
Sep 15, 2021

Conversation

myshevchuk
Copy link
Member

orb-edit-notes can accept a list of strings or a list of lists whose
element lists start with strings.

See #211.

@bdarcus On another thought I decided to not modify orb-edit-note. By design, it accepts a single argument, a citation key as string, and should probably stay as such. It would anyway require additional destructuring because plain (defun orb-edit-note (citekey &optional entry) would not work because (KEY . ENTRY) is still a single argument.

I instead modified the function orb-edit-notes, which is meant to be plugged in into bibtex-completion-edit-notes-function or bibtex-actions-file-open-note-function. This function used to accept a list of keys as returned by bibtex-comletion. Now it also accepts a list of lists to support bibtex-actions. Note the function still does not support "multi-editing". That is if more than one entry is selected, it will proceed only with the first entry.

Please check if this works for you and I'll merge it.

`orb-edit-notes` can accept a list of strings or a list of lists whose
element lists start with strings.

See #211.
@bdarcus
Copy link

bdarcus commented Sep 14, 2021

@bdarcus On another thought I decided to not modify orb-edit-note. By design, it accepts a single argument, a citation key as string, and should probably stay as such. It would anyway require additional destructuring because plain (defun orb-edit-note (citekey &optional entry) would not work because (KEY . ENTRY) is still a single argument.

Just to clarify, this last point wouldn't be a problem actually.

It's true bibtex-actions-select-refs returns (KEY . ENTRY) now, but my intention was for the interactive notes function that uses it (bibtex-actions-open-notes) to pass them as separate arguments; e.g:

  (funcall bibtex-actions-file-open-note-function key entry)))

.. since the first arg is just the car, and the second the cdr.

E.g. I'd change that part of the function like so:

  (dolist (key-entry keys-entries)
    (funcall bibtex-actions-file-open-note-function (car key-entry) (cdr key-entry)))

Given that, why not just modify orb-edit-note instead?

- New function `orb-bibtex-actions-edit-note` for use with Bibtex-actions
- Rename `orb-edit-notes` to `orb-bibtex-completion-edit-note`
- Adjust `org-roam-bibtex-mode` accordingly
- Minor refactoring
@myshevchuk
Copy link
Member Author

Given that, why not just modify orb-edit-note instead

I would do that if the entry could seamlessly be propagated to orb--new-note, which actually does the job of fetching an entry and initiating org-roam-capture. Unfortunately, orb--new-note already takes another optional variable props for internal use, and I don't want to mess around it for I don't have much time right now. Defining the more or less central function orb-edit-note with a dangling argument doesn't look good to me either.

In principle, I like the idea of the completion system supplying the BibTeX information to orb-edit-note, so that orb--new-note wouldn't have to look it up. That's a more flexible solution too, since one could construct BibTeX entry programmatically and use orb-edit-note outside the scope of a completion system. As of now however, Bibtex-actions uses Bibtex-completion bibliography anyway, so that doesn't make a big difference.

As a current solution, I created a new function orb-bibtex-actions-edit-note, which does what you've requested. Furthermore, org-roam-bibtex-mode automatically sets bibtex-actions-file-open-note-function to orb-bibtex-actions-edit-note, so the user does not have to do that in their config.

Would this work for you?

@bdarcus
Copy link

bdarcus commented Sep 15, 2021

In principle, I like the idea of the completion system supplying the BibTeX information to orb-edit-note, so that orb--new-note wouldn't have to look it up. That's a more flexible solution too, since one could construct BibTeX entry programmatically and use orb-edit-note outside the scope of a completion system.

Right.

As of now however, Bibtex-actions uses Bibtex-completion bibliography anyway, so that doesn't make a big difference.

Yes, I see that.

As a current solution, I created a new function orb-bibtex-actions-edit-note, which does what you've requested. Furthermore, org-roam-bibtex-mode automatically sets bibtex-actions-file-open-note-function to orb-bibtex-actions-edit-note, so the user does not have to do that in their config.

Would this work for you?

Yes, I think so. Thanks!

@myshevchuk myshevchuk changed the title (int) support rich arguments for orb-edit-notes (int) Bibtex-actions support Sep 15, 2021
@myshevchuk myshevchuk merged commit 2c15e43 into master Sep 15, 2021
@myshevchuk
Copy link
Member Author

Great, I'm merging the changes then.

@bdarcus
Copy link

bdarcus commented Sep 15, 2021

I started the change here:

emacs-citar/citar#289

Will finish (mainly adding documentation) later today.

bdarcus added a commit to emacs-citar/citar that referenced this pull request Sep 15, 2021
@myshevchuk myshevchuk deleted the orb-edit-notes branch September 28, 2021 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants