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

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

[nongnu] elpa/multiple-cursors 3cfae1d 290/434: Merge pull request #122


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 3cfae1d 290/434: Merge pull request #122 from kyanagi/appropriate-error-messages-when-no-fake-cursors-exist
Date: Sat, 7 Aug 2021 09:20:45 -0400 (EDT)

branch: elpa/multiple-cursors
commit 3cfae1dac20b483f7490f620c70fd78eb16fb9bd
Merge: 75ece68 00aea4c
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>

    Merge pull request #122 from 
kyanagi/appropriate-error-messages-when-no-fake-cursors-exist
    
    Show appropriate error messages on trying skipping/unmarking commands with 
no fake cursors
---
 mc-mark-more.el | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/mc-mark-more.el b/mc-mark-more.el
index c957ce8..ef4b877 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -107,17 +107,19 @@ Use like case-fold-search, don't recommend setting it 
globally.")
         (match-point-getter (ecase direction
                               (forwards 'match-beginning)
                               (backwards 'match-end))))
-    (mc/save-excursion
-     (goto-char start-char)
-     (when skip-last
-       (mc/remove-fake-cursor furthest-cursor))
-     (if (funcall search-function re nil t)
-         (progn
-           (push-mark (funcall match-point-getter 0))
-           (when point-out-of-order
-             (exchange-point-and-mark))
-           (mc/create-fake-cursor-at-point))
-       (error "no more matches found.")))))
+    (if (and skip-last (not furthest-cursor))
+        (error "No cursors to be skipped")
+      (mc/save-excursion
+       (goto-char start-char)
+       (when skip-last
+         (mc/remove-fake-cursor furthest-cursor))
+       (if (funcall search-function re nil t)
+           (progn
+             (push-mark (funcall match-point-getter 0))
+             (when point-out-of-order
+               (exchange-point-and-mark))
+             (mc/create-fake-cursor-at-point))
+         (error "no more matches found."))))))
 
 ;;;###autoload
 (defun mc/mark-next-like-this (arg)
@@ -127,7 +129,10 @@ With zero ARG, skip the last one and mark next."
   (interactive "p")
   (if (region-active-p)
       (if (< arg 0)
-          (mc/remove-fake-cursor (mc/furthest-cursor-after-point))
+          (let ((cursor (mc/furthest-cursor-after-point)))
+            (if cursor
+                (mc/remove-fake-cursor cursor)
+              (error "No cursors to be unmarked")))
         (mc/mark-more-like-this (= arg 0) 'forwards))
     (mc/mark-lines arg 'forwards))
   (mc/maybe-multiple-cursors-mode))
@@ -152,7 +157,10 @@ With zero ARG, skip the last one and mark next."
   (interactive "p")
   (if (region-active-p)
       (if (< arg 0)
-          (mc/remove-fake-cursor (mc/furthest-cursor-before-point))
+          (let ((cursor (mc/furthest-cursor-before-point)))
+            (if cursor
+                (mc/remove-fake-cursor cursor)
+              (error "No cursors to be unmarked")))
         (mc/mark-more-like-this (= arg 0) 'backwards))
     (mc/mark-lines arg 'backwards))
   (mc/maybe-multiple-cursors-mode))



reply via email to

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