Update documentation.

This commit is contained in:
Magnar Sveen 2012-09-24 13:26:55 +02:00
parent bdc4d9aff5
commit f73569fe13
3 changed files with 21 additions and 8 deletions

View File

@ -250,14 +250,14 @@ cursor with updated info."
(overlays-in (point-min) (point-max)))))
(defun mc/execute-this-command-for-all-cursors ()
"Used with post-command-hook to execute supported commands for
all cursors. It also checks a list of explicitly unsupported
commands that is prevented even for the original cursor, to
inform about the lack of support.
"Used with post-command-hook to execute supported commands for all cursors.
Commands that are neither supported nor explicitly unsupported
is executed normally for point, but skipped for the fake
cursors."
It uses two lists of commands to know what to do: the run-once
list and the run-for-all list. If a command is in neither of these lists,
it will prompt for the proper action and then save that preference.
Some commands are so unsupported that they are even prevented for
the original cursor, to inform about the lack of support."
(if (eq 1 (mc/num-cursors)) ;; no fake cursors? disable mc-mode
(multiple-cursors-mode 0)
(let ((original-command (or (command-remapping this-original-command)
@ -306,6 +306,7 @@ multiple cursors editing.")
(define-key mc/keymap (kbd "<return>") 'multiple-cursors-mode))
(defun mc--all-equal (entries)
"Are all these entries equal?"
(let ((first (car entries))
(all-equal t))
(while (and all-equal entries)
@ -314,12 +315,16 @@ multiple cursors editing.")
all-equal))
(defun mc--kill-ring-entries ()
"Return the latest kill-ring entry for each cursor.
The entries are returned in the order they are found in the buffer."
(let (entries)
(mc/for-each-cursor-ordered
(setq entries (cons (car (overlay-get cursor 'kill-ring)) entries)))
(reverse entries)))
(defun mc--maybe-set-killed-rectangle ()
"Add the latest kill-ring entry for each cursor to killed-rectangle.
So you can paste it in later with `yank-rectangle'."
(let ((entries (mc--kill-ring-entries)))
(unless (mc--all-equal entries)
(setq killed-rectangle entries))))
@ -382,6 +387,7 @@ from being executed if in multiple-cursors-mode."
for running commands with multiple cursors.")
(defun mc/save-lists ()
"Saves preferences for running commands with multiple cursors to `mc/list-file'"
(with-temp-file mc/list-file
(emacs-lisp-mode)
(insert ";; This file is automatically generated by the multiple-cursors extension.")

View File

@ -125,7 +125,6 @@
;;
;;; Code:
(require 'multiple-cursors-core)
(require 'mc-edit-lines)
(require 'mc-cycle-cursors)
(require 'mc-mark-more)

View File

@ -39,6 +39,7 @@
(define-key rectangular-region-mode-map (kbd "<return>") 'rrm/switch-to-multiple-cursors)
(defun rrm/keyboard-quit ()
"Exit rectangular-region-mode."
(interactive)
(rectangular-region-mode 0)
(rrm/remove-rectangular-region-overlays)
@ -47,12 +48,17 @@
;; Bind this to a key (for instance H-SPC) to start rectangular-region-mode
;;;###autoload
(defun set-rectangular-region-anchor ()
"Anchors the rectangular region at point.
Think of this one as `set-mark' except you're marking a rectangular region. It is
an exceedingly quick way of adding multiple cursors to multiple lines."
(interactive)
(set-marker rrm/anchor (point))
(push-mark (point))
(rectangular-region-mode 1))
(defun rrm/remove-rectangular-region-overlays ()
"Remove all rectangular-region overlays."
(mc/remove-fake-cursors)
(mapc #'(lambda (o)
(when (eq (overlay-get o 'type) 'additional-region)
@ -60,6 +66,7 @@
(overlays-in (point-min) (point-max))))
(defun rrm/repaint ()
"Start from the anchor and draw a rectangle between it and point."
(rrm/remove-rectangular-region-overlays)
(let* ((annoying-arrows-mode nil)
(point-column (current-column))
@ -83,6 +90,7 @@
(mc/create-fake-cursor-at-point)))))))
(defun rrm/switch-to-multiple-cursors (&rest forms)
"Switch from rectangular-region-mode to multiple-cursors-mode."
(interactive)
(rectangular-region-mode 0)
(multiple-cursors-mode 1))