summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-08-24 14:50:40 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-08-24 14:50:40 +0200
commit9eaab0b5cf532970a0161f086740f8802cd1ea59 (patch)
tree604a4ce730f8d1c2ebf3e29d651e8879b02aea29
parent0f826c4e879645aa53995e682e247bb93f34a84a (diff)
downloadorg-mode-9eaab0b5cf532970a0161f086740f8802cd1ea59.tar.gz
Visibility Cycling: Allow to show all empty lines after a headline
`org-cycle-separator-lines' can now get a negative value, to indicate that, if the number of empty lines before a visible entry is greater than the specified number, then *all* empty lines should be shown.
-rwxr-xr-xlisp/ChangeLog4
-rw-r--r--lisp/org.el21
2 files changed, 19 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 866f304..09026ab 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
2009-08-24 Carsten Dominik <carsten.dominik@gmail.com>
+ * org.el (org-cycle-separator-lines): Update docstring.
+ (org-cycle-show-empty-lines): Handle negative values for
+ `org-cycle-show-empty-lines'.
+
* org-remember.el (org-remember-escaped-%): New function.
(org-remember-apply-template): Use `org-remember-escaped-%' to
detect escaped % signs.
diff --git a/lisp/org.el b/lisp/org.el
index d3fce7b..6e8dd2c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -673,6 +673,9 @@ So the default 2 means, at least 2 empty lines after the end of a subtree
are needed to produce free space between a collapsed subtree and the
following headline.
+If the number is negative, and the number of empty lines is at least -N,
+all empty lines are shown.
+
Special case: when 0, never leave empty lines in collapsed view."
:group 'org-cycle
:type 'integer)
@@ -5231,16 +5234,16 @@ The region to be covered depends on STATE when called through
`org-cycle-hook'. Lisp program can use t for STATE to get the
entire buffer covered. Note that an empty line is only shown if there
are at least `org-cycle-separator-lines' empty lines before the headline."
- (when (> org-cycle-separator-lines 0)
+ (when (not (= org-cycle-separator-lines 0))
(save-excursion
- (let* ((n org-cycle-separator-lines)
+ (let* ((n (abs org-cycle-separator-lines))
(re (cond
((= n 1) "\\(\n[ \t]*\n\\*+\\) ")
((= n 2) "^[ \t]*\\(\n[ \t]*\n\\*+\\) ")
(t (let ((ns (number-to-string (- n 2))))
(concat "^\\(?:[ \t]*\n\\)\\{" ns "," ns "\\}"
"[ \t]*\\(\n[ \t]*\n\\*+\\) ")))))
- beg end)
+ beg end b e)
(cond
((memq state '(overview contents t))
(setq beg (point-min) end (point-max)))
@@ -5251,9 +5254,15 @@ are at least `org-cycle-separator-lines' empty lines before the headline."
(when beg
(goto-char beg)
(while (re-search-forward re end t)
- (if (not (get-char-property (match-end 1) 'invisible))
- (outline-flag-region
- (match-beginning 1) (match-end 1) nil)))))))
+ (unless (get-char-property (match-end 1) 'invisible)
+ (setq e (match-end 1))
+ (if (< org-cycle-separator-lines 0)
+ (setq b (save-excursion
+ (goto-char (match-beginning 0))
+ (org-back-over-empty-lines)
+ (point)))
+ (setq b (match-beginning 1)))
+ (outline-flag-region b e nil)))))))
;; Never hide empty lines at the end of the file.
(save-excursion
(goto-char (point-max))