diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-10 02:19:43 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-10 02:19:43 +0200 |
commit | f1c0f34772a35c0f7c4fc7de814de625d553afc6 (patch) | |
tree | 216d223eb0fcdcba4dabf2801c46b388e62c0859 | |
parent | c744d3cf4c0be13b628aa15a235f0b4726372c13 (diff) | |
download | org-mode-f1c0f34772a35c0f7c4fc7de814de625d553afc6.tar.gz |
Small speed-up to `org-overview'
* lisp/org.el (org-overview): Use direct Org function instead of
Outline's for a slight speed-up.
-rw-r--r-- | lisp/org.el | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lisp/org.el b/lisp/org.el index e48bb60..5892edf 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6538,20 +6538,21 @@ With a numeric prefix, show all headlines up to that level." (org-end-of-subtree))))))) (defun org-overview () - "Switch to overview mode, showing only top-level headlines. -This shows all headlines with a level equal or greater than the level -of the first headline in the buffer. This is important, because if the -first headline is not level one, then (hide-sublevels 1) gives confusing -results." + "Switch to overview mode, showing only top-level headlines." (interactive) + (org-show-all '(headings)) (save-excursion - (let ((level - (save-excursion - (goto-char (point-min)) - (when (re-search-forward org-outline-regexp-bol nil t) - (goto-char (match-beginning 0)) - (funcall outline-level))))) - (and level (outline-hide-sublevels level))))) + (goto-char (point-min)) + (when (re-search-forward org-outline-regexp-bol nil t) + (let* ((last (line-end-position)) + (level (- (match-end 0) (match-beginning 0) 1)) + (regexp (format "^\\*\\{1,%d\\} " level))) + (while (re-search-forward regexp nil :move) + (org-flag-region last (line-end-position 0) t 'outline) + (setq last (line-end-position)) + (setq level (- (match-end 0) (match-beginning 0) 1)) + (setq regexp (format "^\\*\\{1,%d\\} " level))) + (org-flag-region last (point) t 'outline))))) (defun org-content (&optional arg) "Show all headlines in the buffer, like a table of contents. |