emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Citation syntax: a revised proposal
Date: Mon, 02 Mar 2015 21:53:20 +0100	[thread overview]
Message-ID: <877fuzruin.fsf@gmx.us> (raw)
In-Reply-To: 87bnkbi61v.fsf@gmail.com

[-- Attachment #1: Type: text/plain, Size: 4480 bytes --]

Looks cool Aaron.  Thanks!

Aaron Ecay <aaronecay@gmail.com> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element.el-Add-subkeys-to-citation-objects.patch --]
[-- Type: text/x-diff, Size: 2773 bytes --]

From 60e7b587ccda20e63fe0d90ce27315831be27d76 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
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


  parent reply	other threads:[~2015-03-02 20:53 UTC|newest]

Thread overview: 163+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-15  2:29 Citation syntax: a revised proposal Richard Lawrence
2015-02-15  2:45 ` Richard Lawrence
2015-02-15  3:57 ` Thomas S. Dye
2015-02-15 16:40   ` Richard Lawrence
2015-02-15 19:43     ` Thomas S. Dye
2015-02-16  3:34       ` Matt Price
2015-02-16  8:56         ` Nicolas Goaziou
2015-02-16  9:57         ` Rasmus
2015-02-17 17:18       ` Richard Lawrence
2015-02-17 18:11         ` Rasmus
2015-02-18  0:44           ` Matt Price
2015-02-18  3:38           ` Richard Lawrence
2015-02-18  2:24         ` Thomas S. Dye
2015-02-18  4:03           ` Richard Lawrence
2015-02-18  9:00             ` Stefan Nobis
2015-02-18 10:11             ` Eric S Fraga
2015-02-18 14:19             ` Nicolas Goaziou
2015-02-18 16:38               ` Richard Lawrence
2015-02-18 18:44                 ` Samuel Wales
2015-02-18 18:46                   ` Samuel Wales
2015-02-18 20:54                   ` Aaron Ecay
2015-02-18 21:21                     ` Samuel Wales
2015-02-18 21:24                     ` John Kitchin
2015-02-18 19:42                 ` Nicolas Goaziou
2015-02-18 20:47                   ` Aaron Ecay
2015-02-18 22:43                     ` Rasmus
2015-02-18 22:35                   ` Rasmus
2015-02-19 17:06                   ` Richard Lawrence
2015-02-20  0:10                     ` Nicolas Goaziou
2015-02-20 16:44                       ` Richard Lawrence
2015-02-20 19:45                         ` Samuel Wales
2015-02-20 20:01                           ` Rasmus
2015-02-20 22:33                             ` Samuel Wales
2015-02-21 11:58                               ` Rasmus
2015-02-21 17:25                                 ` Thomas S. Dye
2015-02-27  0:56                                 ` Samuel Wales
2015-02-27  8:55                                   ` Stefan Nobis
2015-02-27  9:56                                   ` Rasmus
2015-02-21  3:12                           ` Richard Lawrence
2015-02-21 12:00                             ` Rasmus
2015-02-21 20:19                             ` Samuel Wales
2015-02-21 20:36                             ` Samuel Wales
2015-02-25 13:59                         ` Aaron Ecay
2015-02-25 16:57                           ` Richard Lawrence
2015-02-25 22:37                             ` Nicolas Goaziou
2015-02-26  5:10                               ` Richard Lawrence
2015-03-01 20:35                                 ` Nicolas Goaziou
2015-03-01 21:31                                   ` Rasmus
2015-03-02  0:24                                     ` Thomas S. Dye
2015-03-02  8:57                                       ` Eric S Fraga
2015-03-02  1:37                                     ` Thomas S. Dye
2015-03-02  9:23                                       ` Rasmus
2015-03-02 19:11                                     ` Aaron Ecay
2015-03-02 20:15                                       ` Rasmus
2015-03-03  3:14                                       ` Richard Lawrence
2015-03-03  5:33                                         ` Avram Lyon
2015-03-03 17:27                                           ` Richard Lawrence
2015-03-03 17:56                                             ` Avram Lyon
2015-03-04 16:41                                               ` Richard Lawrence
2015-03-03  9:24                                         ` Rasmus
2015-03-03  9:39                                           ` Rasmus
2015-03-03 14:12                                         ` Aaron Ecay
2015-03-02 18:50                                   ` Richard Lawrence
2015-03-02 20:14                                     ` Nicolas Goaziou
2015-03-02 20:34                                       ` Rasmus
2015-03-02 22:17                                         ` Nicolas Goaziou
2015-03-02 22:33                                           ` Rasmus
2015-03-02 22:45                                             ` Nicolas Goaziou
2015-03-02 23:05                                               ` Rasmus
2015-03-02 23:27                                                 ` Nicolas Goaziou
2015-03-02 23:42                                                   ` Rasmus
2015-03-03  2:48                                       ` Richard Lawrence
2015-03-03  8:43                                         ` Nicolas Goaziou
2015-03-03 16:59                                           ` Richard Lawrence
2015-03-04  0:43                                           ` Matt Price
2015-03-08  0:16                                         ` Nicolas Goaziou
2015-03-03 14:23                                     ` Aaron Ecay
2015-03-02 18:54                                   ` Aaron Ecay
2015-03-02 20:26                                     ` Nicolas Goaziou
2015-03-03  2:53                                       ` Richard Lawrence
2015-03-03  8:38                                         ` Nicolas Goaziou
2015-03-03  9:13                                           ` Rasmus
2015-03-03 16:12                                             ` Richard Lawrence
2015-03-03 14:25                                       ` Aaron Ecay
2015-03-02 20:53                                     ` Rasmus [this message]
2015-03-03 14:57                                       ` Aaron Ecay
2015-03-03 15:41                                         ` Rasmus
2015-03-03 15:58                                           ` Ken Mankoff
2015-03-03 16:08                                             ` Rasmus
2015-03-03 17:13                                         ` Richard Lawrence
2015-03-10  3:44                                     ` Aaron Ecay
2015-03-10  9:49                                       ` Rasmus
2015-03-11  1:51                                         ` Aaron Ecay
2015-03-11  6:04                                           ` Thomas S. Dye
2015-03-10 16:31                                       ` Richard Lawrence
2015-03-11  2:21                                         ` Aaron Ecay
2015-03-11 17:33                                           ` Richard Lawrence
2015-03-13 18:13                                             ` Richard Lawrence
2015-03-17  5:15                                               ` Richard Lawrence
2015-03-17  9:27                                                 ` Andreas Leha
2015-03-17 16:26                                                   ` Richard Lawrence
2015-03-17 20:42                                                     ` Andreas Leha
2015-03-17 21:34                                                       ` Richard Lawrence
2015-03-18  1:12                                                     ` Matt Price
2015-03-18 15:19                                                       ` Richard Lawrence
2015-02-25 18:08                           ` Thomas S. Dye
2015-02-26 21:30                             ` Aaron Ecay
2015-02-26 23:50                               ` Thomas S. Dye
2015-02-27  8:49                               ` Stefan Nobis
2015-02-27 16:35                                 ` Richard Lawrence
2015-02-27 10:09                               ` Rasmus
2015-03-02  5:48                               ` Thomas S. Dye
2015-03-02 12:22                                 ` Aaron Ecay
2015-03-02 13:53                                   ` Thomas S. Dye
2015-03-02 19:02                                     ` Aaron Ecay
2015-02-20  5:27                     ` Melanie Bacou
2015-02-20 16:49                       ` Richard Lawrence
2015-02-24  7:08         ` Vaidheeswaran C
2015-02-25  4:29           ` Richard Lawrence
2015-02-25  5:57             ` Vaidheeswaran C
2015-02-15 11:17 ` Tory S. Anderson
2015-02-15 11:57 ` Rasmus
2015-02-15 17:05   ` Richard Lawrence
2015-02-16  8:53     ` Stefan Nobis
2015-02-16 17:52       ` Thomas S. Dye
2015-02-15 17:23   ` Nicolas Goaziou
2015-03-09 10:40     ` Sebastien Vauban
2015-03-09 10:50       ` Vaidheeswaran C
2015-02-15 17:19 ` Nicolas Goaziou
2015-02-15 17:37   ` Rasmus
2015-02-15 17:55     ` Nicolas Goaziou
2015-02-15 19:30     ` John Kitchin
2015-02-15 18:07   ` Richard Lawrence
2015-02-15 18:25     ` Nicolas Goaziou
2015-02-15 19:05       ` Aaron Ecay
2015-02-15 19:18         ` Nicolas Goaziou
2015-02-15 19:38           ` Aaron Ecay
2015-02-15 20:13             ` Nicolas Goaziou
2015-02-15 20:23               ` Rasmus
2015-02-16  9:07               ` Stefan Nobis
2015-02-16 16:59               ` Richard Lawrence
2015-02-16 17:43                 ` Nicolas Goaziou
2015-02-16 18:39                   ` Rasmus
2015-02-16 19:16                     ` Thomas S. Dye
2015-02-16 19:40                       ` Rasmus
2015-02-15 20:49 ` John Kitchin
2015-02-16 16:18   ` Richard Lawrence
2015-02-16 18:21     ` John Kitchin
2015-02-16 12:05 ` Eric S Fraga
2015-02-16 13:10   ` William Denton
2015-02-16 13:42   ` John Kitchin
2015-02-16 16:19     ` Nicolas Goaziou
2015-02-16 17:28       ` John Kitchin
2015-02-16 18:49         ` Rasmus
2015-02-16 19:16           ` John Kitchin
2015-02-23  7:26       ` Vaidheeswaran
2015-02-16 16:35     ` Jorge A. Alfaro-Murillo
2015-02-16 17:56       ` Stefan Nobis
2015-02-16 18:24         ` John Kitchin
2015-02-16 18:39           ` Jorge A. Alfaro-Murillo
2015-02-16 19:19         ` Jorge A. Alfaro-Murillo
2015-02-17  6:47           ` Stefan Nobis
2015-02-16 16:45   ` Richard Lawrence

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 \
    --in-reply-to=877fuzruin.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).