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.
This commit is contained in:
Andrew Whatson 2019-03-13 12:44:59 +10:00
parent 5ff2071fac
commit d27870dff3

View File

@ -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: