From 00f905549e40a333447ecbe3701f0205ece995a5 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 3 Oct 2012 18:47:31 +0200 Subject: [PATCH 1/2] Add mc/dump-list to make mc/save-lists diff-friendly --- multiple-cursors-core.el | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index 6312db5..132c415 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -479,6 +479,17 @@ from being executed if in multiple-cursors-mode." "The position of the file that keeps track of your preferences for running commands with multiple cursors.") +(defun mc/dump-list (list-symbol) + "Insert (setq 'LIST-SYMBOL LIST-VALUE) to current buffer." + (let ((value (symbol-value list-symbol))) + (insert "(setq " (symbol-name list-symbol) "\n" + " '(") + (newline-and-indent) + (mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent)) + value) + (insert "))") + (newline))) + (defun mc/save-lists () "Saves preferences for running commands with multiple cursors to `mc/list-file'" (with-temp-file mc/list-file @@ -488,21 +499,9 @@ for running commands with multiple cursors.") (insert ";; It keeps track of your preferences for running commands with multiple cursors.") (newline) (newline) - (insert "(setq mc/cmds-to-run-for-all '(") - (mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent)) mc/cmds-to-run-for-all) - (when mc/cmds-to-run-for-all - (forward-line -1) - (end-of-line)) - (insert "))") + (mc/dump-list 'mc/cmds-to-run-for-all) (newline) - (newline) - (insert "(setq mc/cmds-to-run-once '(") - (mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent)) mc/cmds-to-run-once) - (when mc/cmds-to-run-once - (forward-line -1) - (end-of-line)) - (insert "))") - (newline))) + (mc/dump-list 'mc/cmds-to-run-once))) (defvar mc/cmds-to-run-once nil "Commands to run only once in multiple-cursors-mode.") From f4d5aea860cffa5f3d083a16a95c07356da96d15 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 3 Oct 2012 18:50:29 +0200 Subject: [PATCH 2/2] Sort before saving list in mc/save-lists --- multiple-cursors-core.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index 132c415..387f7ea 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -486,7 +486,8 @@ for running commands with multiple cursors.") " '(") (newline-and-indent) (mapc #'(lambda (cmd) (insert (format "%S" cmd)) (newline-and-indent)) - value) + (sort value (lambda (x y) (string-lessp (symbol-name x) + (symbol-name y))))) (insert "))") (newline)))