diff options
| author | Richard M. Stallman | 1998-05-18 05:40:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-18 05:40:30 +0000 |
| commit | 9dc0cb3d106cc4e437583d7e3a0d73fb9dee1a1f (patch) | |
| tree | a3b1dba73a3c508d123540cf9a436093ea1349c0 | |
| parent | fd51b1bc2c5b4976bf820897c6b9776e26b76141 (diff) | |
| download | emacs-9dc0cb3d106cc4e437583d7e3a0d73fb9dee1a1f.tar.gz emacs-9dc0cb3d106cc4e437583d7e3a0d73fb9dee1a1f.zip | |
Customized.
(vi-self-insert): New function.
(vi-dot): Use that.
(vi-dot-insertion-function): Variable deleted.
| -rw-r--r-- | lisp/repeat.el | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/lisp/repeat.el b/lisp/repeat.el index fd2f76866c3..7cda492d1ce 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el | |||
| @@ -124,8 +124,10 @@ | |||
| 124 | 124 | ||
| 125 | ;;;;; ************************* USER OPTIONS ************************** ;;;;; | 125 | ;;;;; ************************* USER OPTIONS ************************** ;;;;; |
| 126 | 126 | ||
| 127 | (defvar vi-dot-too-dangerous '(kill-this-buffer) | 127 | (defcustom vi-dot-too-dangerous '(kill-this-buffer) |
| 128 | "Commands too dangerous to repeat with `vi-dot'.") | 128 | "Commands too dangerous to repeat with `vi-dot'." |
| 129 | :group 'convenience | ||
| 130 | :type '(repeat function)) | ||
| 129 | 131 | ||
| 130 | ;; If the last command was self-insert-command, the char to be inserted was | 132 | ;; If the last command was self-insert-command, the char to be inserted was |
| 131 | ;; obtained by that command from last-command-char, which has now been | 133 | ;; obtained by that command from last-command-char, which has now been |
| @@ -134,33 +136,15 @@ | |||
| 134 | ;; this has the disadvantage that if the user types a sequence of different | 136 | ;; this has the disadvantage that if the user types a sequence of different |
| 135 | ;; chars then invokes vi-dot, only the final char will be inserted. In vi, | 137 | ;; chars then invokes vi-dot, only the final char will be inserted. In vi, |
| 136 | ;; the dot command can reinsert the entire most-recently-inserted sequence. | 138 | ;; the dot command can reinsert the entire most-recently-inserted sequence. |
| 137 | ;; To do the same thing here, we need to extract the string to insert from | ||
| 138 | ;; the undo information, then insert a new copy in the buffer. However, the | ||
| 139 | ;; built-in `insert', which takes a string as an arg, is a little different | ||
| 140 | ;; from `self-insert-command', which takes only a prefix arg; `insert' ignores | ||
| 141 | ;; `overwrite-mode'. Emacs 19.34 has no self-insert-string. But there's | ||
| 142 | ;; one in my dotemacs.el (on the web), so if you want to, you can define that | ||
| 143 | ;; in your .emacs, & it'll Just Work, as it will in any future Emaecse that | ||
| 144 | ;; have self-insert-string. Or users can code their own | ||
| 145 | ;; insert-string-with-trumpet-fanfare and use that by customizing this: | ||
| 146 | |||
| 147 | (defvar vi-dot-insert-function | ||
| 148 | (catch t (mapcar (lambda (f) (if (fboundp f) (throw t f))) | ||
| 149 | [self-insert-string | ||
| 150 | insert])) | ||
| 151 | "Function used by `vi-dot' command to re-insert a string of characters. | ||
| 152 | In a vanilla Emacs this will default to `insert', which doesn't respect | ||
| 153 | `overwrite-mode'; customize with your own insertion function, taking a single | ||
| 154 | string as an argument, if you have one.") | ||
| 155 | 139 | ||
| 156 | (defvar vi-dot-message-function nil | 140 | (defvar vi-dot-message-function nil |
| 157 | "If non-nil, function used by `vi-dot' command to say what it's doing. | 141 | "If non-nil, function used by `vi-dot' command to say what it's doing. |
| 158 | Message is something like \"Repeating command glorp\". | 142 | Message is something like \"Repeating command glorp\". |
| 159 | To disable such messages, assign 'ignore to this variable. To customize | 143 | To disable such messages, set this variable to `ignore'. To customize |
| 160 | display, assign a function that takes one string as an arg and displays | 144 | display, assign a function that takes one string as an arg and displays |
| 161 | it however you want.") | 145 | it however you want.") |
| 162 | 146 | ||
| 163 | (defvar vi-dot-repeat-on-final-keystroke t | 147 | (defcustom vi-dot-repeat-on-final-keystroke t |
| 164 | "Allow `vi-dot' to re-execute for repeating lastchar of a key sequence. | 148 | "Allow `vi-dot' to re-execute for repeating lastchar of a key sequence. |
| 165 | If this variable is t, `vi-dot' determines what key sequence | 149 | If this variable is t, `vi-dot' determines what key sequence |
| 166 | it was invoked by, extracts the final character of that sequence, and | 150 | it was invoked by, extracts the final character of that sequence, and |
| @@ -168,7 +152,9 @@ re-executes as many times as that final character is hit; so for example | |||
| 168 | if `vi-dot' is bound to C-x z, typing C-x z z z repeats the previous command | 152 | if `vi-dot' is bound to C-x z, typing C-x z z z repeats the previous command |
| 169 | 3 times. If this variable is a sequence of characters, then re-execution | 153 | 3 times. If this variable is a sequence of characters, then re-execution |
| 170 | only occurs if the final character by which `vi-dot' was invoked is a | 154 | only occurs if the final character by which `vi-dot' was invoked is a |
| 171 | member of that sequence. If this variable is nil, no re-execution occurs.") | 155 | member of that sequence. If this variable is nil, no re-execution occurs." |
| 156 | :group 'convenience | ||
| 157 | :type 'boolean) | ||
| 172 | 158 | ||
| 173 | ;;;;; ****************** HACKS TO THE REST OF EMACS ******************* ;;;;; | 159 | ;;;;; ****************** HACKS TO THE REST OF EMACS ******************* ;;;;; |
| 174 | 160 | ||
| @@ -350,7 +336,7 @@ can be modified by the global variable `vi-dot-repeat-on-final-keystroke'." | |||
| 350 | "clobbered it, sorry"))))))) | 336 | "clobbered it, sorry"))))))) |
| 351 | (setq vi-dot-num-input-keys-at-self-insert num-input-keys) | 337 | (setq vi-dot-num-input-keys-at-self-insert num-input-keys) |
| 352 | (loop repeat (prefix-numeric-value vi-dot-arg) do | 338 | (loop repeat (prefix-numeric-value vi-dot-arg) do |
| 353 | (funcall vi-dot-insert-function insertion))) | 339 | (vi-self-insert insertion))) |
| 354 | (call-interactively last-command))) | 340 | (call-interactively last-command))) |
| 355 | (when vi-dot-repeat-char | 341 | (when vi-dot-repeat-char |
| 356 | ;; A simple recursion here gets into trouble with max-lisp-eval-depth | 342 | ;; A simple recursion here gets into trouble with max-lisp-eval-depth |
| @@ -363,6 +349,13 @@ can be modified by the global variable `vi-dot-repeat-on-final-keystroke'." | |||
| 363 | (vi-dot vi-dot-arg)) | 349 | (vi-dot vi-dot-arg)) |
| 364 | (setq unread-command-events (list last-input-event)))))) | 350 | (setq unread-command-events (list last-input-event)))))) |
| 365 | 351 | ||
| 352 | (defun vi-self-insert (string) | ||
| 353 | (let ((i 0)) | ||
| 354 | (while (< i (length string)) | ||
| 355 | (let ((last-command-char (aref string i))) | ||
| 356 | (self-insert-command 1)) | ||
| 357 | (setq i (1+ i))))) | ||
| 358 | |||
| 366 | (defun vi-dot-message (format &rest args) | 359 | (defun vi-dot-message (format &rest args) |
| 367 | "Like `message' but displays with `vi-dot-message-function' if non-nil." | 360 | "Like `message' but displays with `vi-dot-message-function' if non-nil." |
| 368 | (let ((message (apply 'format format args))) | 361 | (let ((message (apply 'format format args))) |