From 719573c43ecb6e37e2f7c813dfcab09c8707d59d Mon Sep 17 00:00:00 2001 From: Allen Li Date: Wed, 27 Mar 2019 12:39:28 -0700 Subject: [PATCH] Load custom variable dependencies in FIFO order The custom-autoload function is used in autoloads/loaddef files to set up custom variables. custom-autoload adds a load path to the custom-loads property of a variable. This property is then used in custom-load-symbol to load each of the load paths. The problem is that custom-autoload adds load paths to the front of custom-loads, and custom-load-symbol loads the paths in forward order. This is unexpected because if the site distributes a package foo and the user installs their own version of foo, the site custom-autoload will be called first: ;; Called from site-start (custom-autoload 'foo-some-variable "path/to/site/foo" nil) ;; Called from init.el/package-initialize (custom-autoload 'foo-some-variable "path/to/user/foo" nil) In this case the custom-loads property will be ("path/to/user/foo" "path/to/site/foo") The user version will be loaded first, and the site version will be loaded later, overriding the user version. This behavior is unexpected; the user would expect that their version of foo overrides the site version of foo. Furthermore, this behavior is somewhat non-deterministic; site overrides foo *only if* foo is loaded via setting foo-some-variable with customize. If foo is loaded normally (e.g. with require), then the user version of foo will be loaded in preference to the site verison of foo. * lisp/custom.el (custom-load-symbol): Load variable deps in reverse order. --- lisp/custom.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/custom.el b/lisp/custom.el index f0125742d1..da407bee83 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -639,7 +639,7 @@ custom-load-symbol (condition-case nil (require 'cus-start) (error nil)) - (dolist (load (get symbol 'custom-loads)) + (dolist (load (reverse (get symbol 'custom-loads))) (cond ((symbolp load) (condition-case nil (require load) (error nil))) ;; This is subsumed by the test below, but it's much faster. ((assoc load load-history)) -- 2.21.0.392.gf8f6787159e-goog