diff options
| author | Miles Bader | 2008-01-30 07:57:28 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-01-30 07:57:28 +0000 |
| commit | d235ca2ff8fab139ce797757fcb159d1e28fa7e0 (patch) | |
| tree | 96c5cd1a06a0d9dc26e8470c6eabfc032c0046f3 /lisp/repeat.el | |
| parent | 3709a060f679dba14df71ae64a0035fa2b5b3106 (diff) | |
| parent | 02cbe062bee38a6705bafb1699d77e3c44cfafcf (diff) | |
| download | emacs-d235ca2ff8fab139ce797757fcb159d1e28fa7e0.tar.gz emacs-d235ca2ff8fab139ce797757fcb159d1e28fa7e0.zip | |
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-324
Diffstat (limited to 'lisp/repeat.el')
| -rw-r--r-- | lisp/repeat.el | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/lisp/repeat.el b/lisp/repeat.el index 8e97abf32e9..fdeec47f7c4 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el | |||
| @@ -200,6 +200,14 @@ this function is always whether the value of `this-command' would've been | |||
| 200 | (defvar repeat-previous-repeated-command nil | 200 | (defvar repeat-previous-repeated-command nil |
| 201 | "The previous repeated command.") | 201 | "The previous repeated command.") |
| 202 | 202 | ||
| 203 | ;; The following variable counts repeated self-insertions. The idea is | ||
| 204 | ;; that repeating a self-insertion command and subsequently undoing it | ||
| 205 | ;; should have almost the same effect as if the characters were inserted | ||
| 206 | ;; manually. The basic difference is that we leave in one undo-boundary | ||
| 207 | ;; between the original insertion and its first repetition. | ||
| 208 | (defvar repeat-undo-count nil | ||
| 209 | "Number of self-insertions since last `undo-boundary'.") | ||
| 210 | |||
| 203 | ;;;###autoload | 211 | ;;;###autoload |
| 204 | (defun repeat (repeat-arg) | 212 | (defun repeat (repeat-arg) |
| 205 | "Repeat most recently executed command. | 213 | "Repeat most recently executed command. |
| @@ -246,12 +254,6 @@ recently executed command not bound to an input event\"." | |||
| 246 | ;; needs to be saved. | 254 | ;; needs to be saved. |
| 247 | (let ((repeat-repeat-char | 255 | (let ((repeat-repeat-char |
| 248 | (if (eq repeat-on-final-keystroke t) | 256 | (if (eq repeat-on-final-keystroke t) |
| 249 | ;; The following commented out since it's equivalent to | ||
| 250 | ;; last-comment-char (martin 2007-08-29). | ||
| 251 | ;;; ;; allow any final input event that was a character | ||
| 252 | ;;; (when (eq last-command-char | ||
| 253 | ;;; last-command-event) | ||
| 254 | ;;; last-command-char) | ||
| 255 | last-command-char | 257 | last-command-char |
| 256 | ;; allow only specified final keystrokes | 258 | ;; allow only specified final keystrokes |
| 257 | (car (memq last-command-char | 259 | (car (memq last-command-char |
| @@ -293,11 +295,22 @@ recently executed command not bound to an input event\"." | |||
| 293 | (i 0)) | 295 | (i 0)) |
| 294 | ;; Run pre- and post-command hooks for self-insertion too. | 296 | ;; Run pre- and post-command hooks for self-insertion too. |
| 295 | (run-hooks 'pre-command-hook) | 297 | (run-hooks 'pre-command-hook) |
| 298 | (cond | ||
| 299 | ((not repeat-undo-count)) | ||
| 300 | ((< repeat-undo-count 20) | ||
| 301 | ;; Don't make an undo-boundary here. | ||
| 302 | (setq repeat-undo-count (1+ repeat-undo-count))) | ||
| 303 | (t | ||
| 304 | ;; Make an undo-boundary after 20 repetitions only. | ||
| 305 | (undo-boundary) | ||
| 306 | (setq repeat-undo-count 1))) | ||
| 296 | (while (< i count) | 307 | (while (< i count) |
| 297 | (repeat-self-insert insertion) | 308 | (repeat-self-insert insertion) |
| 298 | (setq i (1+ i))) | 309 | (setq i (1+ i))) |
| 299 | (run-hooks 'post-command-hook))) | 310 | (run-hooks 'post-command-hook))) |
| 300 | (let ((indirect (indirect-function last-repeatable-command))) | 311 | (let ((indirect (indirect-function last-repeatable-command))) |
| 312 | ;; Make each repetition undo separately. | ||
| 313 | (undo-boundary) | ||
| 301 | (if (or (stringp indirect) | 314 | (if (or (stringp indirect) |
| 302 | (vectorp indirect)) | 315 | (vectorp indirect)) |
| 303 | ;; Bind real-last-command so that executing the macro does | 316 | ;; Bind real-last-command so that executing the macro does |
| @@ -314,12 +327,20 @@ recently executed command not bound to an input event\"." | |||
| 314 | ;; (only 32 repetitions are possible given the default value of 200 for | 327 | ;; (only 32 repetitions are possible given the default value of 200 for |
| 315 | ;; max-lisp-eval-depth), but if I now locally disable the repeat char I | 328 | ;; max-lisp-eval-depth), but if I now locally disable the repeat char I |
| 316 | ;; can iterate indefinitely here around a single level of recursion. | 329 | ;; can iterate indefinitely here around a single level of recursion. |
| 317 | (let (repeat-on-final-keystroke) | 330 | (let (repeat-on-final-keystroke |
| 331 | ;; Bind `undo-inhibit-record-point' to t in order to avoid | ||
| 332 | ;; recording point in `buffer-undo-list' here. We have to | ||
| 333 | ;; do this since the command loop does not set the last | ||
| 334 | ;; position of point thus confusing the point recording | ||
| 335 | ;; mechanism when inserting or deleting text. | ||
| 336 | (undo-inhibit-record-point t)) | ||
| 318 | (setq real-last-command 'repeat) | 337 | (setq real-last-command 'repeat) |
| 319 | (while (eq (read-event) repeat-repeat-char) | 338 | (setq repeat-undo-count 1) |
| 320 | ;; Make each repetition undo separately. | 339 | (unwind-protect |
| 321 | (undo-boundary) | 340 | (while (eq (read-event) repeat-repeat-char) |
| 322 | (repeat repeat-arg)) | 341 | (repeat repeat-arg)) |
| 342 | ;; Make sure `repeat-undo-count' is reset. | ||
| 343 | (setq repeat-undo-count nil)) | ||
| 323 | (setq unread-command-events (list last-input-event)))))) | 344 | (setq unread-command-events (list last-input-event)))))) |
| 324 | 345 | ||
| 325 | (defun repeat-self-insert (string) | 346 | (defun repeat-self-insert (string) |