diff options
| author | Martin Rudalics | 2007-08-29 09:09:05 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2007-08-29 09:09:05 +0000 |
| commit | 392abfd2874f74f26d1bba4bb0fa497c55c1d5e1 (patch) | |
| tree | 9c8d0b5d62d34dac1260c1358f35a6cff6101ae2 | |
| parent | d0d3a31145231a520300d9360b74dcac60aa3930 (diff) | |
| download | emacs-392abfd2874f74f26d1bba4bb0fa497c55c1d5e1.tar.gz emacs-392abfd2874f74f26d1bba4bb0fa497c55c1d5e1.zip | |
(repeat): Use last-repeatable-command instead of
real-last-command. Run pre- and post-command hooks for
self-insertion. Update doc-string.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/repeat.el | 87 |
3 files changed, 63 insertions, 33 deletions
| @@ -81,6 +81,9 @@ in to make it use the scrollbars from the system theme. | |||
| 81 | 81 | ||
| 82 | * Lisp Changes in Emacs 22.2. | 82 | * Lisp Changes in Emacs 22.2. |
| 83 | 83 | ||
| 84 | ** The command `repeat' will no more attempt to repeat a command bound | ||
| 85 | to an input event. | ||
| 86 | |||
| 84 | ** The function invisible-p returns non-nil if the character | 87 | ** The function invisible-p returns non-nil if the character |
| 85 | after a specified position is invisible. | 88 | after a specified position is invisible. |
| 86 | 89 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b8346887ab1..a7cbdf407cb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2007-08-29 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * repeat.el (repeat): Use last-repeatable-command instead of | ||
| 4 | real-last-command. Run pre- and post-command hooks for | ||
| 5 | self-insertion. Update doc-string. | ||
| 6 | |||
| 1 | 2007-08-28 Glenn Morris <rgm@gnu.org> | 7 | 2007-08-28 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * progmodes/cc-langs.el (c-constant-kwds): Add java: true, false, | 9 | * progmodes/cc-langs.el (c-constant-kwds): Add java: true, false, |
diff --git a/lisp/repeat.el b/lisp/repeat.el index ad8c4d818f8..1a1d081b06e 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el | |||
| @@ -152,6 +152,11 @@ member of that sequence. If this variable is nil, no re-execution occurs." | |||
| 152 | ;; with auto-filling. Most problems are eliminated by remembering what we're | 152 | ;; with auto-filling. Most problems are eliminated by remembering what we're |
| 153 | ;; self-inserting, so we only need to get it from the undo information once. | 153 | ;; self-inserting, so we only need to get it from the undo information once. |
| 154 | 154 | ||
| 155 | ;; With Emacs 22.2 the variable `last-repeatable-command' stores the | ||
| 156 | ;; most recently executed command that was not bound to an input event. | ||
| 157 | ;; `repeat' now repeats that command instead of `real-last-command' to | ||
| 158 | ;; avoid a "... must be bound to an event with parameters" error. | ||
| 159 | |||
| 155 | (defvar repeat-last-self-insert nil | 160 | (defvar repeat-last-self-insert nil |
| 156 | "If last repeated command was `self-insert-command', it inserted this.") | 161 | "If last repeated command was `self-insert-command', it inserted this.") |
| 157 | 162 | ||
| @@ -198,13 +203,18 @@ this function is always whether the value of `this-command' would've been | |||
| 198 | ;;;###autoload | 203 | ;;;###autoload |
| 199 | (defun repeat (repeat-arg) | 204 | (defun repeat (repeat-arg) |
| 200 | "Repeat most recently executed command. | 205 | "Repeat most recently executed command. |
| 201 | With prefix arg, apply new prefix arg to that command; otherwise, use | 206 | With prefix arg, apply new prefix arg to that command; otherwise, |
| 202 | the prefix arg that was used before (if any). | 207 | use the prefix arg that was used before (if any). |
| 203 | This command is like the `.' command in the vi editor. | 208 | This command is like the `.' command in the vi editor. |
| 204 | 209 | ||
| 205 | If this command is invoked by a multi-character key sequence, it can then | 210 | If this command is invoked by a multi-character key sequence, it |
| 206 | be repeated by repeating the final character of that sequence. This behavior | 211 | can then be repeated by repeating the final character of that |
| 207 | can be modified by the global variable `repeat-on-final-keystroke'." | 212 | sequence. This behavior can be modified by the global variable |
| 213 | `repeat-on-final-keystroke'. | ||
| 214 | |||
| 215 | `repeat' ignores commands bound to input events. Hence the term | ||
| 216 | \"most recently executed command\" shall be read as \"most | ||
| 217 | recently executed command not bound to an input event\"." | ||
| 208 | ;; The most recently executed command could be anything, so surprises could | 218 | ;; The most recently executed command could be anything, so surprises could |
| 209 | ;; result if it were re-executed in a context where new dynamically | 219 | ;; result if it were re-executed in a context where new dynamically |
| 210 | ;; localized variables were shadowing global variables in a `let' clause in | 220 | ;; localized variables were shadowing global variables in a `let' clause in |
| @@ -214,17 +224,19 @@ can be modified by the global variable `repeat-on-final-keystroke'." | |||
| 214 | ;; "repeat-" prefix, reserved by this package, for *local* variables that | 224 | ;; "repeat-" prefix, reserved by this package, for *local* variables that |
| 215 | ;; might be visible to re-executed commands, including this function's arg. | 225 | ;; might be visible to re-executed commands, including this function's arg. |
| 216 | (interactive "P") | 226 | (interactive "P") |
| 217 | (when (eq real-last-command 'repeat) | 227 | (when (eq last-repeatable-command 'repeat) |
| 218 | (setq real-last-command repeat-previous-repeated-command)) | 228 | (setq last-repeatable-command repeat-previous-repeated-command)) |
| 219 | (when (null real-last-command) | 229 | (cond |
| 230 | ((null last-repeatable-command) | ||
| 220 | (error "There is nothing to repeat")) | 231 | (error "There is nothing to repeat")) |
| 221 | (when (eq real-last-command 'mode-exit) | 232 | ((eq last-repeatable-command 'mode-exit) |
| 222 | (error "real-last-command is mode-exit & can't be repeated")) | 233 | (error "last-repeatable-command is mode-exit & can't be repeated")) |
| 223 | (when (memq real-last-command repeat-too-dangerous) | 234 | ((memq last-repeatable-command repeat-too-dangerous) |
| 224 | (error "Command %S too dangerous to repeat automatically" real-last-command)) | 235 | (error "Command %S too dangerous to repeat automatically" |
| 225 | (setq this-command real-last-command | 236 | last-repeatable-command))) |
| 226 | repeat-num-input-keys-at-repeat num-input-keys) | 237 | (setq this-command last-repeatable-command |
| 227 | (setq repeat-previous-repeated-command this-command) | 238 | repeat-previous-repeated-command last-repeatable-command |
| 239 | repeat-num-input-keys-at-repeat num-input-keys) | ||
| 228 | (when (null repeat-arg) | 240 | (when (null repeat-arg) |
| 229 | (setq repeat-arg last-prefix-arg)) | 241 | (setq repeat-arg last-prefix-arg)) |
| 230 | ;; Now determine whether to loop on repeated taps of the final character | 242 | ;; Now determine whether to loop on repeated taps of the final character |
| @@ -234,25 +246,29 @@ can be modified by the global variable `repeat-on-final-keystroke'." | |||
| 234 | ;; needs to be saved. | 246 | ;; needs to be saved. |
| 235 | (let ((repeat-repeat-char | 247 | (let ((repeat-repeat-char |
| 236 | (if (eq repeat-on-final-keystroke t) | 248 | (if (eq repeat-on-final-keystroke t) |
| 237 | ;; allow any final input event that was a character | 249 | ;; The following commented out since it's equivalent to |
| 238 | (when (eq last-command-char | 250 | ;; last-comment-char (martin 2007-08-29). |
| 239 | last-command-event) | 251 | ;;; ;; allow any final input event that was a character |
| 240 | last-command-char) | 252 | ;;; (when (eq last-command-char |
| 253 | ;;; last-command-event) | ||
| 254 | ;;; last-command-char) | ||
| 255 | last-command-char | ||
| 241 | ;; allow only specified final keystrokes | 256 | ;; allow only specified final keystrokes |
| 242 | (car (memq last-command-char | 257 | (car (memq last-command-char |
| 243 | (listify-key-sequence | 258 | (listify-key-sequence |
| 244 | repeat-on-final-keystroke)))))) | 259 | repeat-on-final-keystroke)))))) |
| 245 | (if (memq real-last-command '(exit-minibuffer | 260 | (if (memq last-repeatable-command '(exit-minibuffer |
| 246 | minibuffer-complete-and-exit | 261 | minibuffer-complete-and-exit |
| 247 | self-insert-and-exit)) | 262 | self-insert-and-exit)) |
| 248 | (let ((repeat-command (car command-history))) | 263 | (let ((repeat-command (car command-history))) |
| 249 | (repeat-message "Repeating %S" repeat-command) | 264 | (repeat-message "Repeating %S" repeat-command) |
| 250 | (eval repeat-command)) | 265 | (eval repeat-command)) |
| 251 | (if (null repeat-arg) | 266 | (if (null repeat-arg) |
| 252 | (repeat-message "Repeating command %S" real-last-command) | 267 | (repeat-message "Repeating command %S" last-repeatable-command) |
| 253 | (setq current-prefix-arg repeat-arg) | 268 | (setq current-prefix-arg repeat-arg) |
| 254 | (repeat-message "Repeating command %S %S" repeat-arg real-last-command)) | 269 | (repeat-message |
| 255 | (if (eq real-last-command 'self-insert-command) | 270 | "Repeating command %S %S" repeat-arg last-repeatable-command)) |
| 271 | (if (eq last-repeatable-command 'self-insert-command) | ||
| 256 | (let ((insertion | 272 | (let ((insertion |
| 257 | (if (<= (- num-input-keys | 273 | (if (<= (- num-input-keys |
| 258 | repeat-num-input-keys-at-self-insert) | 274 | repeat-num-input-keys-at-self-insert) |
| @@ -275,18 +291,22 @@ can be modified by the global variable `repeat-on-final-keystroke'." | |||
| 275 | (setq insertion (substring insertion -1)) | 291 | (setq insertion (substring insertion -1)) |
| 276 | (let ((count (prefix-numeric-value repeat-arg)) | 292 | (let ((count (prefix-numeric-value repeat-arg)) |
| 277 | (i 0)) | 293 | (i 0)) |
| 294 | ;; Run pre- and post-command hooks for self-insertion too. | ||
| 295 | (run-hooks 'pre-command-hook) | ||
| 278 | (while (< i count) | 296 | (while (< i count) |
| 279 | (repeat-self-insert insertion) | 297 | (repeat-self-insert insertion) |
| 280 | (setq i (1+ i))))) | 298 | (setq i (1+ i))) |
| 281 | (let ((indirect (indirect-function real-last-command))) | 299 | (run-hooks 'post-command-hook))) |
| 300 | (let ((indirect (indirect-function last-repeatable-command))) | ||
| 282 | (if (or (stringp indirect) | 301 | (if (or (stringp indirect) |
| 283 | (vectorp indirect)) | 302 | (vectorp indirect)) |
| 284 | ;; Bind real-last-command so that executing the macro | 303 | ;; Bind real-last-command so that executing the macro does |
| 285 | ;; does not alter it. | 304 | ;; not alter it. Do the same for last-repeatable-command. |
| 286 | (let ((real-last-command real-last-command)) | 305 | (let ((real-last-command real-last-command) |
| 287 | (execute-kbd-macro real-last-command)) | 306 | (last-repeatable-command last-repeatable-command)) |
| 307 | (execute-kbd-macro last-repeatable-command)) | ||
| 288 | (run-hooks 'pre-command-hook) | 308 | (run-hooks 'pre-command-hook) |
| 289 | (call-interactively real-last-command) | 309 | (call-interactively last-repeatable-command) |
| 290 | (run-hooks 'post-command-hook))))) | 310 | (run-hooks 'post-command-hook))))) |
| 291 | (when repeat-repeat-char | 311 | (when repeat-repeat-char |
| 292 | ;; A simple recursion here gets into trouble with max-lisp-eval-depth | 312 | ;; A simple recursion here gets into trouble with max-lisp-eval-depth |
| @@ -295,6 +315,7 @@ can be modified by the global variable `repeat-on-final-keystroke'." | |||
| 295 | ;; max-lisp-eval-depth), but if I now locally disable the repeat char I | 315 | ;; max-lisp-eval-depth), but if I now locally disable the repeat char I |
| 296 | ;; can iterate indefinitely here around a single level of recursion. | 316 | ;; can iterate indefinitely here around a single level of recursion. |
| 297 | (let (repeat-on-final-keystroke) | 317 | (let (repeat-on-final-keystroke) |
| 318 | (setq real-last-command 'repeat) | ||
| 298 | (while (eq (read-event) repeat-repeat-char) | 319 | (while (eq (read-event) repeat-repeat-char) |
| 299 | ;; Make each repetition undo separately. | 320 | ;; Make each repetition undo separately. |
| 300 | (undo-boundary) | 321 | (undo-boundary) |