From 1686630fd69279023bb2768f8174347ccaa91c8d Mon Sep 17 00:00:00 2001 From: bb2020 Date: Thu, 12 May 2016 14:41:38 +0300 Subject: [PATCH 1/3] try to implement blacklist --- multiple-cursors-core.el | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index 09b1b01..dd733f2 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -310,6 +310,19 @@ cursor with updated info." (mc/pop-state-from-overlay mc--stored-state-for-undo) (setq mc--stored-state-for-undo nil))) +(defcustom mc/black-list-prefer nil + "Disables whitelist mechanism and executes commands that are defined +in mc/black-list only once. If you are a novice multiple-cursors or +Emacs user, it is benefitical to stick to whitelists." + :type '(boolean) + :group 'multiple-cursors) + +(defcustom mc/black-list nil + "Commands to execute once while using multiple-cursors. Requires +mc/black-list-prefer to be non-nil." + :type '(repeat function) + :group 'multiple-cursors) + (defun mc/prompt-for-inclusion-in-whitelist (original-command) "Asks the user, then adds the command either to the once-list or the all-list." (let ((all-p (y-or-n-p (format "Do %S for all cursors?" original-command)))) @@ -396,13 +409,19 @@ 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)) - (when (and original-command - (not (memq original-command mc--default-cmds-to-run-once)) - (not (memq original-command mc/cmds-to-run-once)) - (or (memq original-command mc--default-cmds-to-run-for-all) - (memq original-command mc/cmds-to-run-for-all) - (mc/prompt-for-inclusion-in-whitelist original-command))) - (mc/execute-command-for-all-fake-cursors original-command)))))))))) + (if mc/black-list-prefer + (when (and original-command + (not (memq original-command mc--default-cmds-to-run-once)) + (or (memq original-command mc--default-cmds-to-run-for-all) + (not (memq original-command mc/black-list)))) + (mc/execute-command-for-all-fake-cursors original-command)) + (when (and original-command + (not (memq original-command mc--default-cmds-to-run-once)) + (not (memq original-command mc/cmds-to-run-once)) + (or (memq original-command mc--default-cmds-to-run-for-all) + (memq original-command mc/cmds-to-run-for-all) + (mc/prompt-for-inclusion-in-whitelist original-command))) + (mc/execute-command-for-all-fake-cursors original-command))))))))))) (defun mc/remove-fake-cursors () "Remove all fake cursors. From fd847ae6e7de876978c4d81850b27d221131187c Mon Sep 17 00:00:00 2001 From: bb2020 Date: Thu, 9 Jun 2016 22:41:51 +0300 Subject: [PATCH 2/3] added mc/always-run-for-all --- multiple-cursors-core.el | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index dd733f2..1b933aa 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -310,19 +310,11 @@ cursor with updated info." (mc/pop-state-from-overlay mc--stored-state-for-undo) (setq mc--stored-state-for-undo nil))) -(defcustom mc/black-list-prefer nil - "Disables whitelist mechanism and executes commands that are defined -in mc/black-list only once. If you are a novice multiple-cursors or -Emacs user, it is benefitical to stick to whitelists." +(defcustom mc/always-run-for-all nil + "Disables whitelisting and always executes commands for every fake cursor." :type '(boolean) :group 'multiple-cursors) -(defcustom mc/black-list nil - "Commands to execute once while using multiple-cursors. Requires -mc/black-list-prefer to be non-nil." - :type '(repeat function) - :group 'multiple-cursors) - (defun mc/prompt-for-inclusion-in-whitelist (original-command) "Asks the user, then adds the command either to the once-list or the all-list." (let ((all-p (y-or-n-p (format "Do %S for all cursors?" original-command)))) @@ -409,19 +401,14 @@ 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)) - (if mc/black-list-prefer - (when (and original-command - (not (memq original-command mc--default-cmds-to-run-once)) - (or (memq original-command mc--default-cmds-to-run-for-all) - (not (memq original-command mc/black-list)))) - (mc/execute-command-for-all-fake-cursors original-command)) - (when (and original-command - (not (memq original-command mc--default-cmds-to-run-once)) - (not (memq original-command mc/cmds-to-run-once)) - (or (memq original-command mc--default-cmds-to-run-for-all) - (memq original-command mc/cmds-to-run-for-all) - (mc/prompt-for-inclusion-in-whitelist original-command))) - (mc/execute-command-for-all-fake-cursors original-command))))))))))) + (when (and original-command + (not (memq original-command mc--default-cmds-to-run-once)) + (not (memq original-command mc/cmds-to-run-once)) + (or (memq original-command mc--default-cmds-to-run-for-all) + (memq original-command mc/cmds-to-run-for-all) + (or mc/always-run-for-all + (mc/prompt-for-inclusion-in-whitelist original-command)))) + (mc/execute-command-for-all-fake-cursors original-command)))))))))) (defun mc/remove-fake-cursors () "Remove all fake cursors. From d26cecd53aa03dd4db12d126dd3f37c65af2aaf0 Mon Sep 17 00:00:00 2001 From: bb2020 Date: Thu, 9 Jun 2016 23:06:48 +0300 Subject: [PATCH 3/3] added always-run-for-all --- multiple-cursors-core.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el index b48e88c..650ce3c 100644 --- a/multiple-cursors-core.el +++ b/multiple-cursors-core.el @@ -404,10 +404,10 @@ the original cursor, to inform about the lack of support." (when (and original-command (not (memq original-command mc--default-cmds-to-run-once)) (not (memq original-command mc/cmds-to-run-once)) - (or (memq original-command mc--default-cmds-to-run-for-all) + (or mc/always-run-for-all + (memq original-command mc--default-cmds-to-run-for-all) (memq original-command mc/cmds-to-run-for-all) - (or mc/always-run-for-all - (mc/prompt-for-inclusion-in-whitelist original-command)))) + (mc/prompt-for-inclusion-in-whitelist original-command))) (mc/execute-command-for-all-fake-cursors original-command)))))))))) (defun mc/remove-fake-cursors ()