diff options
| author | Stefan Monnier | 2019-12-20 17:34:38 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2019-12-20 17:34:38 -0500 |
| commit | 0f7e3430bba031a6c5f45e0afe2ddcac197603cf (patch) | |
| tree | 34c14495d9e17d4a674bb57563980c507084b47f /lisp | |
| parent | 2c8f1539ab0a2d8b6b2bb9982249c5aa2dbd27b1 (diff) | |
| download | emacs-0f7e3430bba031a6c5f45e0afe2ddcac197603cf.tar.gz emacs-0f7e3430bba031a6c5f45e0afe2ddcac197603cf.zip | |
* lisp/international/mule-cmds.el: Fix bug#38642
(universal-coding-system-argument): Adjust the code to the way
`universal-argument` works nowadays. Handle `prefix-arg` a bit more
like `command_loop` does.
* test/lisp/international/mule-tests.el
(mule-cmds--test-universal-coding-system-argument): New test.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/international/mule-cmds.el | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index e4f5bb2a5f0..0a8a4aa6610 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -295,10 +295,14 @@ wrong, use this command again to toggle back to the right mode." | |||
| 295 | (format "Coding system for following command (default %s): " default) | 295 | (format "Coding system for following command (default %s): " default) |
| 296 | "Coding system for following command: ") | 296 | "Coding system for following command: ") |
| 297 | default)))) | 297 | default)))) |
| 298 | ;; FIXME: This "read-key-sequence + call-interactively" loop is trying to | ||
| 299 | ;; reproduce the normal command loop, but this "can't" be done faithfully so | ||
| 300 | ;; it necessarily suffers from breakage in corner cases (e.g. it fails to run | ||
| 301 | ;; pre/post-command-hook, doesn't properly set this-command/last-command, it | ||
| 302 | ;; doesn't handle keyboard macros, ...). | ||
| 298 | (let* ((keyseq (read-key-sequence | 303 | (let* ((keyseq (read-key-sequence |
| 299 | (format "Command to execute with %s:" coding-system))) | 304 | (format "Command to execute with %s:" coding-system))) |
| 300 | (cmd (key-binding keyseq)) | 305 | (cmd (key-binding keyseq))) |
| 301 | prefix) | ||
| 302 | ;; read-key-sequence ignores quit, so make an explicit check. | 306 | ;; read-key-sequence ignores quit, so make an explicit check. |
| 303 | (if (equal last-input-event (nth 3 (current-input-mode))) | 307 | (if (equal last-input-event (nth 3 (current-input-mode))) |
| 304 | (keyboard-quit)) | 308 | (keyboard-quit)) |
| @@ -309,28 +313,21 @@ wrong, use this command again to toggle back to the right mode." | |||
| 309 | (while (progn | 313 | (while (progn |
| 310 | (setq keyseq (read-key-sequence nil t) | 314 | (setq keyseq (read-key-sequence nil t) |
| 311 | cmd (key-binding keyseq t)) | 315 | cmd (key-binding keyseq t)) |
| 312 | (not (eq cmd 'universal-argument-other-key))) | 316 | (memq cmd '(negative-argument digit-argument |
| 313 | (let ((current-prefix-arg prefix-arg) | 317 | universal-argument-more))) |
| 314 | ;; Have to bind `last-command-event' here so that | 318 | (setq current-prefix-arg prefix-arg prefix-arg nil) |
| 315 | ;; `digit-argument', for instance, can compute the | 319 | ;; Have to bind `last-command-event' here so that |
| 316 | ;; `prefix-arg'. | 320 | ;; `digit-argument', for instance, can compute the |
| 317 | (last-command-event (aref keyseq 0))) | 321 | ;; `prefix-arg'. |
| 318 | (call-interactively cmd))) | 322 | (setq last-command-event (aref keyseq 0)) |
| 319 | 323 | (call-interactively cmd))) | |
| 320 | ;; This is the final call to `universal-argument-other-key', which | ||
| 321 | ;; sets the final `prefix-arg'. | ||
| 322 | (let ((current-prefix-arg prefix-arg)) | ||
| 323 | (call-interactively cmd)) | ||
| 324 | |||
| 325 | ;; Read the command to execute with the given `prefix-arg'. | ||
| 326 | (setq prefix prefix-arg | ||
| 327 | keyseq (read-key-sequence nil t) | ||
| 328 | cmd (key-binding keyseq))) | ||
| 329 | 324 | ||
| 330 | (let ((coding-system-for-read coding-system) | 325 | (let ((coding-system-for-read coding-system) |
| 331 | (coding-system-for-write coding-system) | 326 | (coding-system-for-write coding-system) |
| 332 | (coding-system-require-warning t) | 327 | (coding-system-require-warning t)) |
| 333 | (current-prefix-arg prefix)) | 328 | (setq current-prefix-arg prefix-arg prefix-arg nil) |
| 329 | ;; Have to bind `last-command-event' e.g. for `self-insert-command'. | ||
| 330 | (setq last-command-event (aref keyseq 0)) | ||
| 334 | (message "") | 331 | (message "") |
| 335 | (call-interactively cmd)))) | 332 | (call-interactively cmd)))) |
| 336 | 333 | ||