From 321e1a9c4283e1fd1db5a6b7c75325d5ed7b97e1 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 5 Jul 2013 20:10:54 -0400 Subject: [PATCH] * lisp/subr.el (read-quoted-char): Use read-key. (sit-for): Let read-event decode tty input. Fixes: debbugs:14782 --- lisp/ChangeLog | 23 ++++++++++++++--------- lisp/subr.el | 27 +++++++++++++-------------- src/keyboard.c | 1 - 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 46c728abbe7..dc554bc542d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,8 +1,13 @@ +2013-07-06 Stefan Monnier + + * subr.el (read-quoted-char): Use read-key. + (sit-for): Let read-event decode tty input (bug#14782). + 2013-07-05 Stephen Berman * calendar/todo-mode.el: Add handling of file deletion, both by - mode command and externally. Fix various related bugs. Clarify - Commentary and improve some documentation strings and code. + mode command and externally. Fix various related bugs. + Clarify Commentary and improve some documentation strings and code. (todo-delete-file): New command. (todo-check-file): New function. (todo-show): Handle external deletion of the file we're trying to @@ -20,8 +25,8 @@ (todo-find-archive): Check whether there are any archives. Replace unnecessary setq by let-binding. (todo-archive-done-item): Use find-file-noselect to get the - archive buffer whether or not the archive already exists. Remove - superfluous code. Use file size instead of buffer-file-name to + archive buffer whether or not the archive already exists. + Remove superfluous code. Use file size instead of buffer-file-name to check if the archive is new; if it is, update list of archives. (todo-default-todo-file): Allow nil to be a valid value for when there are no todo files. @@ -38,9 +43,9 @@ 2013-07-05 Michael Albinus - * net/tramp-sh.el (tramp-sh-handle-file-notify-add-watch): Support - both "gvfs-monitor-dir" and "inotifywait". - (tramp-sh-file-inotifywait-process-filter): Renamed from + * net/tramp-sh.el (tramp-sh-handle-file-notify-add-watch): + Support both "gvfs-monitor-dir" and "inotifywait". + (tramp-sh-file-inotifywait-process-filter): Rename from `tramp-sh-file-notify-process-filter'. (tramp-sh-file-gvfs-monitor-dir-process-filter) (tramp-get-remote-gvfs-monitor-dir): New defuns. @@ -69,8 +74,8 @@ * subr.el (file-notify-handle-event): Move function to filenotify.el. - * net/tramp.el (tramp-file-name-for-operation): Handle - `file-notify-add-watch' and `file-notify-rm-watch'. + * net/tramp.el (tramp-file-name-for-operation): + Handle `file-notify-add-watch' and `file-notify-rm-watch'. * net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add handler for `file-notify-add-watch' and `file-notify-rm-watch'. diff --git a/lisp/subr.el b/lisp/subr.el index f8262eb7f6d..63fb1621b35 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1990,20 +1990,14 @@ for numeric input." or the octal character code. RET terminates the character code and is discarded; any other non-digit terminates the character code and is then used as input.")) - (setq char (read-event (and prompt (format "%s-" prompt)) t)) + (setq translated (read-key (and prompt (format "%s-" prompt)))) (if inhibit-quit (setq quit-flag nil))) - ;; Translate TAB key into control-I ASCII character, and so on. - ;; Note: `read-char' does it using the `ascii-character' property. - ;; We should try and use read-key instead. - (let ((translation (lookup-key local-function-key-map (vector char)))) - (setq translated (if (arrayp translation) - (aref translation 0) - char))) (if (integerp translated) (setq translated (char-resolve-modifiers translated))) (cond ((null translated)) ((not (integerp translated)) - (setq unread-command-events (list char) + (setq unread-command-events + (listify-key-sequence (this-single-command-raw-keys)) done t)) ((/= (logand translated ?\M-\^@) 0) ;; Turn a meta-character into a character with the 0200 bit set. @@ -2022,7 +2016,8 @@ any other non-digit terminates the character code and is then used as input.")) ((and (not first) (eq translated ?\C-m)) (setq done t)) ((not first) - (setq unread-command-events (list char) + (setq unread-command-events + (listify-key-sequence (this-single-command-raw-keys)) done t)) (t (setq code translated done t))) @@ -2186,6 +2181,7 @@ An obsolete, but still supported form is where the optional arg MILLISECONDS specifies an additional wait period, in milliseconds; this was useful when Emacs was built without floating point support." + (declare (advertised-calling-convention (seconds &optional nodisp) "22.1")) (if (numberp nodisp) (setq seconds (+ seconds (* 1e-3 nodisp)) nodisp obsolete) @@ -2200,7 +2196,10 @@ floating point support." (or nodisp (redisplay))) (t (or nodisp (redisplay)) - (let ((read (read-event nil nil seconds))) + ;; FIXME: we should not read-event here at all, because it's much too + ;; difficult to reliably "undo" a read-event by pushing it onto + ;; unread-command-events. + (let ((read (read-event nil t seconds))) (or (null read) (progn ;; If last command was a prefix arg, e.g. C-u, push this event onto @@ -2210,7 +2209,6 @@ floating point support." (setq read (cons t read))) (push read unread-command-events) nil)))))) -(set-advertised-calling-convention 'sit-for '(seconds &optional nodisp) "22.1") (defun y-or-n-p (prompt) "Ask user a \"y or n\" question. Return t if answer is \"y\". @@ -2451,11 +2449,12 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." (recenter (/ (window-height) 2)))) (message (or message "Type %s to continue editing.") (single-key-description exit-char)) - (let ((event (read-event))) + (let ((event (read-key))) ;; `exit-char' can be an event, or an event description list. (or (eq event exit-char) (eq event (event-convert-list exit-char)) - (setq unread-command-events (list event))))) + (setq unread-command-events + (append (this-single-command-raw-keys)))))) (delete-overlay ol)))) diff --git a/src/keyboard.c b/src/keyboard.c index 7cb4c4b91e3..e6094a939b9 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2286,7 +2286,6 @@ read_event_from_main_queue (EMACS_TIME *end_time, XSETINT (c, XINT (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL)); } - /* FIXME: Decode tty keyboard input here. */ return c; } -- 2.11.4.GIT