aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-11-05 23:56:10 +0100
committerJonas Bernoulli <jonas@bernoul.li>2025-11-05 23:56:10 +0100
commite6fef5ceff2b87b9de56ab79b5ea366b5cfede05 (patch)
tree2eecb3d378f5118824bdd119c4927afac62aa4eb
parent8e9045656297ccace12a57eff07e50facadab0f5 (diff)
magit-custom-initialize-after-init: Define near where it is used
The sections for libraries are sorted alphabetically in autoload files (or randomly, if they are updated instead of being recreated), so to ensure the autoloaded definition of this function appears before its autoloaded use, the function and caller have to be defined in the same library. Closes #5474. Closes #5475.
-rw-r--r--lisp/magit-autorevert.el18
-rw-r--r--lisp/magit-base.el18
2 files changed, 18 insertions, 18 deletions
diff --git a/lisp/magit-autorevert.el b/lisp/magit-autorevert.el
index b5c9ea7..100b0db 100644
--- a/lisp/magit-autorevert.el
+++ b/lisp/magit-autorevert.el
@@ -104,6 +104,24 @@ seconds of user inactivity. That is not desirable."
;;; Mode
+;;;###autoload
+(progn ; magit-custom-initialize-after-init
+ (defun magit-custom-initialize-after-init (symbol value)
+ (internal--define-uninitialized-variable symbol)
+ (cond ((not after-init-time)
+ (letrec ((f (lambda ()
+ (remove-hook 'after-init-hook f)
+ (custom-initialize-set symbol value))))
+ (add-hook 'after-init-hook f)))
+ ((not load-file-name)
+ (custom-initialize-set symbol value))
+ ((let ((thisfile load-file-name))
+ (letrec ((f (lambda (file)
+ (when (equal file thisfile)
+ (remove-hook 'after-load-functions f)
+ (custom-initialize-set symbol value)))))
+ (add-hook 'after-load-functions f)))))))
+
(defun magit-turn-on-auto-revert-mode-if-desired (&optional file)
(cond (file
(when-let ((buffer (find-buffer-visiting file)))
diff --git a/lisp/magit-base.el b/lisp/magit-base.el
index f47efe6..99566a8 100644
--- a/lisp/magit-base.el
+++ b/lisp/magit-base.el
@@ -1026,24 +1026,6 @@ setting `imenu--index-alist' to nil before calling that function."
;;; Kludges for Custom
-;;;###autoload
-(progn ; magit-custom-initialize-after-init
- (defun magit-custom-initialize-after-init (symbol value)
- (internal--define-uninitialized-variable symbol)
- (cond ((not after-init-time)
- (letrec ((f (lambda ()
- (remove-hook 'after-init-hook f)
- (custom-initialize-set symbol value))))
- (add-hook 'after-init-hook f)))
- ((not load-file-name)
- (custom-initialize-set symbol value))
- ((let ((thisfile load-file-name))
- (letrec ((f (lambda (file)
- (when (equal file thisfile)
- (remove-hook 'after-load-functions f)
- (custom-initialize-set symbol value)))))
- (add-hook 'after-load-functions f)))))))
-
(defun magit-custom-initialize-reset (symbol exp)
"Initialize SYMBOL based on EXP.
Set the value of the variable SYMBOL, using `set-default'