1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

(outline--hidden-headings-paths): Fix slow saves (bug#78665)

* lisp/outline.el: Prefer #' to quote function names.
(outline--end-of-previous): New function, extracted from
`outline-end-of-subtree`.
(outline-end-of-subtree): Use it.
(outline--hidden-headings-paths): Distinguish headings where just the
entry is hidden from those where a whole subtree is hidden (bug#78673).
(outline--hidden-headings-restore-paths): Adjust accordingly and don't
delegate to functions like `outline-hide-subtree` so as to avoid
an O(N²) behavior.
This commit is contained in:
Stefan Monnier 2025-06-04 16:36:27 -04:00
parent 6f24725323
commit 77a4c63fda
2 changed files with 90 additions and 59 deletions

View file

@ -72,7 +72,7 @@
(transient--emergency-exit :debugger)
(apply #'debug args))
;;; Options
;;;; Options
(defgroup transient nil
"Transient commands."
@ -507,7 +507,7 @@ give you as many additional suffixes as you hoped.)"
:group 'transient
:type 'boolean)
;;; Faces
;;;; Faces
(defgroup transient-faces nil
"Faces used by Transient."
@ -655,7 +655,7 @@ See also option `transient-highlight-mismatched-keys'."
See also option `transient-highlight-mismatched-keys'."
:group 'transient-faces)
;;; Persistence
;;;; Persistence
(defun transient--read-file-contents (file)
(with-demoted-errors "Transient error: %S"
@ -718,7 +718,7 @@ If `transient-save-history' is nil, then do nothing."
(unless noninteractive
(add-hook 'kill-emacs-hook #'transient-maybe-save-history))
;;; Classes
;;;; Classes
;;;; Prefix
(defclass transient-prefix ()
@ -965,7 +965,7 @@ commands or strings. This group inserts an empty line between
subgroups. The subgroups are responsible for displaying their
elements themselves.")
;;; Define
;;;; Define
(defmacro transient-define-prefix (name arglist &rest args)
"Define NAME as a transient prefix command.
@ -1482,7 +1482,7 @@ Intended for use in a group's `:setup-children' function."
(setq prefix (oref prefix command)))
(mapcar (apply-partially #'transient-parse-suffix prefix) suffixes))
;;; Edit
;;;; Edit
(defun transient--insert-suffix (prefix loc suffix action &optional keep-other)
(pcase-let* ((suf (cl-etypecase suffix
@ -1699,7 +1699,7 @@ using `transient-define-suffix', `transient-define-infix' or
(user-error "Cannot set level for `%s'; no prototype object exists"
command)))
;;; Variables
;;;; Variables
(defvar transient-current-prefix nil
"The transient from which this suffix command was invoked.
@ -1806,7 +1806,7 @@ This is bound while the suffixes are drawn in the transient buffer.")
mwheel-scroll
scroll-bar-toolkit-scroll))
;;; Identities
;;;; Identities
(defun transient-active-prefix (&optional prefixes)
"Return the active transient object.
@ -1944,7 +1944,7 @@ probably use this instead:
(seq-some (lambda (cmd) (get cmd 'transient--suffix))
(function-alias-p command))))
;;; Keymaps
;;;; Keymaps
(defvar-keymap transient-base-map
:doc "Parent of other keymaps used by Transient.
@ -2306,7 +2306,7 @@ of the corresponding object."
transient--transient-map))
topmap))
;;; Setup
;;;; Setup
(defun transient-setup (&optional name layout edit &rest params)
"Setup the transient specified by NAME.
@ -2587,7 +2587,7 @@ value. Otherwise return CHILDREN as is.")
(transient--debug " autoload %s" cmd)
(autoload-do-load fn)))
;;; Flow-Control
;;;; Flow-Control
(defun transient--setup-transient ()
(transient--debug 'setup-transient)
@ -2981,7 +2981,7 @@ identifying the exit."
(transient--pre-exit)
(transient--post-exit this-command)))
;;; Pre-Commands
;;;; Pre-Commands
(defun transient--call-pre-command ()
(if-let* ((fn (transient--get-pre-command this-command
@ -3164,7 +3164,7 @@ prefix argument and pivot to `transient-update'."
(put 'transient--do-move 'transient-face 'transient-key-stay)
(put 'transient--do-minus 'transient-face 'transient-key-stay)
;;; Commands
;;;; Commands
;;;; Noop
(defun transient-noop ()
@ -3487,7 +3487,7 @@ such as when suggesting a new feature or reporting an issue."
arguments " "))
(message "%s: %S" (key-description (this-command-keys)) arguments)))
;;; Value
;;;; Value
;;;; Init
(cl-defgeneric transient-init-value (obj)
@ -4000,7 +4000,7 @@ Append \"=\ to ARG to indicate that it is an option."
(or (match-string 1 match) "")))
(and (member arg args) t)))
;;; Return
;;;; Return
(defun transient-init-return (obj)
(when-let* ((transient--stack)
@ -4012,7 +4012,7 @@ Append \"=\ to ARG to indicate that it is an option."
(list t 'recurse #'transient--do-recurse))))
(oset obj return t)))
;;; Scope
;;;; Scope
;;;; Init
(cl-defgeneric transient-init-scope (obj)
@ -4084,7 +4084,7 @@ If no prefix matches, return nil."
(and-let* ((obj (transient-prefix-object)))
(oref obj scope))))
;;; History
;;;; History
(cl-defgeneric transient--history-key (obj)
"Return OBJ's history key.")
@ -4116,7 +4116,7 @@ have a history of their own.")
(cons val (delete val (alist-get (transient--history-key obj)
transient-history))))))
;;; Display
;;;; Display
(defun transient--show-hint ()
(let ((message-log-max nil))
@ -4190,7 +4190,7 @@ have a history of their own.")
(window-body-width window t)
(window-body-height window t))))
;;; Delete
;;;; Delete
(defun transient--delete-window ()
(when (window-live-p transient--window)
@ -4224,7 +4224,7 @@ have a history of their own.")
(setq show (natnump show)))
show))
;;; Format
;;;; Format
(defun transient--format-hint ()
(if (and transient-show-popup (<= transient-show-popup 0))
@ -4728,7 +4728,7 @@ a prefix command, while porting a regular keymap to a transient."
(propertize (car (split-string doc "\n")) 'face 'font-lock-doc-face)
(propertize (symbol-name command) 'face 'font-lock-function-name-face))))
;;; Help
;;;; Help
(cl-defgeneric transient-show-help (obj)
"Show documentation for the command represented by OBJ.")
@ -5169,7 +5169,7 @@ as stand-in for elements of exhausted lists."
(setq lists (mapcar #'cdr lists)))
(nreverse result)))
;;; Font-Lock
;;;; Font-Lock
(defconst transient-font-lock-keywords
(eval-when-compile
@ -5187,7 +5187,7 @@ as stand-in for elements of exhausted lists."
(font-lock-add-keywords 'emacs-lisp-mode transient-font-lock-keywords)
;;; Auxiliary Classes
;;;; Auxiliary Classes
;;;; `transient-lisp-variable'
(defclass transient-lisp-variable (transient-variable)
@ -5250,4 +5250,4 @@ as stand-in for elements of exhausted lists."
;; indent-tabs-mode: nil
;; checkdoc-symbol-words: ("command-line" "edit-mode" "help-mode")
;; End:
;;; transient.el ends here
;;;; transient.el ends here