From: Gustavo Barros <firstname.lastname@example.org> To: email@example.com Subject: [FR] Generalize org-reftex-citation Date: Thu, 24 Dec 2020 16:01:44 -0300 [thread overview] Message-ID: <firstname.lastname@example.org> (raw) Hi All, It's been some time since included in my todos to cook something to insert citations in Org using RefTeX's infrastructure. As I set this morning to do so, I found out it already existed: `org-reftex-citation'. Alas, it is not enough for me (and certainly also others), because it uses a simple regexp search for "#+BIBLIOGRAPHY:", thus only being able to find the .bib file with that specific form of declaration. In particular, it does not support biblatex (as far as I can tell). Before I found out the function existed, I had a general idea of letting RefTeX work in the exported .tex file. It turns out it is easy to adapt `org-reftex-citation' to do precisely that. And in so doing, being thus able to do anything RefTeX is able to support in its native environment, on top of anything Org is able to export. The only disadvantage I see, and which I consider minor, is that the .tex file has to exist. My take on this neat little idea so far is: #+begin_src emacs-lisp (defvar gb/org--rds nil) (defun gb/org-reftex-citation () "Use `reftex-citation' to insert a citation into the buffer. The bibliography sources for the base Org file are found by RefTeX itself parsing the corresponding exported \".tex\" file, which is required to exist. Those are passed to `reftex-citation' to insert a citation into the base Org buffer." (interactive) (unless (derived-mode-p 'org-mode) (user-error "Not an Org buffer")) (let ((tex-file (org-export-output-file-name ".tex"))) (if (file-readable-p tex-file) (find-file-noselect tex-file) (user-error "TeX file not available, export first to %S" tex-file)) (let ((reftex-docstruct-symbol 'gb/org--rds) gb/org--rds) (with-current-buffer (get-file-buffer tex-file) (reftex-access-scan-info nil) (setq gb/org--rds (symbol-value reftex-docstruct-symbol))) (call-interactively 'reftex-citation)))) #+end_src Still lightly tested, but looks good with what I tried out. So, I thought it was a good idea to send this to the list as suggestion / feature request. Best regards, Gustavo.
reply other threads:[~2020-12-24 19:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: [FR] Generalize org-reftex-citation' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).