diff options
| author | Stefan Monnier | 2015-09-01 21:14:18 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-09-01 21:14:18 -0400 |
| commit | 5dc644a6b01e2cf950ff617ab15be4bf1917c38c (patch) | |
| tree | f5572fd4d2c5cc68ac54e48fbd7541bd8043fadc | |
| parent | afe1cf00713847c1d8f3a9d95d4980d705ec39f1 (diff) | |
| download | emacs-5dc644a6b01e2cf950ff617ab15be4bf1917c38c.tar.gz emacs-5dc644a6b01e2cf950ff617ab15be4bf1917c38c.zip | |
Generalize the prefix-command machinery of C-u
* lisp/simple.el (prefix-command-echo-keystrokes-functions)
(prefix-command-preserve-state-hook): New hooks.
(internal-echo-keystrokes-prefix): New function.
(prefix-command--needs-update, prefix-command--last-echo): New vars.
(prefix-command-update, prefix-command-preserve): New functions.
(reset-this-command-lengths): New compatibility definition.
(universal-argument--mode): Call prefix-command-update.
(universal-argument, universal-argument-more, negative-argument)
(digit-argument): Call prefix-command-preserve-state.
* src/keyboard.c: Call internal-echo-keystrokes-prefix to build
the "prefix argument" to echo.
(this_command_key_count_reset, before_command_key_count)
(before_command_echo_length): Delete variables.
(echo_add_key): Always add a space.
(echo_char): Remove.
(echo_dash): Don't give up when this_command_key_count is 0, since that
is now the case after a prefix command.
(echo_update): New function, extracted from echo_now.
(echo_now): Use it.
(add_command_key, read_char, record_menu_key): Remove old disabled code.
(command_loop_1): Don't refrain from pushing an undo boundary when
prefix-arg is set. Remove other prefix-arg special case, now handled
directly in the prefix commands instead. But call echo_now if there's
a prefix state to echo.
(read_char, record_menu_key): Use echo_update instead of echo_char.
(read_key_sequence): Use echo_now rather than echo_dash/echo_char.
(Freset_this_command_lengths): Delete function.
(syms_of_keyboard): Define Qinternal_echo_keystrokes_prefix.
(syms_of_keyboard): Don't defsubr Sreset_this_command_lengths.
* lisp/simple.el: Use those new hooks for C-u.
(universal-argument--description): New function.
(prefix-command-echo-keystrokes-functions): Use it.
(universal-argument--preserve): New function.
(prefix-command-preserve-state-hook): Use it.
(command-execute): Call prefix-command-update if needed.
* lisp/kmacro.el (kmacro-step-edit-prefix-commands)
(kmacro-step-edit-prefix-index): Delete variables.
(kmacro-step-edit-query, kmacro-step-edit-insert): Remove ad-hoc
support for prefix arg commands.
(kmacro-step-edit-macro): Don't bind kmacro-step-edit-prefix-index.
* lisp/emulation/cua-base.el (cua--prefix-override-replay)
(cua--shift-control-prefix): Use prefix-command-preserve-state.
Remove now unused arg `arg'.
(cua--prefix-override-handler, cua--prefix-repeat-handler)
(cua--shift-control-c-prefix, cua--shift-control-x-prefix):
Update accordingly.
(cua--prefix-override-timeout): Don't call reset-this-command-lengths
any more.
(cua--keep-active, cua-exchange-point-and-mark): Don't set mark-active
if the mark is not set.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/emulation/cua-base.el | 53 | ||||
| -rw-r--r-- | lisp/kmacro.el | 50 | ||||
| -rw-r--r-- | lisp/simple.el | 80 | ||||
| -rw-r--r-- | src/keyboard.c | 278 |
5 files changed, 188 insertions, 277 deletions
| @@ -965,6 +965,10 @@ be updated accordingly. | |||
| 965 | 965 | ||
| 966 | * Lisp Changes in Emacs 25.1 | 966 | * Lisp Changes in Emacs 25.1 |
| 967 | 967 | ||
| 968 | ** New hooks prefix-command-echo-keystrokes-functions and | ||
| 969 | prefix-command-preserve-state-hook, to allow the definition of prefix | ||
| 970 | commands other than the predefined C-u. | ||
| 971 | |||
| 968 | ** New functions `filepos-to-bufferpos' and `bufferpos-to-filepos'. | 972 | ** New functions `filepos-to-bufferpos' and `bufferpos-to-filepos'. |
| 969 | 973 | ||
| 970 | ** The default value of `load-read-function' is now `read'. | 974 | ** The default value of `load-read-function' is now `read'. |
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index e91ce80bbe2..52e1647ede7 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -685,7 +685,7 @@ a cons (TYPE . COLOR), then both properties are affected." | |||
| 685 | (defvar cua--prefix-override-timer nil) | 685 | (defvar cua--prefix-override-timer nil) |
| 686 | (defvar cua--prefix-override-length nil) | 686 | (defvar cua--prefix-override-length nil) |
| 687 | 687 | ||
| 688 | (defun cua--prefix-override-replay (arg repeat) | 688 | (defun cua--prefix-override-replay (repeat) |
| 689 | (let* ((keys (this-command-keys)) | 689 | (let* ((keys (this-command-keys)) |
| 690 | (i (length keys)) | 690 | (i (length keys)) |
| 691 | (key (aref keys (1- i)))) | 691 | (key (aref keys (1- i)))) |
| @@ -705,21 +705,23 @@ a cons (TYPE . COLOR), then both properties are affected." | |||
| 705 | ;; Don't record this command | 705 | ;; Don't record this command |
| 706 | (setq this-command last-command) | 706 | (setq this-command last-command) |
| 707 | ;; Restore the prefix arg | 707 | ;; Restore the prefix arg |
| 708 | (setq prefix-arg arg) | 708 | ;; This should make it so that exchange-point-and-mark gets the prefix when |
| 709 | (reset-this-command-lengths) | 709 | ;; you do C-u C-x C-x C-x work (where the C-u is properly passed to the C-x |
| 710 | ;; C-x binding after the first C-x C-x was rewritten to just C-x). | ||
| 711 | (prefix-command-preserve-state) | ||
| 710 | ;; Push the key back on the event queue | 712 | ;; Push the key back on the event queue |
| 711 | (setq unread-command-events (cons key unread-command-events)))) | 713 | (setq unread-command-events (cons key unread-command-events)))) |
| 712 | 714 | ||
| 713 | (defun cua--prefix-override-handler (arg) | 715 | (defun cua--prefix-override-handler () |
| 714 | "Start timer waiting for prefix key to be followed by another key. | 716 | "Start timer waiting for prefix key to be followed by another key. |
| 715 | Repeating prefix key when region is active works as a single prefix key." | 717 | Repeating prefix key when region is active works as a single prefix key." |
| 716 | (interactive "P") | 718 | (interactive) |
| 717 | (cua--prefix-override-replay arg 0)) | 719 | (cua--prefix-override-replay 0)) |
| 718 | 720 | ||
| 719 | (defun cua--prefix-repeat-handler (arg) | 721 | (defun cua--prefix-repeat-handler () |
| 720 | "Repeating prefix key when region is active works as a single prefix key." | 722 | "Repeating prefix key when region is active works as a single prefix key." |
| 721 | (interactive "P") | 723 | (interactive) |
| 722 | (cua--prefix-override-replay arg 1)) | 724 | (cua--prefix-override-replay 1)) |
| 723 | 725 | ||
| 724 | (defun cua--prefix-copy-handler (arg) | 726 | (defun cua--prefix-copy-handler (arg) |
| 725 | "Copy region/rectangle, then replay last key." | 727 | "Copy region/rectangle, then replay last key." |
| @@ -742,7 +744,8 @@ Repeating prefix key when region is active works as a single prefix key." | |||
| 742 | (when (= (length (this-command-keys)) cua--prefix-override-length) | 744 | (when (= (length (this-command-keys)) cua--prefix-override-length) |
| 743 | (setq unread-command-events (cons 'timeout unread-command-events)) | 745 | (setq unread-command-events (cons 'timeout unread-command-events)) |
| 744 | (if prefix-arg | 746 | (if prefix-arg |
| 745 | (reset-this-command-lengths) | 747 | nil |
| 748 | ;; FIXME: Why? | ||
| 746 | (setq overriding-terminal-local-map nil)) | 749 | (setq overriding-terminal-local-map nil)) |
| 747 | (cua--select-keymaps))) | 750 | (cua--select-keymaps))) |
| 748 | 751 | ||
| @@ -755,8 +758,9 @@ Repeating prefix key when region is active works as a single prefix key." | |||
| 755 | (call-interactively this-command)) | 758 | (call-interactively this-command)) |
| 756 | 759 | ||
| 757 | (defun cua--keep-active () | 760 | (defun cua--keep-active () |
| 758 | (setq mark-active t | 761 | (when (mark t) |
| 759 | deactivate-mark nil)) | 762 | (setq mark-active t |
| 763 | deactivate-mark nil))) | ||
| 760 | 764 | ||
| 761 | (defun cua--deactivate (&optional now) | 765 | (defun cua--deactivate (&optional now) |
| 762 | (if (not now) | 766 | (if (not now) |
| @@ -944,7 +948,7 @@ See also `exchange-point-and-mark'." | |||
| 944 | (cond ((null cua-enable-cua-keys) | 948 | (cond ((null cua-enable-cua-keys) |
| 945 | (exchange-point-and-mark arg)) | 949 | (exchange-point-and-mark arg)) |
| 946 | (arg | 950 | (arg |
| 947 | (setq mark-active t)) | 951 | (when (mark t) (setq mark-active t))) |
| 948 | (t | 952 | (t |
| 949 | (let (mark-active) | 953 | (let (mark-active) |
| 950 | (exchange-point-and-mark) | 954 | (exchange-point-and-mark) |
| @@ -1212,25 +1216,28 @@ If ARG is the atom `-', scroll upward by nearly full screen." | |||
| 1212 | 1216 | ||
| 1213 | (defvar cua--keymaps-initialized nil) | 1217 | (defvar cua--keymaps-initialized nil) |
| 1214 | 1218 | ||
| 1215 | (defun cua--shift-control-prefix (prefix arg) | 1219 | (defun cua--shift-control-prefix (prefix) |
| 1216 | ;; handle S-C-x and S-C-c by emulating the fast double prefix function. | 1220 | ;; handle S-C-x and S-C-c by emulating the fast double prefix function. |
| 1217 | ;; Don't record this command | 1221 | ;; Don't record this command |
| 1218 | (setq this-command last-command) | 1222 | (setq this-command last-command) |
| 1219 | ;; Restore the prefix arg | 1223 | ;; Restore the prefix arg |
| 1220 | (setq prefix-arg arg) | 1224 | ;; This should make it so that exchange-point-and-mark gets the prefix when |
| 1221 | (reset-this-command-lengths) | 1225 | ;; you do C-u S-C-x C-x work (where the C-u is properly passed to the C-x |
| 1226 | ;; C-x binding after the first S-C-x was rewritten to just C-x). | ||
| 1227 | (prefix-command-preserve-state) | ||
| 1222 | ;; Activate the cua--prefix-repeat-keymap | 1228 | ;; Activate the cua--prefix-repeat-keymap |
| 1223 | (setq cua--prefix-override-timer 'shift) | 1229 | (setq cua--prefix-override-timer 'shift) |
| 1224 | ;; Push duplicate keys back on the event queue | 1230 | ;; Push duplicate keys back on the event queue |
| 1225 | (setq unread-command-events (cons prefix (cons prefix unread-command-events)))) | 1231 | (setq unread-command-events |
| 1232 | (cons prefix (cons prefix unread-command-events)))) | ||
| 1226 | 1233 | ||
| 1227 | (defun cua--shift-control-c-prefix (arg) | 1234 | (defun cua--shift-control-c-prefix () |
| 1228 | (interactive "P") | 1235 | (interactive) |
| 1229 | (cua--shift-control-prefix ?\C-c arg)) | 1236 | (cua--shift-control-prefix ?\C-c)) |
| 1230 | 1237 | ||
| 1231 | (defun cua--shift-control-x-prefix (arg) | 1238 | (defun cua--shift-control-x-prefix () |
| 1232 | (interactive "P") | 1239 | (interactive) |
| 1233 | (cua--shift-control-prefix ?\C-x arg)) | 1240 | (cua--shift-control-prefix ?\C-x)) |
| 1234 | 1241 | ||
| 1235 | (defun cua--init-keymaps () | 1242 | (defun cua--init-keymaps () |
| 1236 | ;; Cache actual rectangle modifier key. | 1243 | ;; Cache actual rectangle modifier key. |
diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 9636a36b1e2..ddf3005bab5 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el | |||
| @@ -941,7 +941,6 @@ without repeating the prefix." | |||
| 941 | (defvar kmacro-step-edit-inserting) ;; inserting into macro | 941 | (defvar kmacro-step-edit-inserting) ;; inserting into macro |
| 942 | (defvar kmacro-step-edit-appending) ;; append to end of macro | 942 | (defvar kmacro-step-edit-appending) ;; append to end of macro |
| 943 | (defvar kmacro-step-edit-replace) ;; replace orig macro when done | 943 | (defvar kmacro-step-edit-replace) ;; replace orig macro when done |
| 944 | (defvar kmacro-step-edit-prefix-index) ;; index of first prefix arg key | ||
| 945 | (defvar kmacro-step-edit-key-index) ;; index of current key | 944 | (defvar kmacro-step-edit-key-index) ;; index of current key |
| 946 | (defvar kmacro-step-edit-action) ;; automatic action on next pre-command hook | 945 | (defvar kmacro-step-edit-action) ;; automatic action on next pre-command hook |
| 947 | (defvar kmacro-step-edit-help) ;; kmacro step edit help enabled | 946 | (defvar kmacro-step-edit-help) ;; kmacro step edit help enabled |
| @@ -976,11 +975,6 @@ This keymap is an extension to the `query-replace-map', allowing the | |||
| 976 | following additional answers: `insert', `insert-1', `replace', `replace-1', | 975 | following additional answers: `insert', `insert-1', `replace', `replace-1', |
| 977 | `append', `append-end', `act-repeat', `skip-end', `skip-keep'.") | 976 | `append', `append-end', `act-repeat', `skip-end', `skip-keep'.") |
| 978 | 977 | ||
| 979 | (defvar kmacro-step-edit-prefix-commands | ||
| 980 | '(universal-argument universal-argument-more universal-argument-minus | ||
| 981 | digit-argument negative-argument) | ||
| 982 | "Commands which build up a prefix arg for the current command.") | ||
| 983 | |||
| 984 | (defun kmacro-step-edit-prompt (macro index) | 978 | (defun kmacro-step-edit-prompt (macro index) |
| 985 | ;; Show step-edit prompt | 979 | ;; Show step-edit prompt |
| 986 | (let ((keys (and (not kmacro-step-edit-appending) | 980 | (let ((keys (and (not kmacro-step-edit-appending) |
| @@ -1084,21 +1078,13 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 1084 | ;; Handle prefix arg, or query user | 1078 | ;; Handle prefix arg, or query user |
| 1085 | (cond | 1079 | (cond |
| 1086 | (act act) ;; set above | 1080 | (act act) ;; set above |
| 1087 | ((memq this-command kmacro-step-edit-prefix-commands) | ||
| 1088 | (unless kmacro-step-edit-prefix-index | ||
| 1089 | (setq kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) | ||
| 1090 | (setq act 'universal-argument)) | ||
| 1091 | ((eq this-command 'universal-argument-other-key) | ||
| 1092 | (setq act 'universal-argument)) | ||
| 1093 | (t | 1081 | (t |
| 1094 | (kmacro-step-edit-prompt macro (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) | 1082 | (kmacro-step-edit-prompt macro kmacro-step-edit-key-index) |
| 1095 | (setq act (lookup-key kmacro-step-edit-map | 1083 | (setq act (lookup-key kmacro-step-edit-map |
| 1096 | (vector (with-current-buffer (current-buffer) (read-event)))))))) | 1084 | (vector (with-current-buffer (current-buffer) (read-event)))))))) |
| 1097 | 1085 | ||
| 1098 | ;; Resume macro execution and perform the action | 1086 | ;; Resume macro execution and perform the action |
| 1099 | (cond | 1087 | (cond |
| 1100 | ((eq act 'universal-argument) | ||
| 1101 | nil) | ||
| 1102 | ((cond | 1088 | ((cond |
| 1103 | ((eq act 'act) | 1089 | ((eq act 'act) |
| 1104 | t) | 1090 | t) |
| @@ -1110,7 +1096,6 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 1110 | (setq kmacro-step-edit-active 'ignore) | 1096 | (setq kmacro-step-edit-active 'ignore) |
| 1111 | nil) | 1097 | nil) |
| 1112 | ((eq act 'skip) | 1098 | ((eq act 'skip) |
| 1113 | (setq kmacro-step-edit-prefix-index nil) | ||
| 1114 | nil) | 1099 | nil) |
| 1115 | ((eq act 'skip-keep) | 1100 | ((eq act 'skip-keep) |
| 1116 | (setq this-command 'ignore) | 1101 | (setq this-command 'ignore) |
| @@ -1123,12 +1108,11 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 1123 | (setq act t) | 1108 | (setq act t) |
| 1124 | t) | 1109 | t) |
| 1125 | ((member act '(insert-1 insert)) | 1110 | ((member act '(insert-1 insert)) |
| 1126 | (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) | 1111 | (setq executing-kbd-macro-index kmacro-step-edit-key-index) |
| 1127 | (setq kmacro-step-edit-inserting (if (eq act 'insert-1) 1 t)) | 1112 | (setq kmacro-step-edit-inserting (if (eq act 'insert-1) 1 t)) |
| 1128 | nil) | 1113 | nil) |
| 1129 | ((member act '(replace-1 replace)) | 1114 | ((member act '(replace-1 replace)) |
| 1130 | (setq kmacro-step-edit-inserting (if (eq act 'replace-1) 1 t)) | 1115 | (setq kmacro-step-edit-inserting (if (eq act 'replace-1) 1 t)) |
| 1131 | (setq kmacro-step-edit-prefix-index nil) | ||
| 1132 | (if (= executing-kbd-macro-index (length executing-kbd-macro)) | 1116 | (if (= executing-kbd-macro-index (length executing-kbd-macro)) |
| 1133 | (setq executing-kbd-macro (vconcat executing-kbd-macro [nil]) | 1117 | (setq executing-kbd-macro (vconcat executing-kbd-macro [nil]) |
| 1134 | kmacro-step-edit-appending t)) | 1118 | kmacro-step-edit-appending t)) |
| @@ -1148,19 +1132,19 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 1148 | (setq act t) | 1132 | (setq act t) |
| 1149 | t) | 1133 | t) |
| 1150 | ((eq act 'help) | 1134 | ((eq act 'help) |
| 1151 | (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) | 1135 | (setq executing-kbd-macro-index kmacro-step-edit-key-index) |
| 1152 | (setq kmacro-step-edit-help (not kmacro-step-edit-help)) | 1136 | (setq kmacro-step-edit-help (not kmacro-step-edit-help)) |
| 1153 | nil) | 1137 | nil) |
| 1154 | (t ;; Ignore unknown responses | 1138 | (t ;; Ignore unknown responses |
| 1155 | (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) | 1139 | (setq executing-kbd-macro-index kmacro-step-edit-key-index) |
| 1156 | nil)) | 1140 | nil)) |
| 1157 | (if (> executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index)) | 1141 | (if (> executing-kbd-macro-index kmacro-step-edit-key-index) |
| 1158 | (setq kmacro-step-edit-new-macro | 1142 | (setq kmacro-step-edit-new-macro |
| 1159 | (vconcat kmacro-step-edit-new-macro | 1143 | (vconcat kmacro-step-edit-new-macro |
| 1160 | (substring executing-kbd-macro | 1144 | (substring executing-kbd-macro |
| 1161 | (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index) | 1145 | kmacro-step-edit-key-index |
| 1162 | (if (eq act t) nil executing-kbd-macro-index))) | 1146 | (if (eq act t) nil |
| 1163 | kmacro-step-edit-prefix-index nil)) | 1147 | executing-kbd-macro-index))))) |
| 1164 | (if restore-index | 1148 | (if restore-index |
| 1165 | (setq executing-kbd-macro-index restore-index))) | 1149 | (setq executing-kbd-macro-index restore-index))) |
| 1166 | (t | 1150 | (t |
| @@ -1175,12 +1159,10 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 1175 | (executing-kbd-macro nil) | 1159 | (executing-kbd-macro nil) |
| 1176 | (defining-kbd-macro nil) | 1160 | (defining-kbd-macro nil) |
| 1177 | cmd keys next-index) | 1161 | cmd keys next-index) |
| 1178 | (setq executing-kbd-macro-index (or kmacro-step-edit-prefix-index kmacro-step-edit-key-index) | 1162 | (setq executing-kbd-macro-index kmacro-step-edit-key-index) |
| 1179 | kmacro-step-edit-prefix-index nil) | ||
| 1180 | (kmacro-step-edit-prompt macro nil) | 1163 | (kmacro-step-edit-prompt macro nil) |
| 1181 | ;; Now, we have read a key sequence from the macro, but we don't want | 1164 | ;; Now, we have read a key sequence from the macro, but we don't want |
| 1182 | ;; to execute it yet. So push it back and read another sequence. | 1165 | ;; to execute it yet. So push it back and read another sequence. |
| 1183 | (reset-this-command-lengths) | ||
| 1184 | (setq keys (read-key-sequence nil nil nil nil t)) | 1166 | (setq keys (read-key-sequence nil nil nil nil t)) |
| 1185 | (setq cmd (key-binding keys t nil)) | 1167 | (setq cmd (key-binding keys t nil)) |
| 1186 | (if (cond | 1168 | (if (cond |
| @@ -1201,25 +1183,12 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 1201 | unread-command-events nil))) | 1183 | unread-command-events nil))) |
| 1202 | (setq cmd 'ignore) | 1184 | (setq cmd 'ignore) |
| 1203 | nil) | 1185 | nil) |
| 1204 | ((memq cmd kmacro-step-edit-prefix-commands) | ||
| 1205 | (reset-this-command-lengths) | ||
| 1206 | nil) | ||
| 1207 | ((eq cmd 'universal-argument-other-key) | ||
| 1208 | (setq kmacro-step-edit-action t) | ||
| 1209 | (reset-this-command-lengths) | ||
| 1210 | (if (numberp kmacro-step-edit-inserting) | ||
| 1211 | (setq kmacro-step-edit-inserting nil)) | ||
| 1212 | nil) | ||
| 1213 | ((numberp kmacro-step-edit-inserting) | 1186 | ((numberp kmacro-step-edit-inserting) |
| 1214 | (setq kmacro-step-edit-inserting nil) | 1187 | (setq kmacro-step-edit-inserting nil) |
| 1215 | nil) | 1188 | nil) |
| 1216 | ((equal keys "\C-j") | 1189 | ((equal keys "\C-j") |
| 1217 | (setq kmacro-step-edit-inserting nil) | 1190 | (setq kmacro-step-edit-inserting nil) |
| 1218 | (setq kmacro-step-edit-action nil) | 1191 | (setq kmacro-step-edit-action nil) |
| 1219 | ;; Forget any (partial) prefix arg from next command | ||
| 1220 | (setq kmacro-step-edit-prefix-index nil) | ||
| 1221 | (reset-this-command-lengths) | ||
| 1222 | (setq overriding-terminal-local-map nil) | ||
| 1223 | (setq next-index kmacro-step-edit-key-index) | 1192 | (setq next-index kmacro-step-edit-key-index) |
| 1224 | t) | 1193 | t) |
| 1225 | (t nil)) | 1194 | (t nil)) |
| @@ -1278,7 +1247,6 @@ To customize possible responses, change the \"bindings\" in `kmacro-step-edit-ma | |||
| 1278 | (kmacro-step-edit-inserting nil) | 1247 | (kmacro-step-edit-inserting nil) |
| 1279 | (kmacro-step-edit-appending nil) | 1248 | (kmacro-step-edit-appending nil) |
| 1280 | (kmacro-step-edit-replace t) | 1249 | (kmacro-step-edit-replace t) |
| 1281 | (kmacro-step-edit-prefix-index nil) | ||
| 1282 | (kmacro-step-edit-key-index 0) | 1250 | (kmacro-step-edit-key-index 0) |
| 1283 | (kmacro-step-edit-action nil) | 1251 | (kmacro-step-edit-action nil) |
| 1284 | (kmacro-step-edit-help nil) | 1252 | (kmacro-step-edit-help nil) |
diff --git a/lisp/simple.el b/lisp/simple.el index 6f76d755292..b8d4e741775 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1711,9 +1711,13 @@ The argument SPECIAL, if non-nil, means that this command is executing | |||
| 1711 | a special event, so ignore the prefix argument and don't clear it." | 1711 | a special event, so ignore the prefix argument and don't clear it." |
| 1712 | (setq debug-on-next-call nil) | 1712 | (setq debug-on-next-call nil) |
| 1713 | (let ((prefixarg (unless special | 1713 | (let ((prefixarg (unless special |
| 1714 | ;; FIXME: This should probably be done around | ||
| 1715 | ;; pre-command-hook rather than here! | ||
| 1714 | (prog1 prefix-arg | 1716 | (prog1 prefix-arg |
| 1715 | (setq current-prefix-arg prefix-arg) | 1717 | (setq current-prefix-arg prefix-arg) |
| 1716 | (setq prefix-arg nil))))) | 1718 | (setq prefix-arg nil) |
| 1719 | (when current-prefix-arg | ||
| 1720 | (prefix-command-update)))))) | ||
| 1717 | (if (and (symbolp cmd) | 1721 | (if (and (symbolp cmd) |
| 1718 | (get cmd 'disabled) | 1722 | (get cmd 'disabled) |
| 1719 | disabled-command-function) | 1723 | disabled-command-function) |
| @@ -3626,6 +3630,73 @@ see other processes running on the system, use `list-system-processes'." | |||
| 3626 | (display-buffer buffer) | 3630 | (display-buffer buffer) |
| 3627 | nil) | 3631 | nil) |
| 3628 | 3632 | ||
| 3633 | ;;;; Prefix commands | ||
| 3634 | |||
| 3635 | (setq prefix-command--needs-update nil) | ||
| 3636 | (setq prefix-command--last-echo nil) | ||
| 3637 | |||
| 3638 | (defun internal-echo-keystrokes-prefix () | ||
| 3639 | ;; BEWARE: Called directly from the C code. | ||
| 3640 | (if (not prefix-command--needs-update) | ||
| 3641 | prefix-command--last-echo | ||
| 3642 | (setq prefix-command--last-echo | ||
| 3643 | (let ((strs nil)) | ||
| 3644 | (run-hook-wrapped 'prefix-command-echo-keystrokes-functions | ||
| 3645 | (lambda (fun) (push (funcall fun) strs))) | ||
| 3646 | (setq strs (delq nil strs)) | ||
| 3647 | (when strs (mapconcat #'identity strs " ")))))) | ||
| 3648 | |||
| 3649 | (defvar prefix-command-echo-keystrokes-functions nil | ||
| 3650 | "Abnormal hook which constructs the description of the current prefix state. | ||
| 3651 | Each function is called with no argument, should return a string or nil.") | ||
| 3652 | |||
| 3653 | (defun prefix-command-update () | ||
| 3654 | "Update state of prefix commands. | ||
| 3655 | Call it whenever you change the \"prefix command state\"." | ||
| 3656 | (setq prefix-command--needs-update t)) | ||
| 3657 | |||
| 3658 | (defvar prefix-command-preserve-state-hook nil | ||
| 3659 | "Normal hook run when a command needs to preserve the prefix.") | ||
| 3660 | |||
| 3661 | (defun prefix-command-preserve-state () | ||
| 3662 | "Pass the current prefix command state to the next command. | ||
| 3663 | Should be called by all prefix commands. | ||
| 3664 | Runs `prefix-command-preserve-state-hook'." | ||
| 3665 | (run-hooks 'prefix-command-preserve-state-hook) | ||
| 3666 | ;; If the current command is a prefix command, we don't want the next (real) | ||
| 3667 | ;; command to have `last-command' set to, say, `universal-argument'. | ||
| 3668 | (setq this-command last-command) | ||
| 3669 | (setq real-this-command real-last-command) | ||
| 3670 | (prefix-command-update)) | ||
| 3671 | |||
| 3672 | (defun reset-this-command-lengths () | ||
| 3673 | (declare (obsolete prefix-command-preserve-state "25.1")) | ||
| 3674 | nil) | ||
| 3675 | |||
| 3676 | ;;;;; The main prefix command. | ||
| 3677 | |||
| 3678 | ;; FIXME: Declaration of `prefix-arg' should be moved here!? | ||
| 3679 | |||
| 3680 | (add-hook 'prefix-command-echo-keystrokes-functions | ||
| 3681 | #'universal-argument--description) | ||
| 3682 | (defun universal-argument--description () | ||
| 3683 | (when prefix-arg | ||
| 3684 | (concat "C-u" | ||
| 3685 | (pcase prefix-arg | ||
| 3686 | (`(-) " -") | ||
| 3687 | (`(,(and (pred integerp) n)) | ||
| 3688 | (let ((str "")) | ||
| 3689 | (while (and (> n 4) (= (mod n 4) 0)) | ||
| 3690 | (setq str (concat str " C-u")) | ||
| 3691 | (setq n (/ n 4))) | ||
| 3692 | (if (= n 4) str (format " %s" prefix-arg)))) | ||
| 3693 | (_ (format " %s" prefix-arg)))))) | ||
| 3694 | |||
| 3695 | (add-hook 'prefix-command-preserve-state-hook | ||
| 3696 | #'universal-argument--preserve) | ||
| 3697 | (defun universal-argument--preserve () | ||
| 3698 | (setq prefix-arg current-prefix-arg)) | ||
| 3699 | |||
| 3629 | (defvar universal-argument-map | 3700 | (defvar universal-argument-map |
| 3630 | (let ((map (make-sparse-keymap)) | 3701 | (let ((map (make-sparse-keymap)) |
| 3631 | (universal-argument-minus | 3702 | (universal-argument-minus |
| @@ -3664,7 +3735,8 @@ see other processes running on the system, use `list-system-processes'." | |||
| 3664 | "Keymap used while processing \\[universal-argument].") | 3735 | "Keymap used while processing \\[universal-argument].") |
| 3665 | 3736 | ||
| 3666 | (defun universal-argument--mode () | 3737 | (defun universal-argument--mode () |
| 3667 | (set-transient-map universal-argument-map)) | 3738 | (prefix-command-update) |
| 3739 | (set-transient-map universal-argument-map nil)) | ||
| 3668 | 3740 | ||
| 3669 | (defun universal-argument () | 3741 | (defun universal-argument () |
| 3670 | "Begin a numeric argument for the following command. | 3742 | "Begin a numeric argument for the following command. |
| @@ -3677,6 +3749,7 @@ For some commands, just \\[universal-argument] by itself serves as a flag | |||
| 3677 | which is different in effect from any particular numeric argument. | 3749 | which is different in effect from any particular numeric argument. |
| 3678 | These commands include \\[set-mark-command] and \\[start-kbd-macro]." | 3750 | These commands include \\[set-mark-command] and \\[start-kbd-macro]." |
| 3679 | (interactive) | 3751 | (interactive) |
| 3752 | (prefix-command-preserve-state) | ||
| 3680 | (setq prefix-arg (list 4)) | 3753 | (setq prefix-arg (list 4)) |
| 3681 | (universal-argument--mode)) | 3754 | (universal-argument--mode)) |
| 3682 | 3755 | ||
| @@ -3684,6 +3757,7 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]." | |||
| 3684 | ;; A subsequent C-u means to multiply the factor by 4 if we've typed | 3757 | ;; A subsequent C-u means to multiply the factor by 4 if we've typed |
| 3685 | ;; nothing but C-u's; otherwise it means to terminate the prefix arg. | 3758 | ;; nothing but C-u's; otherwise it means to terminate the prefix arg. |
| 3686 | (interactive "P") | 3759 | (interactive "P") |
| 3760 | (prefix-command-preserve-state) | ||
| 3687 | (setq prefix-arg (if (consp arg) | 3761 | (setq prefix-arg (if (consp arg) |
| 3688 | (list (* 4 (car arg))) | 3762 | (list (* 4 (car arg))) |
| 3689 | (if (eq arg '-) | 3763 | (if (eq arg '-) |
| @@ -3695,6 +3769,7 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]." | |||
| 3695 | "Begin a negative numeric argument for the next command. | 3769 | "Begin a negative numeric argument for the next command. |
| 3696 | \\[universal-argument] following digits or minus sign ends the argument." | 3770 | \\[universal-argument] following digits or minus sign ends the argument." |
| 3697 | (interactive "P") | 3771 | (interactive "P") |
| 3772 | (prefix-command-preserve-state) | ||
| 3698 | (setq prefix-arg (cond ((integerp arg) (- arg)) | 3773 | (setq prefix-arg (cond ((integerp arg) (- arg)) |
| 3699 | ((eq arg '-) nil) | 3774 | ((eq arg '-) nil) |
| 3700 | (t '-))) | 3775 | (t '-))) |
| @@ -3704,6 +3779,7 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]." | |||
| 3704 | "Part of the numeric argument for the next command. | 3779 | "Part of the numeric argument for the next command. |
| 3705 | \\[universal-argument] following digits or minus sign ends the argument." | 3780 | \\[universal-argument] following digits or minus sign ends the argument." |
| 3706 | (interactive "P") | 3781 | (interactive "P") |
| 3782 | (prefix-command-preserve-state) | ||
| 3707 | (let* ((char (if (integerp last-command-event) | 3783 | (let* ((char (if (integerp last-command-event) |
| 3708 | last-command-event | 3784 | last-command-event |
| 3709 | (get last-command-event 'ascii-character))) | 3785 | (get last-command-event 'ascii-character))) |
diff --git a/src/keyboard.c b/src/keyboard.c index d7a533b80b7..a8b1e9828bf 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -107,10 +107,6 @@ static Lisp_Object recent_keys; | |||
| 107 | Lisp_Object this_command_keys; | 107 | Lisp_Object this_command_keys; |
| 108 | ptrdiff_t this_command_key_count; | 108 | ptrdiff_t this_command_key_count; |
| 109 | 109 | ||
| 110 | /* True after calling Freset_this_command_lengths. | ||
| 111 | Usually it is false. */ | ||
| 112 | static bool this_command_key_count_reset; | ||
| 113 | |||
| 114 | /* This vector is used as a buffer to record the events that were actually read | 110 | /* This vector is used as a buffer to record the events that were actually read |
| 115 | by read_key_sequence. */ | 111 | by read_key_sequence. */ |
| 116 | static Lisp_Object raw_keybuf; | 112 | static Lisp_Object raw_keybuf; |
| @@ -124,11 +120,6 @@ static int raw_keybuf_count; | |||
| 124 | that precede this key sequence. */ | 120 | that precede this key sequence. */ |
| 125 | static ptrdiff_t this_single_command_key_start; | 121 | static ptrdiff_t this_single_command_key_start; |
| 126 | 122 | ||
| 127 | /* Record values of this_command_key_count and echo_length () | ||
| 128 | before this command was read. */ | ||
| 129 | static ptrdiff_t before_command_key_count; | ||
| 130 | static ptrdiff_t before_command_echo_length; | ||
| 131 | |||
| 132 | #ifdef HAVE_STACK_OVERFLOW_HANDLING | 123 | #ifdef HAVE_STACK_OVERFLOW_HANDLING |
| 133 | 124 | ||
| 134 | /* For longjmp to recover from C stack overflow. */ | 125 | /* For longjmp to recover from C stack overflow. */ |
| @@ -441,10 +432,12 @@ echo_add_key (Lisp_Object c) | |||
| 441 | ptrdiff_t size = sizeof initbuf; | 432 | ptrdiff_t size = sizeof initbuf; |
| 442 | char *buffer = initbuf; | 433 | char *buffer = initbuf; |
| 443 | char *ptr = buffer; | 434 | char *ptr = buffer; |
| 444 | Lisp_Object echo_string; | 435 | Lisp_Object echo_string = KVAR (current_kboard, echo_string); |
| 445 | USE_SAFE_ALLOCA; | 436 | USE_SAFE_ALLOCA; |
| 446 | 437 | ||
| 447 | echo_string = KVAR (current_kboard, echo_string); | 438 | if (STRINGP (echo_string) && SCHARS (echo_string) > 0) |
| 439 | /* Add a space at the end as a separator between keys. */ | ||
| 440 | ptr++[0] = ' '; | ||
| 448 | 441 | ||
| 449 | /* If someone has passed us a composite event, use its head symbol. */ | 442 | /* If someone has passed us a composite event, use its head symbol. */ |
| 450 | c = EVENT_HEAD (c); | 443 | c = EVENT_HEAD (c); |
| @@ -486,48 +479,12 @@ echo_add_key (Lisp_Object c) | |||
| 486 | ptr += len; | 479 | ptr += len; |
| 487 | } | 480 | } |
| 488 | 481 | ||
| 489 | /* Replace a dash from echo_dash with a space, otherwise add a space | ||
| 490 | at the end as a separator between keys. */ | ||
| 491 | AUTO_STRING (space, " "); | ||
| 492 | if (STRINGP (echo_string) && SCHARS (echo_string) > 1) | ||
| 493 | { | ||
| 494 | Lisp_Object last_char, prev_char, idx; | ||
| 495 | |||
| 496 | idx = make_number (SCHARS (echo_string) - 2); | ||
| 497 | prev_char = Faref (echo_string, idx); | ||
| 498 | |||
| 499 | idx = make_number (SCHARS (echo_string) - 1); | ||
| 500 | last_char = Faref (echo_string, idx); | ||
| 501 | |||
| 502 | /* We test PREV_CHAR to make sure this isn't the echoing of a | ||
| 503 | minus-sign. */ | ||
| 504 | if (XINT (last_char) == '-' && XINT (prev_char) != ' ') | ||
| 505 | Faset (echo_string, idx, make_number (' ')); | ||
| 506 | else | ||
| 507 | echo_string = concat2 (echo_string, space); | ||
| 508 | } | ||
| 509 | else if (STRINGP (echo_string) && SCHARS (echo_string) > 0) | ||
| 510 | echo_string = concat2 (echo_string, space); | ||
| 511 | |||
| 512 | kset_echo_string | 482 | kset_echo_string |
| 513 | (current_kboard, | 483 | (current_kboard, |
| 514 | concat2 (echo_string, make_string (buffer, ptr - buffer))); | 484 | concat2 (echo_string, make_string (buffer, ptr - buffer))); |
| 515 | SAFE_FREE (); | 485 | SAFE_FREE (); |
| 516 | } | 486 | } |
| 517 | 487 | ||
| 518 | /* Add C to the echo string, if echoing is going on. C can be a | ||
| 519 | character or a symbol. */ | ||
| 520 | |||
| 521 | static void | ||
| 522 | echo_char (Lisp_Object c) | ||
| 523 | { | ||
| 524 | if (current_kboard->immediate_echo) | ||
| 525 | { | ||
| 526 | echo_add_key (c); | ||
| 527 | echo_now (); | ||
| 528 | } | ||
| 529 | } | ||
| 530 | |||
| 531 | /* Temporarily add a dash to the end of the echo string if it's not | 488 | /* Temporarily add a dash to the end of the echo string if it's not |
| 532 | empty, so that it serves as a mini-prompt for the very next | 489 | empty, so that it serves as a mini-prompt for the very next |
| 533 | character. */ | 490 | character. */ |
| @@ -539,9 +496,6 @@ echo_dash (void) | |||
| 539 | if (NILP (KVAR (current_kboard, echo_string))) | 496 | if (NILP (KVAR (current_kboard, echo_string))) |
| 540 | return; | 497 | return; |
| 541 | 498 | ||
| 542 | if (this_command_key_count == 0) | ||
| 543 | return; | ||
| 544 | |||
| 545 | if (!current_kboard->immediate_echo | 499 | if (!current_kboard->immediate_echo |
| 546 | && SCHARS (KVAR (current_kboard, echo_string)) == 0) | 500 | && SCHARS (KVAR (current_kboard, echo_string)) == 0) |
| 547 | return; | 501 | return; |
| @@ -574,39 +528,39 @@ echo_dash (void) | |||
| 574 | echo_now (); | 528 | echo_now (); |
| 575 | } | 529 | } |
| 576 | 530 | ||
| 577 | /* Display the current echo string, and begin echoing if not already | ||
| 578 | doing so. */ | ||
| 579 | |||
| 580 | static void | 531 | static void |
| 581 | echo_now (void) | 532 | echo_update (void) |
| 582 | { | 533 | { |
| 583 | if (!current_kboard->immediate_echo) | 534 | if (current_kboard->immediate_echo) |
| 584 | { | 535 | { |
| 585 | ptrdiff_t i; | 536 | ptrdiff_t i; |
| 586 | current_kboard->immediate_echo = true; | 537 | kset_echo_string (current_kboard, |
| 538 | call0 (Qinternal_echo_keystrokes_prefix)); | ||
| 587 | 539 | ||
| 588 | for (i = 0; i < this_command_key_count; i++) | 540 | for (i = 0; i < this_command_key_count; i++) |
| 589 | { | 541 | { |
| 590 | Lisp_Object c; | 542 | Lisp_Object c; |
| 591 | 543 | ||
| 592 | /* Set before_command_echo_length to the value that would | ||
| 593 | have been saved before the start of this subcommand in | ||
| 594 | command_loop_1, if we had already been echoing then. */ | ||
| 595 | if (i == this_single_command_key_start) | ||
| 596 | before_command_echo_length = echo_length (); | ||
| 597 | |||
| 598 | c = AREF (this_command_keys, i); | 544 | c = AREF (this_command_keys, i); |
| 599 | if (! (EVENT_HAS_PARAMETERS (c) | 545 | if (! (EVENT_HAS_PARAMETERS (c) |
| 600 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) | 546 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) |
| 601 | echo_char (c); | 547 | echo_add_key (c); |
| 602 | } | 548 | } |
| 603 | 549 | ||
| 604 | /* Set before_command_echo_length to the value that would | 550 | echo_now (); |
| 605 | have been saved before the start of this subcommand in | 551 | } |
| 606 | command_loop_1, if we had already been echoing then. */ | 552 | } |
| 607 | if (this_command_key_count == this_single_command_key_start) | 553 | |
| 608 | before_command_echo_length = echo_length (); | 554 | /* Display the current echo string, and begin echoing if not already |
| 555 | doing so. */ | ||
| 609 | 556 | ||
| 557 | static void | ||
| 558 | echo_now (void) | ||
| 559 | { | ||
| 560 | if (!current_kboard->immediate_echo) | ||
| 561 | { | ||
| 562 | current_kboard->immediate_echo = true; | ||
| 563 | echo_update (); | ||
| 610 | /* Put a dash at the end to invite the user to type more. */ | 564 | /* Put a dash at the end to invite the user to type more. */ |
| 611 | echo_dash (); | 565 | echo_dash (); |
| 612 | } | 566 | } |
| @@ -666,20 +620,6 @@ echo_truncate (ptrdiff_t nchars) | |||
| 666 | static void | 620 | static void |
| 667 | add_command_key (Lisp_Object key) | 621 | add_command_key (Lisp_Object key) |
| 668 | { | 622 | { |
| 669 | #if 0 /* Not needed after we made Freset_this_command_lengths | ||
| 670 | do the job immediately. */ | ||
| 671 | /* If reset-this-command-length was called recently, obey it now. | ||
| 672 | See the doc string of that function for an explanation of why. */ | ||
| 673 | if (before_command_restore_flag) | ||
| 674 | { | ||
| 675 | this_command_key_count = before_command_key_count_1; | ||
| 676 | if (this_command_key_count < this_single_command_key_start) | ||
| 677 | this_single_command_key_start = this_command_key_count; | ||
| 678 | echo_truncate (before_command_echo_length_1); | ||
| 679 | before_command_restore_flag = 0; | ||
| 680 | } | ||
| 681 | #endif | ||
| 682 | |||
| 683 | if (this_command_key_count >= ASIZE (this_command_keys)) | 623 | if (this_command_key_count >= ASIZE (this_command_keys)) |
| 684 | this_command_keys = larger_vector (this_command_keys, 1, -1); | 624 | this_command_keys = larger_vector (this_command_keys, 1, -1); |
| 685 | 625 | ||
| @@ -1285,10 +1225,6 @@ static void adjust_point_for_property (ptrdiff_t, bool); | |||
| 1285 | /* The last boundary auto-added to buffer-undo-list. */ | 1225 | /* The last boundary auto-added to buffer-undo-list. */ |
| 1286 | Lisp_Object last_undo_boundary; | 1226 | Lisp_Object last_undo_boundary; |
| 1287 | 1227 | ||
| 1288 | /* FIXME: This is wrong rather than test window-system, we should call | ||
| 1289 | a new set-selection, which will then dispatch to x-set-selection, or | ||
| 1290 | tty-set-selection, or w32-set-selection, ... */ | ||
| 1291 | |||
| 1292 | Lisp_Object | 1228 | Lisp_Object |
| 1293 | command_loop_1 (void) | 1229 | command_loop_1 (void) |
| 1294 | { | 1230 | { |
| @@ -1306,7 +1242,6 @@ command_loop_1 (void) | |||
| 1306 | cancel_echoing (); | 1242 | cancel_echoing (); |
| 1307 | 1243 | ||
| 1308 | this_command_key_count = 0; | 1244 | this_command_key_count = 0; |
| 1309 | this_command_key_count_reset = false; | ||
| 1310 | this_single_command_key_start = 0; | 1245 | this_single_command_key_start = 0; |
| 1311 | 1246 | ||
| 1312 | if (NILP (Vmemory_full)) | 1247 | if (NILP (Vmemory_full)) |
| @@ -1394,9 +1329,6 @@ command_loop_1 (void) | |||
| 1394 | && !NILP (Ffboundp (Qrecompute_lucid_menubar))) | 1329 | && !NILP (Ffboundp (Qrecompute_lucid_menubar))) |
| 1395 | call0 (Qrecompute_lucid_menubar); | 1330 | call0 (Qrecompute_lucid_menubar); |
| 1396 | 1331 | ||
| 1397 | before_command_key_count = this_command_key_count; | ||
| 1398 | before_command_echo_length = echo_length (); | ||
| 1399 | |||
| 1400 | Vthis_command = Qnil; | 1332 | Vthis_command = Qnil; |
| 1401 | Vreal_this_command = Qnil; | 1333 | Vreal_this_command = Qnil; |
| 1402 | Vthis_original_command = Qnil; | 1334 | Vthis_original_command = Qnil; |
| @@ -1424,7 +1356,6 @@ command_loop_1 (void) | |||
| 1424 | { | 1356 | { |
| 1425 | cancel_echoing (); | 1357 | cancel_echoing (); |
| 1426 | this_command_key_count = 0; | 1358 | this_command_key_count = 0; |
| 1427 | this_command_key_count_reset = false; | ||
| 1428 | this_single_command_key_start = 0; | 1359 | this_single_command_key_start = 0; |
| 1429 | goto finalize; | 1360 | goto finalize; |
| 1430 | } | 1361 | } |
| @@ -1509,14 +1440,13 @@ command_loop_1 (void) | |||
| 1509 | } | 1440 | } |
| 1510 | #endif | 1441 | #endif |
| 1511 | 1442 | ||
| 1512 | if (NILP (KVAR (current_kboard, Vprefix_arg))) /* FIXME: Why? --Stef */ | 1443 | { |
| 1513 | { | 1444 | Lisp_Object undo = BVAR (current_buffer, undo_list); |
| 1514 | Lisp_Object undo = BVAR (current_buffer, undo_list); | 1445 | Fundo_boundary (); |
| 1515 | Fundo_boundary (); | 1446 | last_undo_boundary |
| 1516 | last_undo_boundary | 1447 | = (EQ (undo, BVAR (current_buffer, undo_list)) |
| 1517 | = (EQ (undo, BVAR (current_buffer, undo_list)) | 1448 | ? Qnil : BVAR (current_buffer, undo_list)); |
| 1518 | ? Qnil : BVAR (current_buffer, undo_list)); | 1449 | } |
| 1519 | } | ||
| 1520 | call1 (Qcommand_execute, Vthis_command); | 1450 | call1 (Qcommand_execute, Vthis_command); |
| 1521 | 1451 | ||
| 1522 | #ifdef HAVE_WINDOW_SYSTEM | 1452 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -1544,31 +1474,23 @@ command_loop_1 (void) | |||
| 1544 | 1474 | ||
| 1545 | safe_run_hooks (Qdeferred_action_function); | 1475 | safe_run_hooks (Qdeferred_action_function); |
| 1546 | 1476 | ||
| 1547 | /* If there is a prefix argument, | 1477 | kset_last_command (current_kboard, Vthis_command); |
| 1548 | 1) We don't want Vlast_command to be ``universal-argument'' | 1478 | kset_real_last_command (current_kboard, Vreal_this_command); |
| 1549 | (that would be dumb), so don't set Vlast_command, | 1479 | if (!CONSP (last_command_event)) |
| 1550 | 2) we want to leave echoing on so that the prefix will be | 1480 | kset_last_repeatable_command (current_kboard, Vreal_this_command); |
| 1551 | echoed as part of this key sequence, so don't call | 1481 | |
| 1552 | cancel_echoing, and | 1482 | this_command_key_count = 0; |
| 1553 | 3) we want to leave this_command_key_count non-zero, so that | 1483 | this_single_command_key_start = 0; |
| 1554 | read_char will realize that it is re-reading a character, and | 1484 | |
| 1555 | not echo it a second time. | 1485 | if (current_kboard->immediate_echo |
| 1556 | 1486 | && !NILP (call0 (Qinternal_echo_keystrokes_prefix))) | |
| 1557 | If the command didn't actually create a prefix arg, | ||
| 1558 | but is merely a frame event that is transparent to prefix args, | ||
| 1559 | then the above doesn't apply. */ | ||
| 1560 | if (NILP (KVAR (current_kboard, Vprefix_arg)) | ||
| 1561 | || CONSP (last_command_event)) | ||
| 1562 | { | 1487 | { |
| 1563 | kset_last_command (current_kboard, Vthis_command); | 1488 | current_kboard->immediate_echo = false; |
| 1564 | kset_real_last_command (current_kboard, Vreal_this_command); | 1489 | /* Refresh the echo message. */ |
| 1565 | if (!CONSP (last_command_event)) | 1490 | echo_now (); |
| 1566 | kset_last_repeatable_command (current_kboard, Vreal_this_command); | ||
| 1567 | cancel_echoing (); | ||
| 1568 | this_command_key_count = 0; | ||
| 1569 | this_command_key_count_reset = false; | ||
| 1570 | this_single_command_key_start = 0; | ||
| 1571 | } | 1491 | } |
| 1492 | else | ||
| 1493 | cancel_echoing (); | ||
| 1572 | 1494 | ||
| 1573 | if (!NILP (BVAR (current_buffer, mark_active)) | 1495 | if (!NILP (BVAR (current_buffer, mark_active)) |
| 1574 | && !NILP (Vrun_hooks)) | 1496 | && !NILP (Vrun_hooks)) |
| @@ -2389,10 +2311,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2389 | 2311 | ||
| 2390 | also_record = Qnil; | 2312 | also_record = Qnil; |
| 2391 | 2313 | ||
| 2392 | #if 0 /* This was commented out as part of fixing echo for C-u left. */ | ||
| 2393 | before_command_key_count = this_command_key_count; | ||
| 2394 | before_command_echo_length = echo_length (); | ||
| 2395 | #endif | ||
| 2396 | c = Qnil; | 2314 | c = Qnil; |
| 2397 | previous_echo_area_message = Qnil; | 2315 | previous_echo_area_message = Qnil; |
| 2398 | 2316 | ||
| @@ -2471,8 +2389,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2471 | goto reread_for_input_method; | 2389 | goto reread_for_input_method; |
| 2472 | } | 2390 | } |
| 2473 | 2391 | ||
| 2474 | this_command_key_count_reset = false; | ||
| 2475 | |||
| 2476 | if (!NILP (Vexecuting_kbd_macro)) | 2392 | if (!NILP (Vexecuting_kbd_macro)) |
| 2477 | { | 2393 | { |
| 2478 | /* We set this to Qmacro; since that's not a frame, nobody will | 2394 | /* We set this to Qmacro; since that's not a frame, nobody will |
| @@ -2570,7 +2486,7 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2570 | 2486 | ||
| 2571 | (3) There's only one place in 20.x where ok_to_echo_at_next_pause | 2487 | (3) There's only one place in 20.x where ok_to_echo_at_next_pause |
| 2572 | is set to a non-null value. This is done in read_char and it is | 2488 | is set to a non-null value. This is done in read_char and it is |
| 2573 | set to echo_area_glyphs after a call to echo_char. That means | 2489 | set to echo_area_glyphs. That means |
| 2574 | ok_to_echo_at_next_pause is either null or | 2490 | ok_to_echo_at_next_pause is either null or |
| 2575 | current_kboard->echobuf with the appropriate current_kboard at | 2491 | current_kboard->echobuf with the appropriate current_kboard at |
| 2576 | that time. | 2492 | that time. |
| @@ -2674,7 +2590,8 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2674 | if (minibuf_level == 0 | 2590 | if (minibuf_level == 0 |
| 2675 | && !end_time | 2591 | && !end_time |
| 2676 | && !current_kboard->immediate_echo | 2592 | && !current_kboard->immediate_echo |
| 2677 | && this_command_key_count > 0 | 2593 | && (this_command_key_count > 0 |
| 2594 | || !NILP (call0 (Qinternal_echo_keystrokes_prefix))) | ||
| 2678 | && ! noninteractive | 2595 | && ! noninteractive |
| 2679 | && echo_keystrokes_p () | 2596 | && echo_keystrokes_p () |
| 2680 | && (/* No message. */ | 2597 | && (/* No message. */ |
| @@ -3018,7 +2935,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3018 | { | 2935 | { |
| 3019 | Lisp_Object keys; | 2936 | Lisp_Object keys; |
| 3020 | ptrdiff_t key_count; | 2937 | ptrdiff_t key_count; |
| 3021 | bool key_count_reset; | ||
| 3022 | ptrdiff_t command_key_start; | 2938 | ptrdiff_t command_key_start; |
| 3023 | ptrdiff_t count = SPECPDL_INDEX (); | 2939 | ptrdiff_t count = SPECPDL_INDEX (); |
| 3024 | 2940 | ||
| @@ -3028,20 +2944,8 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3028 | Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string); | 2944 | Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string); |
| 3029 | ptrdiff_t saved_echo_after_prompt = current_kboard->echo_after_prompt; | 2945 | ptrdiff_t saved_echo_after_prompt = current_kboard->echo_after_prompt; |
| 3030 | 2946 | ||
| 3031 | #if 0 | ||
| 3032 | if (before_command_restore_flag) | ||
| 3033 | { | ||
| 3034 | this_command_key_count = before_command_key_count_1; | ||
| 3035 | if (this_command_key_count < this_single_command_key_start) | ||
| 3036 | this_single_command_key_start = this_command_key_count; | ||
| 3037 | echo_truncate (before_command_echo_length_1); | ||
| 3038 | before_command_restore_flag = 0; | ||
| 3039 | } | ||
| 3040 | #endif | ||
| 3041 | |||
| 3042 | /* Save the this_command_keys status. */ | 2947 | /* Save the this_command_keys status. */ |
| 3043 | key_count = this_command_key_count; | 2948 | key_count = this_command_key_count; |
| 3044 | key_count_reset = this_command_key_count_reset; | ||
| 3045 | command_key_start = this_single_command_key_start; | 2949 | command_key_start = this_single_command_key_start; |
| 3046 | 2950 | ||
| 3047 | if (key_count > 0) | 2951 | if (key_count > 0) |
| @@ -3051,7 +2955,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3051 | 2955 | ||
| 3052 | /* Clear out this_command_keys. */ | 2956 | /* Clear out this_command_keys. */ |
| 3053 | this_command_key_count = 0; | 2957 | this_command_key_count = 0; |
| 3054 | this_command_key_count_reset = false; | ||
| 3055 | this_single_command_key_start = 0; | 2958 | this_single_command_key_start = 0; |
| 3056 | 2959 | ||
| 3057 | /* Now wipe the echo area. */ | 2960 | /* Now wipe the echo area. */ |
| @@ -3075,7 +2978,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3075 | /* Restore the saved echoing state | 2978 | /* Restore the saved echoing state |
| 3076 | and this_command_keys state. */ | 2979 | and this_command_keys state. */ |
| 3077 | this_command_key_count = key_count; | 2980 | this_command_key_count = key_count; |
| 3078 | this_command_key_count_reset = key_count_reset; | ||
| 3079 | this_single_command_key_start = command_key_start; | 2981 | this_single_command_key_start = command_key_start; |
| 3080 | if (key_count > 0) | 2982 | if (key_count > 0) |
| 3081 | this_command_keys = keys; | 2983 | this_command_keys = keys; |
| @@ -3141,28 +3043,23 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3141 | goto retry; | 3043 | goto retry; |
| 3142 | } | 3044 | } |
| 3143 | 3045 | ||
| 3144 | if ((! reread || this_command_key_count == 0 | 3046 | if ((! reread || this_command_key_count == 0) |
| 3145 | || this_command_key_count_reset) | ||
| 3146 | && !end_time) | 3047 | && !end_time) |
| 3147 | { | 3048 | { |
| 3148 | 3049 | ||
| 3149 | /* Don't echo mouse motion events. */ | 3050 | /* Don't echo mouse motion events. */ |
| 3150 | if (echo_keystrokes_p () | 3051 | if (! (EVENT_HAS_PARAMETERS (c) |
| 3151 | && ! (EVENT_HAS_PARAMETERS (c) | 3052 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) |
| 3152 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) | 3053 | /* Once we reread a character, echoing can happen |
| 3153 | { | 3054 | the next time we pause to read a new one. */ |
| 3154 | echo_char (c); | 3055 | ok_to_echo_at_next_pause = current_kboard; |
| 3155 | if (! NILP (also_record)) | ||
| 3156 | echo_char (also_record); | ||
| 3157 | /* Once we reread a character, echoing can happen | ||
| 3158 | the next time we pause to read a new one. */ | ||
| 3159 | ok_to_echo_at_next_pause = current_kboard; | ||
| 3160 | } | ||
| 3161 | 3056 | ||
| 3162 | /* Record this character as part of the current key. */ | 3057 | /* Record this character as part of the current key. */ |
| 3163 | add_command_key (c); | 3058 | add_command_key (c); |
| 3164 | if (! NILP (also_record)) | 3059 | if (! NILP (also_record)) |
| 3165 | add_command_key (also_record); | 3060 | add_command_key (also_record); |
| 3061 | |||
| 3062 | echo_update (); | ||
| 3166 | } | 3063 | } |
| 3167 | 3064 | ||
| 3168 | last_input_event = c; | 3065 | last_input_event = c; |
| @@ -3218,23 +3115,13 @@ record_menu_key (Lisp_Object c) | |||
| 3218 | 3115 | ||
| 3219 | record_char (c); | 3116 | record_char (c); |
| 3220 | 3117 | ||
| 3221 | #if 0 | 3118 | /* Once we reread a character, echoing can happen |
| 3222 | before_command_key_count = this_command_key_count; | 3119 | the next time we pause to read a new one. */ |
| 3223 | before_command_echo_length = echo_length (); | 3120 | ok_to_echo_at_next_pause = NULL; |
| 3224 | #endif | ||
| 3225 | |||
| 3226 | /* Don't echo mouse motion events. */ | ||
| 3227 | if (echo_keystrokes_p ()) | ||
| 3228 | { | ||
| 3229 | echo_char (c); | ||
| 3230 | |||
| 3231 | /* Once we reread a character, echoing can happen | ||
| 3232 | the next time we pause to read a new one. */ | ||
| 3233 | ok_to_echo_at_next_pause = 0; | ||
| 3234 | } | ||
| 3235 | 3121 | ||
| 3236 | /* Record this character as part of the current key. */ | 3122 | /* Record this character as part of the current key. */ |
| 3237 | add_command_key (c); | 3123 | add_command_key (c); |
| 3124 | echo_update (); | ||
| 3238 | 3125 | ||
| 3239 | /* Re-reading in the middle of a command. */ | 3126 | /* Re-reading in the middle of a command. */ |
| 3240 | last_input_event = c; | 3127 | last_input_event = c; |
| @@ -9120,11 +9007,12 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9120 | { | 9007 | { |
| 9121 | key = keybuf[t]; | 9008 | key = keybuf[t]; |
| 9122 | add_command_key (key); | 9009 | add_command_key (key); |
| 9123 | if (echo_keystrokes_p () | 9010 | if (current_kboard->immediate_echo) |
| 9124 | && current_kboard->immediate_echo) | ||
| 9125 | { | 9011 | { |
| 9126 | echo_add_key (key); | 9012 | /* Set immediate_echo to false so as to force echo_now to |
| 9127 | echo_dash (); | 9013 | redisplay (it will set immediate_echo right back to true). */ |
| 9014 | current_kboard->immediate_echo = false; | ||
| 9015 | echo_now (); | ||
| 9128 | } | 9016 | } |
| 9129 | } | 9017 | } |
| 9130 | 9018 | ||
| @@ -9788,11 +9676,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9788 | 9676 | ||
| 9789 | Better ideas? */ | 9677 | Better ideas? */ |
| 9790 | for (; t < mock_input; t++) | 9678 | for (; t < mock_input; t++) |
| 9791 | { | 9679 | add_command_key (keybuf[t]); |
| 9792 | if (echo_keystrokes_p ()) | 9680 | echo_update (); |
| 9793 | echo_char (keybuf[t]); | ||
| 9794 | add_command_key (keybuf[t]); | ||
| 9795 | } | ||
| 9796 | 9681 | ||
| 9797 | return t; | 9682 | return t; |
| 9798 | } | 9683 | } |
| @@ -9819,7 +9704,6 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, | |||
| 9819 | if (NILP (continue_echo)) | 9704 | if (NILP (continue_echo)) |
| 9820 | { | 9705 | { |
| 9821 | this_command_key_count = 0; | 9706 | this_command_key_count = 0; |
| 9822 | this_command_key_count_reset = false; | ||
| 9823 | this_single_command_key_start = 0; | 9707 | this_single_command_key_start = 0; |
| 9824 | } | 9708 | } |
| 9825 | 9709 | ||
| @@ -10076,33 +9960,6 @@ The value is always a vector. */) | |||
| 10076 | return Fvector (raw_keybuf_count, XVECTOR (raw_keybuf)->contents); | 9960 | return Fvector (raw_keybuf_count, XVECTOR (raw_keybuf)->contents); |
| 10077 | } | 9961 | } |
| 10078 | 9962 | ||
| 10079 | DEFUN ("reset-this-command-lengths", Freset_this_command_lengths, | ||
| 10080 | Sreset_this_command_lengths, 0, 0, 0, | ||
| 10081 | doc: /* Make the unread events replace the last command and echo. | ||
| 10082 | Used in `universal-argument-other-key'. | ||
| 10083 | |||
| 10084 | `universal-argument-other-key' rereads the event just typed. | ||
| 10085 | It then gets translated through `function-key-map'. | ||
| 10086 | The translated event has to replace the real events, | ||
| 10087 | both in the value of (this-command-keys) and in echoing. | ||
| 10088 | To achieve this, `universal-argument-other-key' calls | ||
| 10089 | `reset-this-command-lengths', which discards the record of reading | ||
| 10090 | these events the first time. */) | ||
| 10091 | (void) | ||
| 10092 | { | ||
| 10093 | this_command_key_count = before_command_key_count; | ||
| 10094 | if (this_command_key_count < this_single_command_key_start) | ||
| 10095 | this_single_command_key_start = this_command_key_count; | ||
| 10096 | |||
| 10097 | echo_truncate (before_command_echo_length); | ||
| 10098 | |||
| 10099 | /* Cause whatever we put into unread-command-events | ||
| 10100 | to echo as if it were being freshly read from the keyboard. */ | ||
| 10101 | this_command_key_count_reset = true; | ||
| 10102 | |||
| 10103 | return Qnil; | ||
| 10104 | } | ||
| 10105 | |||
| 10106 | DEFUN ("clear-this-command-keys", Fclear_this_command_keys, | 9963 | DEFUN ("clear-this-command-keys", Fclear_this_command_keys, |
| 10107 | Sclear_this_command_keys, 0, 1, 0, | 9964 | Sclear_this_command_keys, 0, 1, 0, |
| 10108 | doc: /* Clear out the vector that `this-command-keys' returns. | 9965 | doc: /* Clear out the vector that `this-command-keys' returns. |
| @@ -10113,7 +9970,6 @@ KEEP-RECORD is non-nil. */) | |||
| 10113 | int i; | 9970 | int i; |
| 10114 | 9971 | ||
| 10115 | this_command_key_count = 0; | 9972 | this_command_key_count = 0; |
| 10116 | this_command_key_count_reset = false; | ||
| 10117 | 9973 | ||
| 10118 | if (NILP (keep_record)) | 9974 | if (NILP (keep_record)) |
| 10119 | { | 9975 | { |
| @@ -11210,6 +11066,7 @@ syms_of_keyboard (void) | |||
| 11210 | staticpro (&raw_keybuf); | 11066 | staticpro (&raw_keybuf); |
| 11211 | 11067 | ||
| 11212 | DEFSYM (Qcommand_execute, "command-execute"); | 11068 | DEFSYM (Qcommand_execute, "command-execute"); |
| 11069 | DEFSYM (Qinternal_echo_keystrokes_prefix, "internal-echo-keystrokes-prefix"); | ||
| 11213 | 11070 | ||
| 11214 | accent_key_syms = Qnil; | 11071 | accent_key_syms = Qnil; |
| 11215 | staticpro (&accent_key_syms); | 11072 | staticpro (&accent_key_syms); |
| @@ -11253,7 +11110,6 @@ syms_of_keyboard (void) | |||
| 11253 | defsubr (&Sthis_command_keys_vector); | 11110 | defsubr (&Sthis_command_keys_vector); |
| 11254 | defsubr (&Sthis_single_command_keys); | 11111 | defsubr (&Sthis_single_command_keys); |
| 11255 | defsubr (&Sthis_single_command_raw_keys); | 11112 | defsubr (&Sthis_single_command_raw_keys); |
| 11256 | defsubr (&Sreset_this_command_lengths); | ||
| 11257 | defsubr (&Sclear_this_command_keys); | 11113 | defsubr (&Sclear_this_command_keys); |
| 11258 | defsubr (&Ssuspend_emacs); | 11114 | defsubr (&Ssuspend_emacs); |
| 11259 | defsubr (&Sabort_recursive_edit); | 11115 | defsubr (&Sabort_recursive_edit); |