Giter VIP home page Giter VIP logo

Comments (4)

zaeph avatar zaeph commented on August 17, 2024

We're using Org-roam's org-roam--title-to-slug to generate the name of the files:
https://github.com/zaeph/org-roam-bibtex/blob/6bbdebb39d7edf9b369c16311afa18cf00cecffc/org-roam-bibtex.el#L493

I think this is safe to drop this, but I'm going to run some tests first.

from org-roam-bibtex.

myshevchuk avatar myshevchuk commented on August 17, 2024

@tmalsburg Just don't use ${slug} in :file-name

  1. You can use the citekey directly like this:
(setq org-roam-bibtex-preformat-templates t
      org-roam-bibtex-preformat-keywords '(("citekey" . "=key="))
      org-roam-bibtex-templates
                '(("r" "ref" plain #'org-roam-capture--get-point
                   "%?"
                   :file-name "references/${citekey}"
                   :head "#+TITLE: ${title}\n#+ROAM_KEY: ${ref}\n"
                   :unnarrowed t)))
  1. Above, the difference between "citekey" and "ref" is that the latter is a kind of hardcoded internal and will be formatted according to the format specified in org-roam-bibtex-citekey-format (cite:%s by default, if it's nil then "ref" is the citekey). So the following will also work yielding the identical result:
(setq org-roam-bibtex-preformat-templates nil
      org-roam-bibtex-citekey-format nil
      org-roam-bibtex-preformat-keywords nil
      org-roam-bibtex-templates
                '(("r" "ref" plain #'org-roam-capture--get-point
                   "%?"
                   :file-name "references/${ref}"
                   :head "#+TITLE: ${title}\n#+ROAM_KEY: cite:${ref}\n"
                   :unnarrowed t)))
  1. Alternatively, the same result can be achieved with org-roam-capture-templates (to use these one must set org-roam-bibtex-templates to nil, however).
(setq org-roam-capture-templates 
        '(("r" "reference" plain (function org-roam-capture--get-point)
           "%?"
           :file-name "references/${citekey}"
           :head "#+TITLE: ${title}\n#+ROAM_KEY: cite:${citekey}\n"
           :unnarrowed t)))
  1. Note that extra things in :head can be moved into the template string (5th element of the list). For preformatting to take place one has to use Org-capture's %^{...} syntax instead of ${...} used in :file-name and :head, which are Org-roam's add-ons to Org-capture.
(setq org-roam-capture-templates 
        '(("r" "reference" plain (function org-roam-capture--get-point)
           "#+ROAM_KEY: cite:%^{citekey}\n%?"
           :file-name "references/${citekey}"
           :head "#+TITLE: ${title}\n"
           :unnarrowed t)))
  1. Pay attention that in order to use custom bibtex-aware wildcards in the templates, make sure org-roam-bibtex-preformat-templates is t and the bibtex key field is set for preformatting:
(setq org-roam-bibtex-preformat-keywords "=key=")
(setq ... templates ...
...  :file-name "${=key=}" ...

or

(setq org-roam-bibtex-preformat-keywords '(("myverybestcitekey" . "=key=")))
(setq ... templates ...
...  :file-name "${myverybestcitekey}" ...

By the way, this works with any bibtex field as retrieved by bibtex-completion-apa-get-value. As far as I'm aware, only "citekey" and "type" fields have special names, =key= and =type=, respectively. All other field names are the same as found in a bib file. So one can put anything or even everything from a bibtex record into the notes file and the file name itself!

With this setup Bibtex-completion has worked out of the box from the very beginning 😉

from org-roam-bibtex.

zaeph avatar zaeph commented on August 17, 2024

Thanks for double-checking this, @myshevchuk!
I'm not sure if we should make (setq org-roam-bibtex-preformat-keywords '(("citekey" . "=key=")) anvec :file-name "${citekey}" the defaults, though. As it is right now, it prevents special characters from screwing up with the file-creation.

from org-roam-bibtex.

myshevchuk avatar myshevchuk commented on August 17, 2024

@zaeph Yes, a similar thought appeared to me. Could you please make a separate issue for this. I'd opt for the defaults you are suggesting. As of now, org-roam-capture-templates and org-roam-bibtex-templates provide basically the same functionality and interface. We could tune org-roam-bibtex-templates to be more user friendly with some additional work under the hood.

from org-roam-bibtex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.