branch: elpa/multiple-cursors
commit d27870dff3a765e1c1fcb0ea5e433ec62a62dfb6
Author: Andrew Whatson <[email protected]>
Commit: Andrew Whatson <[email protected]>
Load mc/list-file as late as possible
Previously the list file was loaded immediately upon loading
`multiple-cursors-core`. This doesn't work well with modern autoloading
emacs configurations, where customisation is mostly done in
`eval-after-load` hooks; the default file location is loaded, *then*
the value of `mc/list-file` is changed, and everyone is confused.
---
multiple-cursors-core.el | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 935f6df..12e9e75 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -435,6 +435,10 @@ the original cursor, to inform about the lack of support."
(message "%S is not supported with multiple cursors%s"
original-command
(get original-command 'mc--unsupported))
+
+ ;; lazy-load the user's list file
+ (mc/load-lists)
+
(when (and original-command
(not (memq original-command
mc--default-cmds-to-run-once))
(not (memq original-command mc/cmds-to-run-once))
@@ -613,6 +617,15 @@ for running commands with multiple cursors."
:type 'file
:group 'multiple-cursors)
+(defvar mc--list-file-loaded nil
+ "Whether the list file has already been loaded.")
+
+(defun mc/load-lists ()
+ "Loads preferences for running commands with multiple cursors from
`mc/list-file'"
+ (unless mc--list-file-loaded
+ (load mc/list-file 'noerror 'nomessage)
+ (setq mc--list-file-loaded t)))
+
(defun mc/dump-list (list-symbol)
"Insert (setq 'LIST-SYMBOL LIST-VALUE) to current buffer."
(cl-symbol-macrolet ((value (symbol-value list-symbol)))
@@ -817,10 +830,6 @@ for running commands with multiple cursors."
(defvar mc/cmds-to-run-for-all nil
"Commands to run for all cursors in multiple-cursors-mode")
-;; load, but no errors if it does not exist yet please, and no message
-;; while loading
-(load mc/list-file 'noerror 'nomessage)
-
(provide 'multiple-cursors-core)
;; Local Variables: