summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-04-30 23:27:30 (GMT)
committer Nicolas Goaziou <mail@nicolasgoaziou.fr>2016-04-30 23:27:30 (GMT)
commitaf853dd3aa4ce42f8e860ed45ced7f922cb08091 (patch)
treedbf1ee870f0429ae80a669330458daf50eb66526
parentc8c2d2b1f715158a1f55a7eaf4797c78562b4402 (diff)
downloadorg-mode-maint.zip
org-mode-maint.tar.gz
Fix `org-flag-drawer' with optional argumentmaint
* lisp/org.el (org-flag-drawer): Do not require point to be at a drawer in order to call the function with an optional argument. * testing/lisp/test-org.el (test-org/flag-drawer): Narrow test.
-rw-r--r--lisp/org.el35
-rw-r--r--testing/lisp/test-org.el2
2 files changed, 19 insertions, 18 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 1d3e129..ba240fb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7226,23 +7226,24 @@ specifying which drawers should not be hidden."
Otherwise make it visible. When optional argument ELEMENT is
a parsed drawer, as returned by `org-element-at-point', hide or
show that drawer instead."
- (when (save-excursion
- (beginning-of-line)
- (org-looking-at-p org-drawer-regexp))
- (let ((drawer (or element (org-element-at-point))))
- (when (memq (org-element-type drawer) '(drawer property-drawer))
- (let ((post (org-element-property :post-affiliated drawer)))
- (save-excursion
- (outline-flag-region
- (progn (goto-char post) (line-end-position))
- (progn (goto-char (org-element-property :end drawer))
- (skip-chars-backward " \r\t\n")
- (line-end-position))
- flag))
- ;; When the drawer is hidden away, make sure point lies in
- ;; a visible part of the buffer.
- (when (and flag (> (line-beginning-position) post))
- (goto-char post)))))))
+ (let ((drawer (or element
+ (and (save-excursion
+ (beginning-of-line)
+ (org-looking-at-p org-drawer-regexp))
+ (org-element-at-point)))))
+ (when (memq (org-element-type drawer) '(drawer property-drawer))
+ (let ((post (org-element-property :post-affiliated drawer)))
+ (save-excursion
+ (outline-flag-region
+ (progn (goto-char post) (line-end-position))
+ (progn (goto-char (org-element-property :end drawer))
+ (skip-chars-backward " \r\t\n")
+ (line-end-position))
+ flag))
+ ;; When the drawer is hidden away, make sure point lies in
+ ;; a visible part of the buffer.
+ (when (and flag (> (line-beginning-position) post))
+ (goto-char post))))))
(defun org-subtree-end-visible-p ()
"Is the end of the current subtree visible?"
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index de28772..3707be1 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -4237,7 +4237,7 @@ Paragraph<point>"
(get-char-property (line-end-position) 'invisible)))
;; Test optional argument.
(should
- (org-test-with-temp-text ":D1:\nc1\n:END:\n\n:D2:\nc2\n:END:"
+ (org-test-with-temp-text "Text\n:D1:\nc1\n:END:\n\n:D2:\nc2\n:END:"
(let ((drawer (save-excursion (search-forward ":D2")
(org-element-at-point))))
(org-flag-drawer t drawer)