Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Justin Dove 2015-06-08 09:18:33 -04:00
commit 49c9f7f6bf
5 changed files with 84 additions and 30 deletions

View 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
"""

View File

@ -49,7 +49,7 @@
;;;###autoload ;;;###autoload
(define-minor-mode mc-hide-unmatched-lines-mode (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 also hum/lines-to-expand below and above) To make use of this
mode press \"C-'\" while multiple-cursor-mode is active. You can mode press \"C-'\" while multiple-cursor-mode is active. You can
still edit lines while you are in mc-hide-unmatched-lines still edit lines while you are in mc-hide-unmatched-lines

View File

@ -127,14 +127,14 @@ Use like case-fold-search, don't recommend setting it globally.")
With negative ARG, delete the last one instead. With negative ARG, delete the last one instead.
With zero ARG, skip the last one and mark next." With zero ARG, skip the last one and mark next."
(interactive "p") (interactive "p")
(if (< arg 0) (if (region-active-p)
(let ((cursor (mc/furthest-cursor-after-point))) (if (< arg 0)
(if cursor (let ((cursor (mc/furthest-cursor-after-point)))
(mc/remove-fake-cursor cursor) (if cursor
(error "No cursors to be unmarked"))) (mc/remove-fake-cursor cursor)
(if (region-active-p) (error "No cursors to be unmarked")))
(mc/mark-more-like-this (= arg 0) 'forwards) (mc/mark-more-like-this (= arg 0) 'forwards))
(mc/mark-lines arg 'forwards))) (mc/mark-lines arg 'forwards))
(mc/maybe-multiple-cursors-mode)) (mc/maybe-multiple-cursors-mode))
;;;###autoload ;;;###autoload
@ -155,14 +155,14 @@ With zero ARG, skip the last one and mark next."
With negative ARG, delete the last one instead. With negative ARG, delete the last one instead.
With zero ARG, skip the last one and mark next." With zero ARG, skip the last one and mark next."
(interactive "p") (interactive "p")
(if (< arg 0) (if (region-active-p)
(let ((cursor (mc/furthest-cursor-before-point))) (if (< arg 0)
(if cursor (let ((cursor (mc/furthest-cursor-before-point)))
(mc/remove-fake-cursor cursor) (if cursor
(error "No cursors to be unmarked"))) (mc/remove-fake-cursor cursor)
(if (region-active-p) (error "No cursors to be unmarked")))
(mc/mark-more-like-this (= arg 0) 'backwards) (mc/mark-more-like-this (= arg 0) 'backwards))
(mc/mark-lines arg 'backwards))) (mc/mark-lines arg 'backwards))
(mc/maybe-multiple-cursors-mode)) (mc/maybe-multiple-cursors-mode))
;;;###autoload ;;;###autoload
@ -179,16 +179,12 @@ With zero ARG, skip the last one and mark next."
(defun mc/mark-lines (num-lines direction) (defun mc/mark-lines (num-lines direction)
(dotimes (i num-lines) (dotimes (i num-lines)
(mc/save-excursion (mc/create-fake-cursor-at-point)
(let ((furthest-cursor (ecase direction (ecase direction
(forwards (mc/furthest-cursor-after-point)) (forwards (loop do (next-logical-line 1 nil)
(backwards (mc/furthest-cursor-before-point))))) while (mc/all-fake-cursors (point) (1+ (point)))))
(if (overlayp furthest-cursor) (backwards (loop do (previous-logical-line 1 nil)
(goto-char (overlay-get furthest-cursor 'point)))) while (mc/all-fake-cursors (point) (1+ (point))))))))
(ecase direction
(forwards (next-logical-line 1 nil))
(backwards (previous-logical-line 1 nil)))
(mc/create-fake-cursor-at-point))))
;;;###autoload ;;;###autoload
(defun mc/mark-next-lines (arg) (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))) (mc/mark-all-like-this)))
;;;###autoload ;;;###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" "Find and mark all the parts in the region matching the given search"
(interactive "r") (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)) (case-fold-search nil))
(if (string= search "") (if (string= search "")
(message "Mark aborted") (message "Mark aborted")

View File

@ -86,5 +86,36 @@
(setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<)) (setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
(mc--replace-region-strings)) (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) (provide 'mc-separate-operations)
;;; mc-separate-operations.el ends here ;;; mc-separate-operations.el ends here

View File

@ -524,7 +524,7 @@ from being executed if in multiple-cursors-mode."
(overlay-put cursor 'kill-ring kill-ring) (overlay-put cursor 'kill-ring kill-ring)
(overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer))))))) (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 "The position of the file that keeps track of your preferences
for running commands with multiple cursors.") for running commands with multiple cursors.")