summaryrefslogtreecommitdiff
path: root/lisp/loadhist.el
diff options
context:
space:
mode:
authorŠtěpán Němec <stepnem@gmail.com>2020-04-06 13:25:41 +0200
committerŠtěpán Němec <stepnem@gmail.com>2020-10-21 18:51:12 +0200
commit0e9e36747f060a52ce4ecbf48eeb8421d4a19c68 (patch)
treeb811388700bd6233b56afda1ce464f7bb5f67540 /lisp/loadhist.el
parent4bd8add2e3cc668c04b634e8d5a915c7d6803e17 (diff)
downloademacs-0e9e36747f060a52ce4ecbf48eeb8421d4a19c68.tar.gz
unload-feature: Improve logic (don't repeat computation)
* lisp/loadhist.el (unload-feature): Don't do the same computation twice.
Diffstat (limited to 'lisp/loadhist.el')
-rw-r--r--lisp/loadhist.el33
1 files changed, 17 insertions, 16 deletions
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index a1ff2f6270d..60da00cceb2 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -287,22 +287,23 @@ something strange, such as redefining an Emacs function."
;; functions which the package might just have installed, and
;; there might be other important state, but this tactic
;; normally works.
- (mapatoms
- (lambda (x)
- (when (and (boundp x)
- (or (and (consp (symbol-value x)) ; Random hooks.
- (string-match "-hooks?\\'" (symbol-name x)))
- (memq x unload-feature-special-hooks))) ; Known abnormal hooks etc.
- (dolist (y unload-function-defs-list)
- (when (and (eq (car-safe y) 'defun)
- (not (get (cdr y) 'autoload)))
- (remove-hook x (cdr y)))))))
- ;; Remove any feature-symbols from auto-mode-alist as well.
- (dolist (y unload-function-defs-list)
- (when (and (eq (car-safe y) 'defun)
- (not (get (cdr y) 'autoload)))
- (setq auto-mode-alist
- (rassq-delete-all (cdr y) auto-mode-alist)))))
+ (let ((removables (cl-loop for def in unload-function-defs-list
+ when (and (eq (car-safe def) 'defun)
+ (not (get (cdr def) 'autoload)))
+ collect (cdr def))))
+ (mapatoms
+ (lambda (x)
+ (when (and (boundp x)
+ (or (and (consp (symbol-value x)) ; Random hooks.
+ (string-match "-hooks?\\'" (symbol-name x)))
+ ;; Known abnormal hooks etc.
+ (memq x unload-feature-special-hooks)))
+ (dolist (func removables)
+ (remove-hook x func)))))
+ ;; Remove any feature-symbols from auto-mode-alist as well.
+ (dolist (func removables)
+ (setq auto-mode-alist
+ (rassq-delete-all func auto-mode-alist)))))
;; Change major mode in all buffers using one defined in the feature being unloaded.
(unload--set-major-mode)