Browse Source

org-element: Fix affiliated keyword regexp

* lisp/org-element.el (org-element--affiliated-re): Fix affiliated
  keyword regexp.
Nicolas Goaziou 12 years ago
parent
commit
f1b9339aa5
1 changed files with 25 additions and 13 deletions
  1. 25 13
      lisp/org-element.el

+ 25 - 13
lisp/org-element.el

@@ -239,19 +239,6 @@ application to open them.")
 By default, all keywords setting attributes (i.e. \"ATTR_LATEX\")
 By default, all keywords setting attributes (i.e. \"ATTR_LATEX\")
 are affiliated keywords and need not to be in this list.")
 are affiliated keywords and need not to be in this list.")
 
 
-(defconst org-element--affiliated-re
-  (format "[ \t]*#\\+%s:"
-	  ;; Regular affiliated keywords.
-	  (format "\\(%s\\|ATTR_[-_A-Za-z0-9]+\\)\\(?:\\[\\(.*\\)\\]\\)?"
-		  (regexp-opt org-element-affiliated-keywords)))
-  "Regexp matching any affiliated keyword.
-
-Keyword name is put in match group 1.  Moreover, if keyword
-belongs to `org-element-dual-keywords', put the dual value in
-match group 2.
-
-Don't modify it, set `org-element-affiliated-keywords' instead.")
-
 (defconst org-element-keyword-translation-alist
 (defconst org-element-keyword-translation-alist
   '(("DATA" . "NAME")  ("LABEL" . "NAME") ("RESNAME" . "NAME")
   '(("DATA" . "NAME")  ("LABEL" . "NAME") ("RESNAME" . "NAME")
     ("SOURCE" . "NAME") ("SRCNAME" . "NAME") ("TBLNAME" . "NAME")
     ("SOURCE" . "NAME") ("SRCNAME" . "NAME") ("TBLNAME" . "NAME")
@@ -298,6 +285,31 @@ This list is checked after translations have been applied.  See
 Any keyword in this list will have its value parsed and stored as
 Any keyword in this list will have its value parsed and stored as
 a secondary string.")
 a secondary string.")
 
 
+(defconst org-element--affiliated-re
+  (format "[ \t]*#\\+\\(?:%s\\):\\(?: \\|$\\)"
+	  (concat
+	   ;; Dual affiliated keywords.
+	   (format "\\(?1:%s\\)\\(?:\\[\\(.*\\)\\]\\)?"
+		   (regexp-opt org-element-dual-keywords))
+	   "\\|"
+	   ;; Regular affiliated keywords.
+	   (format "\\(?1:%s\\)"
+		   (regexp-opt
+		    (org-remove-if
+		     #'(lambda (keyword)
+			 (member keyword org-element-dual-keywords))
+		     org-element-affiliated-keywords)))
+	   "\\|"
+	   ;; Export attributes.
+	   "\\(?1:ATTR_[-_A-Za-z0-9]+\\)"))
+  "Regexp matching any affiliated keyword.
+
+Keyword name is put in match group 1.  Moreover, if keyword
+belongs to `org-element-dual-keywords', put the dual value in
+match group 2.
+
+Don't modify it, set `org-element-affiliated-keywords' instead.")
+
 (defconst org-element-object-restrictions
 (defconst org-element-object-restrictions
   (let* ((standard-set
   (let* ((standard-set
 	  (remq 'plain-link (remq 'table-cell org-element-all-successors)))
 	  (remq 'plain-link (remq 'table-cell org-element-all-successors)))