summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-22 13:28:02 (GMT)
committer Nicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-22 13:28:02 (GMT)
commit12a23d6c61ce04695e8d967e96843f94823df78b (patch)
treedcc792c1823951c9913fa889c5c7eaf96d9db371
parent7c3e0b0fdfdc0cf1a4724cffe17b6bb160278247 (diff)
downloadorg-mode-maint.zip
org-mode-maint.tar.gz
`org-entry-delete' can remove erroneous special propertiesmaint
* lisp/org.el (org-entry-delete): Also remove erroneously inserted special properties in properties drawer. Small refactoring. * testing/lisp/test-org.el (test-org/entry-delete): Add test. Reported-by: Michael Welle <mwe012008@gmx.net> <http://permalink.gmane.org/gmane.emacs.orgmode/111564>
-rw-r--r--lisp/org.el34
-rw-r--r--testing/lisp/test-org.el7
2 files changed, 22 insertions, 19 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 9df4468..cf3a889 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16088,24 +16088,22 @@ If yes, return this value. If not, return the current value of the variable."
"Delete PROPERTY from entry at point-or-marker POM.
Accumulated properties, i.e. PROPERTY+, are also removed. Return
non-nil when a property was removed."
- (unless (member property org-special-properties)
- (org-with-point-at pom
- (let ((range (org-get-property-block)))
- (when range
- (let* ((begin (car range))
- (origin (cdr range))
- (end (copy-marker origin))
- (re (org-re-property
- (concat (regexp-quote property) "\\+?") t t)))
- (goto-char begin)
- (while (re-search-forward re end t)
- (delete-region (match-beginning 0) (line-beginning-position 2)))
- ;; If drawer is empty, remove it altogether.
- (when (= begin end)
- (delete-region (line-beginning-position 0)
- (line-beginning-position 2)))
- ;; Return non-nil if some property was removed.
- (prog1 (/= end origin) (set-marker end nil))))))))
+ (org-with-point-at pom
+ (pcase (org-get-property-block)
+ (`(,begin . ,origin)
+ (let* ((end (copy-marker origin))
+ (re (org-re-property
+ (concat (regexp-quote property) "\\+?") t t)))
+ (goto-char begin)
+ (while (re-search-forward re end t)
+ (delete-region (match-beginning 0) (line-beginning-position 2)))
+ ;; If drawer is empty, remove it altogether.
+ (when (= begin end)
+ (delete-region (line-beginning-position 0)
+ (line-beginning-position 2)))
+ ;; Return non-nil if some property was removed.
+ (prog1 (/= end origin) (set-marker end nil))))
+ (_ nil))))
;; Multi-values properties are properties that contain multiple values
;; These values are assumed to be single words, separated by whitespace.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 4d299a9..32cd441 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -4143,7 +4143,12 @@ Paragraph<point>"
(org-entry-delete (point) "A")))
(should-not
(org-test-with-temp-text "* H\n:PROPERTIES:\n:A: 1\n:B: 2\n:END:"
- (org-entry-delete (point) "C"))))
+ (org-entry-delete (point) "C")))
+ ;; Special properties cannot be located in a drawer. Allow to
+ ;; remove them anyway, in case of user error.
+ (should
+ (org-test-with-temp-text "* H\n:PROPERTIES:\n:SCHEDULED: 1\n:END:"
+ (org-entry-delete (point) "SCHEDULED"))))
(ert-deftest test-org/entry-get ()
"Test `org-entry-get' specifications."