summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchim Gratz <Stromeko@Stromeko.DE>2013-06-23 10:21:10 +0200
committerAchim Gratz <Stromeko@Stromeko.DE>2013-06-23 19:35:09 +0200
commit68276fd62d7c6663641d9f2f028e80823dab2eff (patch)
tree2d16eaf9612940703034d7e9f1d64ec18fdc7fc0
parent56ac8f8b6951379e323ee724d79f95f97ae2c8a1 (diff)
downloadorg-mode-68276fd62d7c6663641d9f2f028e80823dab2eff.tar.gz
org.el: implement org-property-re using org-re-property
* lisp/org.el (org-re-property): Re-implement using full regex for `org-re-property'. Add optional argument LITERAL to flag when PROPERTY should to be regex-quoted. Move before definition of `org-re-property'. (org-re-property-keyword): Remove, functionality is subsumed by `org-re-property'. (org-property-re): Define using `org-re-property'. (org-entry-get, org-property-values): Adjust match number for PROPVAL. (org-entry-put): Use `org-re-property' instead of `org-re-property-keyword' This completes the refactoring started in 3c933adaf6.
-rw-r--r--lisp/org.el27
1 files changed, 12 insertions, 15 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 97773a0..237855d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6122,8 +6122,15 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
(defvar org-font-lock-keywords nil)
+(defsubst org-re-property (property &optional literal)
+ "Return a regexp matching a PROPERTY line.
+Match group 3 will be set to the value if it exists."
+ (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
+ (if literal property (regexp-quote property))
+ "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
+
(defconst org-property-re
- "^\\(?4:[ \t]*\\)\\(?1::\\(?2:.*?\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"
+ (org-re-property ".*?" 'literal)
"Regular expression matching a property line.
There are four matching groups:
1: :PROPKEY: including the leading and trailing colon,
@@ -15022,16 +15029,6 @@ Being in this list makes sure that they are offered for completion.")
org-property-end-re "\\)\n?")
"Matches an entire clock drawer.")
-(defsubst org-re-property (property)
- "Return a regexp matching a PROPERTY line.
-Match group 1 will be set to the value."
- (concat "^[ \t]*:" (regexp-quote property) ":[ \t]*\\(\\S-.*\\)"))
-
-(defsubst org-re-property-keyword (property)
- "Return a regexp matching a PROPERTY line, possibly with no
-value for the property."
- (concat "^[ \t]*:" (regexp-quote property) ":[ \t]*\\(\\S-.*\\)?"))
-
(defun org-property-action ()
"Do an action on properties."
(interactive)
@@ -15291,8 +15288,8 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
(setq props
(org-update-property-plist
key
- (if (match-end 1)
- (org-match-string-no-properties 1) "")
+ (if (match-end 3)
+ (org-match-string-no-properties 3) "")
props)))))
val)
(goto-char (car range))
@@ -15481,7 +15478,7 @@ and the new value.")
(setq range (org-get-property-block beg end 'force))
(goto-char (car range))
(if (re-search-forward
- (org-re-property-keyword property) (cdr range) t)
+ (org-re-property property) (cdr range) t)
(progn
(delete-region (match-beginning 0) (match-end 0))
(goto-char (match-beginning 0)))
@@ -15551,7 +15548,7 @@ formats in the current buffer."
(let ((re (org-re-property key))
values)
(while (re-search-forward re nil t)
- (add-to-list 'values (org-trim (match-string 1))))
+ (add-to-list 'values (org-trim (match-string 3))))
(delete "" values)))))
(defun org-insert-property-drawer ()