thank you. this version is significantly faster. qualitatively
improved.
it has a possibly minor bug.
evalled as source:
- command-execute 8072 98%
- call-interactively 8072 98%
- org-agenda-switch-to 7595 92%
- org-show-context 7595 92%
- org-show-set-visibility 7595 92%
- show-children 7039 86%
- save-excursion 7015 85%
- let* 7015 85%
- while 4832 59%
- outline-flag-region 692 8%
remove-overlays 12 0%
- save-excursion 2179 26%
org-end-of-subtree 2179 26%
- funcall 4 0%
org-outline-level 4 0%
however, if the next heading has fewer stars, it errors:
Debugger entered--Lisp error: (invalid-regexp "Invalid content of \\{\\}")
re-search-forward("^\\*\\{27,13\\} +" 2473493 t)
(while (re-search-forward re end t) (outline-flag-region
(line-end-position 0) (line-end-position) nil))
(let* ((current-level (funcall outline-level)) (level (if level (+
(prefix-numeric-value level) current-level) (save-excursion
(outline-next-heading) (if (eobp) current-level (funcall
outline-level))))) (re (format "^\\*\\{%d,%d\\} +" current-level
level)) (end (save-excursion (org-end-of-subtree t t)))) (while
(re-search-forward re end t) (outline-flag-region (line-end-position
0) (line-end-position) nil)))
(save-excursion (org-back-to-heading t) (let* ((current-level
(funcall outline-level)) (level (if level (+ (prefix-numeric-value
level) current-level) (save-excursion (outline-next-heading) (if
(eobp) current-level (funcall outline-level))))) (re (format
"^\\*\\{%d,%d\\} +" current-level level)) (end (save-excursion
(org-end-of-subtree t t)))) (while (re-search-forward re end t)
(outline-flag-region (line-end-position 0) (line-end-position) nil))))
show-children()
org-show-set-visibility(canonical)
org-show-context(agenda)
org-agenda-switch-to()
call-interactively(org-agenda-switch-to nil nil)
command-execute(org-agenda-switch-to)
(defun show-children (&optional level)
(save-excursion
(org-back-to-heading t)
(let* ((current-level (funcall outline-level))
(level (if level (+ (prefix-numeric-value level) current-level)
(save-excursion
(outline-next-heading)
(if (eobp) current-level (funcall outline-level)))))
(re (format "^\\*\\{%d,%d\\} +" current-level level))
(end (save-excursion (org-end-of-subtree t t))))
(while (re-search-forward re end t)
(outline-flag-region (line-end-position 0)
(line-end-position) nil)))))
On 8/8/15, Nicolas Goaziou <[email protected]> wrote:
> This one may improve the situation: