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

Use capture to create an entry in the default bib file #167

Open
oatmealm opened this issue Aug 5, 2020 · 8 comments
Open

Use capture to create an entry in the default bib file #167

oatmealm opened this issue Aug 5, 2020 · 8 comments

Comments

@oatmealm
Copy link

oatmealm commented Aug 5, 2020

Is this possible? I'd like for instance to use Emacs' capture mechanism to save a reference from an extension in Firefox à la zotero connector.

@joostkremers
Copy link
Owner

By "Emacs' capture mechanism" do you mean Org-mode's capture mechanism? Or do you have something else in mind?

@oatmealm
Copy link
Author

Yes. Sorry for that, meant org's. I've seen the "paste" function onto the list buffer, which is really nice, thought it's not always available to copy. On second thought, need to think how to make a capture process better in cases where the ref is not provided with a bibtex cite I can copy...

@joostkremers
Copy link
Owner

Well, the Org capture stuff creates an Org-formatted entry, so I'm not sure it can be (ab)used to create .bib entries.

If yanking (pasting) the reference into the index buffer isn't working properly, it's also possible to yank the entry into the *scratch* buffer (or any other text buffer), clean it up manually and then use ebib-import to import the entry into the current database.

If there's no preformatted entry, however, there's little Ebib can do, I'm afraid.

Of course, if you come up with any ideas to improve the process, feel free to suggest them.

@oatmealm
Copy link
Author

Sorry, I forgot this...

While going through my setup and looking at what org-roam-bibtex does , I remembered that I was thinking that it'd be nice to be able to create annotation from an org-capture template, which I already have, rather than keep the template string in ebib's variable.

So when I hit N on an entry, I'd be offered a template for a new note, if one does not exist yet, and pre-populate it with maybe NOTER_DOCUMENT etc.

I'm aware that this already works when using 'ivy-bibtex' and 'org-ref' extended actions. Ie "C-o" from the main list of entries.

Just a thought.

@joostkremers joostkremers reopened this Sep 28, 2020
@joostkremers
Copy link
Owner

You seem to be talking about something else now than in your original message. Originally I thought you were talking about creating a BibTeX entry using Org's capture mechanism. Now you seem to be talking about creating an annotation (an external note, as Ebib calls it).

Using Org's capture mechanism to create an external note for an entry (i.e., when you press N) does make sense, though I'm not entirely sure if it would be possible to implement. It's possible to call org-capture from a Lisp program (such as Ebib) and tell it which template to use (so the user doesn't have to select one), but filling in things like the author, year and title are not straightforward because Org capture of course doesn't know about these.

Looking at ivy-bibtex, it seems that it has its own templates as well: bibtex-completion-notes-template-multiple-files and bibtex-completion-notes-template-one-file.

@oatmealm
Copy link
Author

oatmealm commented Sep 28, 2020

I might have seen this integration happening via 'org-roam-bibtex' ... the templates are used for either ivy-bibtex or org-ref if I'm not mistaken, and are injected with some additional information supplied by org-roam-bibtex (functions prefix is orb-*.

I'll look at the code again when I get a chance.

And yes, sorry. It is about using the same mechanism but for different purposes.

@oatmealm
Copy link
Author

oatmealm commented Sep 30, 2020

I have this setup, which seems to work for me as is. I have the template defined globaly in orb-templates and then I have `bibtex-completion use it like so:

(setq bibtex-completion-notes-template-multiple-files (plist-get (cdr (assoc "r" orb-templates)) :head))

org-ref is set like this, I'm assuming it's using bibtex-completion as well...

(setq org-ref-completion-library
      (cond ((featurep! :completion ivy)  #'org-ref-ivy-cite)
            ((featurep! :completion helm) #'org-ref-helm-bibtex)
            (t                            #'org-ref-reftex)))

Some of the functionality is provided by org-roam-bibtex, i.e. the macro %(orb-process-file-field) but I suspeting also the other keywords which extract values from the bibtex entries are processed by org-roam-bibtex in this case...? Not sure. It's a dizzying to be honest.

(setq orb-templates
          '(("r" "ref" plain (function org-roam-capture--get-point)
             ""
             :file-name "${slug}"
             :head "${title}
#+roam_key: cite:${=key=}
#+roam_tags: ${keywords}
\n* (${author-or-editor}) ${title}
:PROPERTIES:
:URL: ${url}
:NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")
:END:\n"
             :unnarrowed t)))

@joostkremers
Copy link
Owner

Perhaps you should also check out org-capture-ref. It sounds like it might be what you're after. Any BibTeX entry you create with it will be put in the .bib file, which you'd then have to reload in Ebib, but there's a command for that (bound to r).

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

No branches or pull requests

2 participants