mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 21:03:05 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
49c9f7f6bf
27
features/vertical-align.feature
Normal file
27
features/vertical-align.feature
Normal file
@ -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
|
||||
"""
|
@ -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
|
||||
|
@ -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 (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")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'forwards)
|
||||
(mc/mark-lines arg 'forwards)))
|
||||
(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 (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")))
|
||||
(if (region-active-p)
|
||||
(mc/mark-more-like-this (= arg 0) 'backwards)
|
||||
(mc/mark-lines arg 'backwards)))
|
||||
(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))))
|
||||
(mc/create-fake-cursor-at-point)
|
||||
(ecase direction
|
||||
(forwards (next-logical-line 1 nil))
|
||||
(backwards (previous-logical-line 1 nil)))
|
||||
(mc/create-fake-cursor-at-point))))
|
||||
(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")
|
||||
|
@ -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
|
||||
|
@ -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.")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user