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