branch: elpa/multiple-cursors
commit 49c9f7f6bf332c89cf4071a14549f0bf005dc56f
Merge: c90bb62 2588cce
Author: Justin Dove <[email protected]>
Commit: Justin Dove <[email protected]>
Merge remote-tracking branch 'upstream/master'
---
features/vertical-align.feature | 27 +++++++++++++++++++++
mc-hide-unmatched-lines-mode.el | 2 +-
mc-mark-more.el | 52 +++++++++++++++++++----------------------
mc-separate-operations.el | 31 ++++++++++++++++++++++++
multiple-cursors-core.el | 2 +-
5 files changed, 84 insertions(+), 30 deletions(-)
diff --git a/features/vertical-align.feature b/features/vertical-align.feature
new file mode 100644
index 0000000..3a5a124
--- /dev/null
+++ b/features/vertical-align.feature
@@ -0,0 +1,27 @@
+Feature: Align cursors with whitespaces
+
+ Scenario: Vertical aligning with `x'
+ Given I have cursors at "word" in :
+ """
+ One word
+ Another word
+ """
+ And I press "<<mc/vertical-align>> \170"
+ Then I should see:
+ """
+ One xxxxword
+ Another word
+ """
+
+ Scenario: Vertical aligning with space
+ Given I have cursors at "word" in :
+ """
+ One word
+ Another word
+ """
+ And I press "<<mc/vertical-align-with-space>>"
+ Then I should see:
+ """
+ One word
+ Another word
+ """
diff --git a/mc-hide-unmatched-lines-mode.el b/mc-hide-unmatched-lines-mode.el
index 5221ef8..18e1688 100644
--- a/mc-hide-unmatched-lines-mode.el
+++ b/mc-hide-unmatched-lines-mode.el
@@ -49,7 +49,7 @@
;;;###autoload
(define-minor-mode mc-hide-unmatched-lines-mode
- "Minor mode when enabled hides all lines where no cursos (and
+ "Minor mode when enabled hides all lines where no cursors (and
also hum/lines-to-expand below and above) To make use of this
mode press \"C-'\" while multiple-cursor-mode is active. You can
still edit lines while you are in mc-hide-unmatched-lines
diff --git a/mc-mark-more.el b/mc-mark-more.el
index 0069dd3..fc8a9af 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -127,14 +127,14 @@ Use like case-fold-search, don't recommend setting it
globally.")
With negative ARG, delete the last one instead.
With zero ARG, skip the last one and mark next."
(interactive "p")
- (if (< arg 0)
- (let ((cursor (mc/furthest-cursor-after-point)))
- (if cursor
- (mc/remove-fake-cursor cursor)
- (error "No cursors to be unmarked")))
- (if (region-active-p)
- (mc/mark-more-like-this (= arg 0) 'forwards)
- (mc/mark-lines arg 'forwards)))
+ (if (region-active-p)
+ (if (< arg 0)
+ (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))
;;;###autoload
@@ -155,14 +155,14 @@ With zero ARG, skip the last one and mark next."
With negative ARG, delete the last one instead.
With zero ARG, skip the last one and mark next."
(interactive "p")
- (if (< arg 0)
- (let ((cursor (mc/furthest-cursor-before-point)))
- (if cursor
- (mc/remove-fake-cursor cursor)
- (error "No cursors to be unmarked")))
- (if (region-active-p)
- (mc/mark-more-like-this (= arg 0) 'backwards)
- (mc/mark-lines arg 'backwards)))
+ (if (region-active-p)
+ (if (< arg 0)
+ (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))
;;;###autoload
@@ -179,16 +179,12 @@ With zero ARG, skip the last one and mark next."
(defun mc/mark-lines (num-lines direction)
(dotimes (i num-lines)
- (mc/save-excursion
- (let ((furthest-cursor (ecase direction
- (forwards (mc/furthest-cursor-after-point))
- (backwards (mc/furthest-cursor-before-point)))))
- (if (overlayp furthest-cursor)
- (goto-char (overlay-get furthest-cursor 'point))))
- (ecase direction
- (forwards (next-logical-line 1 nil))
- (backwards (previous-logical-line 1 nil)))
- (mc/create-fake-cursor-at-point))))
+ (mc/create-fake-cursor-at-point)
+ (ecase direction
+ (forwards (loop do (next-logical-line 1 nil)
+ while (mc/all-fake-cursors (point) (1+ (point)))))
+ (backwards (loop do (previous-logical-line 1 nil)
+ while (mc/all-fake-cursors (point) (1+ (point))))))))
;;;###autoload
(defun mc/mark-next-lines (arg)
@@ -275,10 +271,10 @@ With zero ARG, skip the last one and mark next."
(mc/mark-all-like-this)))
;;;###autoload
-(defun mc/mark-all-in-region (beg end)
+(defun mc/mark-all-in-region (beg end &optional search)
"Find and mark all the parts in the region matching the given search"
(interactive "r")
- (let ((search (read-from-minibuffer "Mark all in region: "))
+ (let ((search (or search (read-from-minibuffer "Mark all in region: ")))
(case-fold-search nil))
(if (string= search "")
(message "Mark aborted")
diff --git a/mc-separate-operations.el b/mc-separate-operations.el
index abbfaee..b587530 100644
--- a/mc-separate-operations.el
+++ b/mc-separate-operations.el
@@ -86,5 +86,36 @@
(setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
(mc--replace-region-strings))
+
+;;;###autoload
+(defun mc/vertical-align (character)
+ "Aligns all cursors vertically with a given CHARACTER to the one with the
+highest colum number (the rightest).
+Might not behave as intended if more than one cursors are on the same line."
+ (interactive "c")
+ (let ((rightest-column (current-column)))
+ (mc/execute-command-for-all-cursors
+ (lambda () "get the rightest cursor"
+ (interactive)
+ (setq rightest-column (max (current-column) rightest-column))
+ ))
+ (mc/execute-command-for-all-cursors
+ (lambda ()
+ (interactive)
+ (let ((missing-spaces (- rightest-column (current-column))))
+ (save-excursion (insert (make-string missing-spaces character)))
+ (forward-char missing-spaces)
+ )
+ ))
+ )
+ )
+
+;;;###autoload
+(defun mc/vertical-align-with-space ()
+ "Aligns all cursors with whitespace like `mc/vertical-align' does"
+ (interactive)
+ (mc/vertical-align 32)
+ )
+
(provide 'mc-separate-operations)
;;; mc-separate-operations.el ends here
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 54a993f..8971a42 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -524,7 +524,7 @@ from being executed if in multiple-cursors-mode."
(overlay-put cursor 'kill-ring kill-ring)
(overlay-put cursor 'kill-ring-yank-pointer
kill-ring-yank-pointer)))))))
-(defvar mc/list-file "~/.emacs.d/.mc-lists.el"
+(defvar mc/list-file (locate-user-emacs-file ".mc-lists.el")
"The position of the file that keeps track of your preferences
for running commands with multiple cursors.")