emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/multiple-cursors b139bb6 2/3: introduce function mc/disabl


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors b139bb6 2/3: introduce function mc/disable-multiple-cursors-mode
Date: Fri, 12 Nov 2021 17:57:49 -0500 (EST)

branch: elpa/multiple-cursors
commit b139bb6b3054b787e378c3c1794941a82487697f
Author: Johannes Lippmann <code@schauderbasis.de>
Commit: Magnar Sveen <magnars@gmail.com>

    introduce function mc/disable-multiple-cursors-mode
---
 mc-mark-more.el           | 12 +++---------
 mc-separate-operations.el |  3 +--
 multiple-cursors-core.el  | 22 +++++++++-------------
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index 9cbf67f..f0c23b0 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -355,9 +355,7 @@ With zero ARG, skip the last one and mark next."
        (when point-first (exchange-point-and-mark)))))
   (if (> (mc/num-cursors) 1)
       (multiple-cursors-mode 1)
-    (progn
-      (multiple-cursors-mode 0)
-      (run-hooks 'multiple-cursors-mode-disabled-hook))))
+    (mc/disable-multiple-cursors-mode)))
 
 (defun mc--select-thing-at-point (thing)
   (let ((bound (bounds-of-thing-at-point thing)))
@@ -404,9 +402,7 @@ With zero ARG, skip the last one and mark next."
             (mc/pop-state-from-overlay first)))
         (if (> (mc/num-cursors) 1)
             (multiple-cursors-mode 1)
-          (progn
-            (multiple-cursors-mode 0)
-            (run-hooks 'multiple-cursors-mode-disabled-hook)))))))
+          (mc/disable-multiple-cursors-mode))))))
 
 ;;;###autoload
 (defun mc/mark-all-in-region-regexp (beg end)
@@ -431,9 +427,7 @@ With zero ARG, skip the last one and mark next."
             (error "Search failed for %S" search)))
         (goto-char (match-end 0))
         (if (< (mc/num-cursors) 3)
-            (progn
-              (multiple-cursors-mode 0)
-              (run-hooks 'multiple-cursors-mode-disabled-hook))
+            (mc/disable-multiple-cursors-mode)
           (mc/pop-state-from-overlay (mc/furthest-cursor-before-point))
           (multiple-cursors-mode 1))))))
 
diff --git a/mc-separate-operations.el b/mc-separate-operations.el
index 24fcd8f..ddc7395 100644
--- a/mc-separate-operations.el
+++ b/mc-separate-operations.el
@@ -106,8 +106,7 @@
       (progn
         (mc/mark-next-lines 1)
         (mc/reverse-regions)
-        (multiple-cursors-mode 0)
-        (multiple-cursors-mode-disabled-hook)
+        (mc/disable-multiple-cursors-mode)
         )
     (unless (use-region-p)
       (mc/execute-command-for-all-cursors 'mark-sexp))
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index e738504..ab4ee52 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -433,9 +433,7 @@ the original cursor, to inform about the lack of support."
   (unless mc--executing-command-for-fake-cursor
 
     (if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
-        (progn
-          (multiple-cursors-mode 0)
-          (run-hooks 'multiple-cursors-mode-disabled-hook))
+        (mc/disable-multiple-cursors-mode)
       (when this-original-command
         (let ((original-command (or mc--this-command
                                     (command-remapping this-original-command)
@@ -489,9 +487,7 @@ you should disable multiple-cursors-mode."
   "Deactivate mark if there are any active, otherwise exit 
multiple-cursors-mode."
   (interactive)
   (if (not (use-region-p))
-      (progn
-        (multiple-cursors-mode 0)
-        (run-hooks 'multiple-cursors-mode-disabled-hook))
+      (mc/disable-multiple-cursors-mode)
     (deactivate-mark)))
 
 (defun mc/repeat-command ()
@@ -592,18 +588,18 @@ They are temporarily disabled when multiple-cursors are 
active.")
     (mc/enable-temporarily-disabled-minor-modes)
     (run-hooks 'multiple-cursors-mode-disabled-hook)))
 
-(add-hook 'after-revert-hook
-          #'(lambda () (progn
-                         (multiple-cursors-mode 0)
-                         (run-hooks 'multiple-cursors-mode-disabled-hook))))
+(defun mc/disable-multiple-cursors-mode ()
+  "Disable multiple-cursors-mode and run the corresponding hook."
+  (multiple-cursors-mode 0)
+  (run-hooks 'multiple-cursors-mode-disabled-hook))
+
+(add-hook 'after-revert-hook 'mc/disable-multiple-cursors-mode)
 
 (defun mc/maybe-multiple-cursors-mode ()
   "Enable multiple-cursors-mode if there is more than one currently active 
cursor."
   (if (> (mc/num-cursors) 1)
       (multiple-cursors-mode 1)
-    (progn
-      (multiple-cursors-mode 0)
-      (run-hooks 'multiple-cursors-mode-disabled-hook))))
+    (mc/disable-multiple-cursors-mode)))
 
 (defmacro unsupported-cmd (cmd msg)
   "Adds command to list of unsupported commands and prevents it



reply via email to

[Prev in Thread] Current Thread [Next in Thread]