[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors 2b536cb 283/434: Added mc/edit-lines-empt
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors 2b536cb 283/434: Added mc/edit-lines-empty-lines |
Date: |
Sat, 7 Aug 2021 09:20:43 -0400 (EDT) |
branch: elpa/multiple-cursors
commit 2b536cb8b6f3bb8acc95b33c478e2d882b4c56cc
Author: Ivan Andrus <darthandrus@gmail.com>
Commit: Ivan Andrus <darthandrus@gmail.com>
Added mc/edit-lines-empty-lines
This allows mc/edit-lines to behave differently for short lines
Fixes #27
---
mc-edit-lines.el | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)
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 6a7c3c0 418/434: Fix whitespace, (continued)
- [nongnu] elpa/multiple-cursors 6a7c3c0 418/434: Fix whitespace, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b39e963 425/434: Faster line-number-at-pos calculation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cb7a145 210/434: Release 1.2.0, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 25dd14d 219/434: Add more scenarios for mark-all-*-like-this, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cc45842 241/434: Improved mc/mark-more-like-this-extended, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4535033 235/434: Added a new function mc/mark-pop that sets cursors by popping marks off the mark stack., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4748386 238/434: Make mc/mark-pop only run once per invocation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors be7905d 258/434: Update README to note that there is a mode allowing search in multiple-cursors., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors a86daa7 270/434: Guard with 'if' rather than defun*/return-from, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 18d858f 272/434: Fall straight through in 'mc/mark-all-dwim' if multiple cursors are already active, as that means we can't sensibly edit lines or mark all in region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2b536cb 283/434: Added mc/edit-lines-empty-lines,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 75ece68 288/434: Merge pull request #118 from aspiers/fix-compile-warnings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 9f4502b 304/434: Change file load timing, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e94567c 303/434: Add installation instructions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 98f2346 305/434: Merge pull request #152 from ShingoFukuyama/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 653d523 308/434: Added mc-hide-unmatched-lines mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 3f1611c 345/434: Factor out a superfluous variable, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 68961b4 355/434: Avoid requiring cl at runtime, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 4c52fb1 358/434: Merge pull request #239 from ilohmar/dwim-mouse-select, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e31b1eb 360/434: Merge pull request #240 from ilohmar/toggle-click-improvements, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6a62e60 367/434: Fix issue #131 (#247), ELPA Syncer, 2021/08/07