0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-06 01:42:58 +00:00

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.
This commit is contained in:
Achim Gratz 2013-06-23 10:21:10 +02:00
parent 56ac8f8b69
commit 68276fd62d

View file

@ -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 ()