summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-11-08 16:16:17 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-11-08 16:16:17 +0100
commitb8f100c14ab20d544ad16e66f278e2ce7561bdaa (patch)
tree55292e85692d9f783f2a6db9e77b2597d997d52e
parentdf321b097fd96cfa470e97451ef02093fa8425b0 (diff)
downloadorg-mode-b8f100c14ab20d544ad16e66f278e2ce7561bdaa.tar.gz
Fix `org-cycle' within `orgstruct-mode'
* lisp/org.el (org-show-children): Fallback to `outline-show-children' when `orgstruct-mode' is active. Reported-by: Jonas Bernoulli <jonas@bernoul.li> <http://permalink.gmane.org/gmane.emacs.orgmode/102709>
-rwxr-xr-xlisp/org.el62
1 files changed, 33 insertions, 29 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 9582eb1..6e641c3 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -24868,35 +24868,39 @@ Prefix arg LEVEL is how many levels below the current level
should be shown. Default is enough to cause the following
heading to appear."
(interactive "p")
- (save-excursion
- (org-back-to-heading t)
- (let* ((current-level (funcall outline-level))
- (max-level (org-get-valid-level
- current-level (if level (prefix-numeric-value level) 1)))
- (end (save-excursion (org-end-of-subtree t t)))
- (regexp-fmt "^\\*\\{%d,%s\\}\\(?: \\|$\\)")
- (past-first-child nil)
- ;; Make sure to skip inlinetasks.
- (re (format regexp-fmt
- current-level
- (cond
- ((not (featurep 'org-inlinetask)) "")
- (org-odd-levels-only (- (* 2 org-inlinetask-min-level)
- 3))
- (t (1- org-inlinetask-min-level))))))
- ;; Display parent heading.
- (outline-flag-region (line-end-position 0) (line-end-position) nil)
- (forward-line)
- ;; Display children. First child may be deeper than expected
- ;; MAX-LEVEL. Since we want to display it anyway, adjust
- ;; MAX-LEVEL accordingly.
- (while (re-search-forward re end t)
- (unless past-first-child
- (setq re (format regexp-fmt
- current-level
- (max (funcall outline-level) max-level)))
- (setq past-first-child t))
- (outline-flag-region (line-end-position 0) (line-end-position) nil)))))
+ ;; If `orgstruct-mode' is active, use the slower version.
+ (if orgstruct-mode (call-interactively #'show-children)
+ (save-excursion
+ (org-back-to-heading t)
+ (let* ((current-level (funcall outline-level))
+ (max-level (org-get-valid-level
+ current-level
+ (if level (prefix-numeric-value level) 1)))
+ (end (save-excursion (org-end-of-subtree t t)))
+ (regexp-fmt "^\\*\\{%d,%s\\}\\(?: \\|$\\)")
+ (past-first-child nil)
+ ;; Make sure to skip inlinetasks.
+ (re (format regexp-fmt
+ current-level
+ (cond
+ ((not (featurep 'org-inlinetask)) "")
+ (org-odd-levels-only (- (* 2 org-inlinetask-min-level)
+ 3))
+ (t (1- org-inlinetask-min-level))))))
+ ;; Display parent heading.
+ (outline-flag-region (line-end-position 0) (line-end-position) nil)
+ (forward-line)
+ ;; Display children. First child may be deeper than expected
+ ;; MAX-LEVEL. Since we want to display it anyway, adjust
+ ;; MAX-LEVEL accordingly.
+ (while (re-search-forward re end t)
+ (unless past-first-child
+ (setq re (format regexp-fmt
+ current-level
+ (max (funcall outline-level) max-level)))
+ (setq past-first-child t))
+ (outline-flag-region
+ (line-end-position 0) (line-end-position) nil))))))
(defun org-show-subtree ()
"Show everything after this heading at deeper levels."