summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2011-04-09 17:50:56 +0200
committerJulien Danjou <julien@danjou.info>2011-04-09 18:53:07 +0200
commit92b603c8920623d9c581e2c58809ad2c73fcd475 (patch)
tree31db5974fca8e8ffd39bc4cfc4be0c44e6fd66b0
parentc9c5da9191ad8ce564961c30cee5796665a96d50 (diff)
downloadorg-mode-92b603c8920623d9c581e2c58809ad2c73fcd475.tar.gz
org: clean property entries matching
* lisp/org.el (org-entry-get): (org-entry-delete): (org-entry-put): (org-property-values): (org-delete-property-globally): Use org-re-property. (org-re-property): New function allowing to build a regexp to match a property. Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r--lisp/org.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/org.el b/lisp/org.el
index edc355d..0e2114f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13694,7 +13694,7 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
(if (and range
(goto-char (car range))
(re-search-forward
- (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)?")
+ (org-re-property property)
(cdr range) t))
;; Found the property, return it.
(if (match-end 1)
@@ -13720,7 +13720,7 @@ If yes, return this value. If not, return the current value of the variable."
(if (and range
(goto-char (car range))
(re-search-forward
- (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)")
+ (org-re-property property)
(cdr range) t))
(progn
(delete-region (match-beginning 0) (1+ (point-at-eol)))
@@ -13867,7 +13867,7 @@ and the new value.")
(setq range (org-get-property-block beg end 'force))
(goto-char (car range))
(if (re-search-forward
- (concat "^[ \t]*:" property ":\\(.*\\)") (cdr range) t)
+ (org-re-property property) (cdr range) t)
(progn
(delete-region (match-beginning 1) (match-end 1))
(goto-char (match-beginning 1)))
@@ -13929,13 +13929,18 @@ formats in the current buffer."
(sort rtn (lambda (a b) (string< (upcase a) (upcase b))))))
+(defsubst org-re-property (property)
+ "Return a regexp matching PROPERTY.
+Match group 1 will be set to the value "
+ (concat "^[ \t]*:" (regexp-quote property) ":[ \t]*\\(\\S-.*\\)"))
+
(defun org-property-values (key)
"Return a list of all values of property KEY in the current buffer."
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
- (let ((re (concat "^[ \t]*:" key ":[ \t]*\\(\\S-.*\\)"))
+ (let ((re (org-re-property key))
values)
(while (re-search-forward re nil t)
(add-to-list 'values (org-trim (match-string 1))))
@@ -14068,7 +14073,7 @@ in the current file."
(goto-char (point-min))
(let ((cnt 0))
(while (re-search-forward
- (concat "^[ \t]*:" (regexp-quote property) ":.*\n?")
+ (org-re-property property)
nil t)
(setq cnt (1+ cnt))
(replace-match ""))