[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 2682e48 285/434: Merge pull request #116
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 2682e48 285/434: Merge pull request #116 from gvol/master |
Date: |
Sat, 7 Aug 2021 09:20:43 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 2682e48204218f639baf5e3c2dcb8646ccad5a55
Merge: c69be0e 2d639b0
Author: Magnar Sveen <magnars@gmail.com>
Commit: Magnar Sveen <magnars@gmail.com>
Merge pull request #116 from gvol/master
Added mc/edit-lines-empty-lines
---
features/edit-lines.feature | 83 +++++++++++++++++++++++++++++++++++++++++++++
mc-edit-lines.el | 49 ++++++++++++++++++++++----
2 files changed, 126 insertions(+), 6 deletions(-)
diff --git a/features/edit-lines.feature b/features/edit-lines.feature
index 814f784..080eaee 100644
--- a/features/edit-lines.feature
+++ b/features/edit-lines.feature
@@ -55,3 +55,86 @@ Feature: Switching from a multiline region to multiple
cursors
And I go to the front of the word "there"
And I press "C-S-c C-S-c"
Then I should have 2 cursors
+
+ Scenario: Edit default short lines
+ When I insert:
+ """
+ hello
+
+ there
+ """
+ And I go to the end of the word "hello"
+ And I set the mark
+ And I go to the end of the word "there"
+ And I press "C-S-c C-S-c"
+ And I press "you"
+ Then I should see:
+ """
+ helloyou
+ you
+ thereyou
+ """
+
+ Scenario: Pad short lines
+ When I insert:
+ """
+ hello
+
+ there
+ """
+ And I go to the end of the word "hello"
+ And I set the mark
+ And I go to the end of the word "there"
+ And I press "M-1 C-S-c C-S-c"
+ Then I should have 3 cursors
+
+ Scenario: Edit padding short lines
+ When I insert:
+ """
+ hello
+
+ there
+ """
+ And I go to the end of the word "hello"
+ And I set the mark
+ And I go to the end of the word "there"
+ And I press "M-1 C-S-c C-S-c"
+ And I press "you"
+ Then I should see:
+ """
+ helloyou
+ you
+ thereyou
+ """
+
+ Scenario: Skip short lines
+ When I insert:
+ """
+ hello
+
+ there
+ """
+ And I go to the end of the word "hello"
+ And I set the mark
+ And I go to the end of the word "there"
+ And I press "M-- M-1 C-S-c C-S-c"
+ Then I should have 2 cursors
+
+ Scenario: Edit skipping short lines
+ When I insert:
+ """
+ hello
+
+ there
+ """
+ And I go to the end of the word "hello"
+ And I set the mark
+ And I go to the end of the word "there"
+ And I press "M-- M-1 C-S-c C-S-c"
+ And I press "you"
+ Then I should see:
+ """
+ helloyou
+
+ thereyou
+ """
diff --git a/mc-edit-lines.el b/mc-edit-lines.el
index 3303620..20668cf 100644
--- a/mc-edit-lines.el
+++ b/mc-edit-lines.el
@@ -29,25 +29,62 @@
(require 'multiple-cursors-core)
+(defcustom mc/edit-lines-empty-lines nil
+ "What should be done by `mc/edit-lines' when a line is not long enough."
+ :type '(radio (const :tag "Pad the line with spaces." pad)
+ (const :tag "Ignore the line." ignore)
+ (const :tag "Signal an error." error)
+ (const :tag "Nothing. Cursor is at end of line." nil))
+ :group 'multiple-cursors)
+
;;;###autoload
-(defun mc/edit-lines ()
+(defun mc/edit-lines (&optional arg)
"Add one cursor to each line of the active region.
Starts from mark and moves in straight down or up towards the
-line point is on."
- (interactive)
+line point is on.
+
+What is done with lines which are not long enough is governed by
+`mc/edit-lines-empty-lines'. The prefix argument ARG can be used
+to override this. If ARG is a symbol (when called from Lisp),
+that symbol is used instead of `mc/edit-lines-empty-lines'.
+Otherwise, if ARG negative, short lines will be ignored. Any
+other non-nil value will cause short lines to be padded."
+ (interactive "P")
(when (not (and mark-active (/= (point) (mark))))
- (error "Mark a set of lines first."))
+ (error "Mark a set of lines first"))
(mc/remove-fake-cursors)
(let* ((col (current-column))
(point-line (line-number-at-pos))
(mark-line (progn (exchange-point-and-mark) (line-number-at-pos)))
- (direction (if (< point-line mark-line) :up :down)))
+ (direction (if (< point-line mark-line) :up :down))
+ (style (cond
+ ;; called from lisp
+ ((and arg (symbolp arg))
+ arg)
+ ;; negative argument
+ ((< (prefix-numeric-value arg) 0)
+ 'ignore)
+ (arg 'pad)
+ (t mc/edit-lines-empty-lines))))
(deactivate-mark)
(when (and (eq direction :up) (bolp))
(previous-logical-line 1 nil)
(move-to-column col))
+ ;; Add the cursors
(while (not (eq (line-number-at-pos) point-line))
- (mc/create-fake-cursor-at-point)
+ ;; Pad the line
+ (when (eq style 'pad)
+ (while (< (current-column) col)
+ (insert " ")))
+ ;; Error
+ (when (and (eq style 'error)
+ (not (equal col (current-column))))
+ (error "Short line encountered in `mc/edit-lines'"))
+ ;; create the cursor
+ (unless (and (eq style 'ignore)
+ (not (equal col (current-column))))
+ (mc/create-fake-cursor-at-point))
+ ;; proceed to next
(if (eq direction :up)
(previous-logical-line 1 nil)
(next-logical-line 1 nil))
- [nongnu] elpa/multiple-cursors 19b1a83 160/434: Refactor mc/first-cursor-after and mc/last-cursor-before to not use extreme., (continued)
- [nongnu] elpa/multiple-cursors 19b1a83 160/434: Refactor mc/first-cursor-after and mc/last-cursor-before to not use extreme., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9ac7675 155/434: Added tests for mc/cycle-forward and mc/cycle-backward with their new looping behaviour, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors dce196c 167/434: Merge pull request #28 from gvol/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors c3b2d84 164/434: Merge pull request #23 from segv/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors be4067d 169/434: Fixed mode-line not showing up, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2345958 260/434: Run ecukes tests in --no-win mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 49027c6 262/434: Add basic tests for 'mc/mark-all-dwim', ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 61388fe 263/434: Add 'mark-all-dwim' tests for selection, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors bf4b0c6 266/434: Refactor mark-dwim tests to share a common background, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9f91a04 267/434: Add 'mc/mark-all-dwim' to README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2682e48 285/434: Merge pull request #116 from gvol/master,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 5fead7d8 286/434: Update README with @gvol contribution., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 238fb97 291/434: Add edge case scenarios which test behavior of mc/cycle-forward and mc/cycle-backward, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7b4dd88 295/434: Merge pull request #129 from jistr/readme_typo, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors bf9e8e9 309/434: Added testcase for mc-hide-unmatched-lines-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7156651 313/434: fixed documentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 19f842d 318/434: Undo after leaving mc mode will restore cursors as they was, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 40b1bad 319/434: Merge pull request #169 from lexa/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 82586a0 321/434: Consolidate contributor entries for Aleksey, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7d84398 327/434: Add missing require to mc-hide-unmatched-lines-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cec48cc 328/434: Merge pull request #188 from iqbalansari/master, ELPA Syncer, 2021/08/07