summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-05-08 08:11:07 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2013-05-08 08:11:07 (GMT)
commit5a14001b5e06c2891a9fd711b25da18ca18d4ab2 (patch)
tree149b2d528589beaacf27980520d26757d5ec6390
parent69dabd48bcd72bdf047fe7e5491a6b25294e194e (diff)
parentbe794a2a308483c44968fdd6b09270224d073595 (diff)
downloadorg-mode-5a14001b5e06c2891a9fd711b25da18ca18d4ab2.zip
org-mode-5a14001b5e06c2891a9fd711b25da18ca18d4ab2.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/org-element.el13
-rw-r--r--testing/lisp/test-org-element.el14
2 files changed, 23 insertions, 4 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 16a6cf8..04df21b 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4199,6 +4199,10 @@ elements.
Elements are accumulated into ACC."
(save-excursion
(goto-char beg)
+ ;; Visible only: skip invisible parts at the beginning of the
+ ;; element.
+ (when (and visible-only (org-invisible-p2))
+ (goto-char (min (1+ (org-find-visible)) end)))
;; When parsing only headlines, skip any text before first one.
(when (and (eq granularity 'headline) (not (org-at-heading-p)))
(org-with-limited-levels (outline-next-heading)))
@@ -4211,12 +4215,13 @@ Elements are accumulated into ACC."
(type (org-element-type element))
(cbeg (org-element-property :contents-begin element)))
(goto-char (org-element-property :end element))
+ ;; Visible only: skip invisible parts between siblings.
+ (when (and visible-only (org-invisible-p2))
+ (goto-char (min (1+ (org-find-visible)) end)))
;; Fill ELEMENT contents by side-effect.
(cond
- ;; If VISIBLE-ONLY is true and element is hidden or if it has
- ;; no contents, don't modify it.
- ((or (and visible-only (org-element-property :hiddenp element))
- (not cbeg)))
+ ;; If element has no contents, don't modify it.
+ ((not cbeg))
;; Greater element: parse it between `contents-begin' and
;; `contents-end'. Make sure GRANULARITY allows the
;; recursion, or ELEMENT is a headline, in which case going
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index ae2e4b6..f03f54a 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2613,6 +2613,20 @@ Paragraph \\alpha."
+;;; Test Visible Only Parsing
+
+(ert-deftest test-org-element/parse-buffer-visible ()
+ "Test `org-element-parse-buffer' with visible only argument."
+ (should
+ (equal '("H1" "H3" "H5")
+ (org-test-with-temp-text
+ "* H1\n** H2\n** H3 :visible:\n** H4\n** H5 :visible:"
+ (org-occur ":visible:")
+ (org-element-map (org-element-parse-buffer nil t) 'headline
+ (lambda (hl) (org-element-property :raw-value hl)))))))
+
+
+
;;; Test `:parent' Property
(ert-deftest test-org-element/parent-property ()