Merge pull request #355 from flatwhatson/lazy-list-file

Load mc/list-file as late as possible
This commit is contained in:
Magnar Sveen 2019-03-17 13:11:44 +01:00 committed by GitHub
commit fc6a6a7462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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" (message "%S is not supported with multiple cursors%s"
original-command original-command
(get original-command 'mc--unsupported)) (get original-command 'mc--unsupported))
;; lazy-load the user's list file
(mc/load-lists)
(when (and original-command (when (and original-command
(not (memq original-command mc--default-cmds-to-run-once)) (not (memq original-command mc--default-cmds-to-run-once))
(not (memq original-command mc/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 :type 'file
:group 'multiple-cursors) :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) (defun mc/dump-list (list-symbol)
"Insert (setq 'LIST-SYMBOL LIST-VALUE) to current buffer." "Insert (setq 'LIST-SYMBOL LIST-VALUE) to current buffer."
(cl-symbol-macrolet ((value (symbol-value list-symbol))) (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 (defvar mc/cmds-to-run-for-all nil
"Commands to run for all cursors in multiple-cursors-mode") "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) (provide 'multiple-cursors-core)
;; Local Variables: ;; Local Variables: