From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Citation syntax: a revised proposal Date: Mon, 02 Mar 2015 21:53:20 +0100 Message-ID: <877fuzruin.fsf@gmx.us> References: <87k2zjnc0e.fsf@berkeley.edu> <87bnkvm8la.fsf@berkeley.edu> <87zj8co3se.fsf@berkeley.edu> <87ioezooi2.fsf@berkeley.edu> <87mw4bpaiu.fsf@nicolasgoaziou.fr> <8761aznpiq.fsf@berkeley.edu> <87twyjnh0r.fsf@nicolasgoaziou.fr> <87oaopx24e.fsf@berkeley.edu> <87k2zd4f3w.fsf@nicolasgoaziou.fr> <87egpkv8g9.fsf@berkeley.edu> <877fv6xfaq.fsf@gmail.com> <87twya2ak0.fsf@berkeley.edu> <87zj81aa97.fsf@nicolasgoaziou.fr> <87ioep2r6p.fsf@berkeley.edu> <87y4ngbgm7.fsf@nicolasgoaziou.fr> <87bnkbi61v.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSXLO-0000u9-Du for emacs-orgmode@gnu.org; Mon, 02 Mar 2015 15:53:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSXLK-0008Si-Aq for emacs-orgmode@gnu.org; Mon, 02 Mar 2015 15:53:38 -0500 Received: from plane.gmane.org ([80.91.229.3]:53244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSXLJ-0008SR-VP for emacs-orgmode@gnu.org; Mon, 02 Mar 2015 15:53:34 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YSXLI-00017k-E3 for emacs-orgmode@gnu.org; Mon, 02 Mar 2015 21:53:32 +0100 Received: from 46.166.188.200 ([46.166.188.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 02 Mar 2015 21:53:32 +0100 Received: from rasmus by 46.166.188.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 02 Mar 2015 21:53:32 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Looks cool Aaron. Thanks! Aaron Ecay writes: > The first issue is that the parser includes trailing punctuation in > “bare” @key citations. So the following does not work as expected (the > :key includes the period): “This was demonstrated most recently by > @Smith2015.” I’m not sure what the right approach is – one option > would be to say that keys can contain punctuation, but must end (and > begin) with an alphanumeric character. I also tried to solve this in the attached patch. Feel free to use it in the unlikely case that it adds anything to your fix (I didn't check). Note, cf. my other recent post, this should probably be part of a citations object rather than a citation object (assuming you take my idea at good value). > The second issue is that the :key property of the citation element > includes the @. This is not right IMO: it’s a detail of the syntax. > And it means that consumers of the syntax, who might want to look up > the key in a database, will always have to remember to strip the @. > I’ve pushed a provisional fix for this in my branch. I agree that the @ should not be part of the key. > Citation modes are responsible for formatting the in-text citation > (usually, a reference to a full citation stored elsewhere). [...] > Citation styles are responsible for formatting the citation in the > bibliography [...] Cool! > -> How much is it worth trying to keep latex and the other backends > together. A lot! In the sense that you get approximately the same output across backends when using support citation commands. When you are using citepos or similar you are on your own, but a highlevel API would be nice. > The current implementation uses some common functions (in ox-cite.el) > for all backends, including latex. However, latex basically does its > own thing. So it would be possible to include in ox-cite only code for > non-latex backends, and then implement latex citations solely in > ox-latex. Separation would make the initial implementation very > simple. On the other hand, I worry that it would perpetuate the present > situation where latex and non-latex citations are two separate > universes. On the third hand, serious latex users will probably just > say you should use latex of you want nice citations, since latex is so > much better. ;) I use LaTeX and in a recent funding request .doc (no x) was *mandatory*! I'm told that some journals only accept word... > -> How much of the non-latex citation code is it worth implementing in > elisp. As little as possible, though a highlevel API is nice, e.g. being able to make a citepos using (concat (citeauthor cite) "'s" (citeyear cite)). > Is it worth trying to put together a bare-bones elisp implementation, > so people can have dependency-free bibliographies? My inclination is to > say “no,” +1 (so "2 × no"). > to avoid duplicating the considerable effort put into the CSL > universe (over 7,000 citation styles available!). However, it also > seems a bit wrong to have a core feature depend on a third party > executable. Afaik, we need latexml or mathtoweb.jar to turn math into mathml for odt. > (How much it would slow down export to continually shell out to an > external program is also an open question.) Does it matter with async? > I didn’t try to do anything about support for editing/inserting citations > within org mode. It would be good to know whether John Kitchin is willing > to contribute bits of his org-ref code for that. (I see on Worg that he > has an FSF assignment on file, but I don’t want to take without asking – > or do porting/integration work that he’s happy to do himself!) I haven't tried org-ref, but isn't it just reftex? If so something like this (add-to-list 'reftex-cite-format-builtin '(org "Org-mode citation" ((?t . "[cite:%l]") (?p . "[parencite:%l]")))) Should work. We'd automatically add subtypes and maybe make an intelligent choice based on whether prefix and postfix is used. Another idea would be to use the ox-export dispatcher code, somehow... > PS the code uses relatively new functions from the subr-x and let-alist > libraries, so it probably works best on a recent-ish (past few months) > trunk version of emacs. In another post, Nicolas said we can target (at least?) 24.4 for v8.4. I'm assuming citation won't make 8.3... —Rasmus -- Send from my Emacs --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-element.el-Add-subkeys-to-citation-objects.patch >From 60e7b587ccda20e63fe0d90ce27315831be27d76 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Mon, 2 Mar 2015 18:18:02 +0100 Subject: [PATCH] org-element.el: Add subkeys to citation objects * org-element.el (org-element--set-regexps), (org-element-citation-parser), (org-element-citation-interpreter): Add citation subtypes. --- lisp/org-element.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index b341cef..7745558 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -197,8 +197,8 @@ specially in `org-element--object-lex'.") (format "\\[\\(?:%s\\)" (mapconcat #'identity - (list "cite:" - "(cite):" + (list "cite\\(?:/\\([A-Za-z_-]+\\)\\)?:" + "(cite\\(?:/\\([A-Za-z_-]+\\)\\)?):" "@[_A-Za-z][A-Za-z0-9:.#$%&-+?<>~/]*\\]" "fn:" "\\(?:[0-9]\\|\\(?:%\\|/[0-9]*\\)\\]\\)" @@ -408,7 +408,7 @@ This alist also applies to secondary string. For example, an still has an entry since one of its properties (`:title') does.") (defconst org-element-secondary-value-alist - '((citation :prefix :suffix) + '((citation :prefix :suffix :subtype) (headline :title) (inlinetask :title) (item :tag)) @@ -2721,7 +2721,8 @@ Assume point is at the beginning of the citation." (t (let ((begin (point)) (before-end (with-syntax-table org-element--pair-square-table - (ignore-errors (scan-lists (point) 1 0))))) + (ignore-errors (scan-lists (point) 1 0)))) + (subtype (org-match-string-no-properties 1))) (save-excursion (search-forward ":") ;; Ignore blanks between cite type and prefix or key. @@ -2741,6 +2742,9 @@ Assume point is at the beginning of the citation." :post-blank (progn (goto-char before-end) (skip-chars-forward " \t")) :end (point))))) + (when subtype + (org-element-put-property + cite :subkey subkey)) (when (< post-tag (match-beginning 0)) (org-element-put-property cite :prefix @@ -2765,7 +2769,12 @@ Assume point is at the beginning of the citation." "Interpret CITATION object as Org syntax. CONTENTS is nil." (concat "[" - (if (org-element-property :parentheticalp citation) "(cite):" "cite:") + (format + (if (org-element-property :parentheticalp citation) + "(%s%s):" "%s%s:") + "cite" + (let ((subtype (org-element-property :subtype citation))) + (if subtype (concat "/" subtype) ""))) (org-element-interpret-data (org-element-property :prefix citation)) (org-element-property :key citation) (org-element-interpret-data (org-element-property :suffix citation)) -- 2.3.1 --=-=-=--