# HG changeset patch # User Stefan Monnier # Date 1024870395 0 # Node ID a8fbafaa31adb7a1495ebb82bc1132f16a0c98cd # Parent ac1a42ec420bab7f553e9470d6fc6a69226669bf (event-start, event-end, event-click-count): Accept non-mouse events as well. (read-key): New function. (read-quoted-char): Use it. Use this-single-command-raw-keys as well. diff -r ac1a42ec420b -r a8fbafaa31ad lisp/subr.el --- a/lisp/subr.el Sun Jun 23 21:43:21 2002 +0000 +++ b/lisp/subr.el Sun Jun 23 22:13:15 2002 +0000 @@ -608,7 +608,8 @@ The return value is of the form (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) The `posn-' functions access elements of such lists." - (nth 1 event)) + (if (consp event) (nth 1 event) + (list (selected-window) (point) '(0 . 0) 0))) (defsubst event-end (event) "Return the ending location of EVENT. EVENT should be a click or drag event. @@ -616,12 +617,13 @@ The return value is of the form (WINDOW BUFFER-POSITION (X . Y) TIMESTAMP) The `posn-' functions access elements of such lists." - (nth (if (consp (nth 2 event)) 2 1) event)) + (if (consp event) (nth (if (consp (nth 2 event)) 2 1) event) + (list (selected-window) (point) '(0 . 0) 0))) (defsubst event-click-count (event) "Return the multi-click count of EVENT, a click or drag event. The return value is a positive integer." - (if (integerp (nth 2 event)) (nth 2 event) 1)) + (if (and (consp event) (integerp (nth 2 event))) (nth 2 event) 1)) (defsubst posn-window (position) "Return the window in POSITION. @@ -1033,6 +1035,13 @@ :type '(choice (const 8) (const 10) (const 16)) :group 'editing-basics) +(defun read-key (&optional prompt) + "Read a key from the keyboard. +Contrary to `read-event' this will not return a raw event but will +obey `function-key-map' and `key-translation-map' instead." + (let ((overriding-terminal-local-map (make-sparse-keymap))) + (aref (read-key-sequence prompt nil t) 0))) + (defun read-quoted-char (&optional prompt) "Like `read-char', but do not allow quitting. Also, if the first character read is an octal digit, @@ -1054,16 +1063,11 @@ 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 char (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. - (and char - (let ((translated (lookup-key function-key-map (vector char)))) - (if (arrayp translated) - (setq char (aref translated 0))))) (cond ((null char)) ((not (integerp char)) - (setq unread-command-events (list char) + (setq unread-command-events (this-single-command-raw-keys) done t)) ((/= (logand char ?\M-\^@) 0) ;; Turn a meta-character into a character with the 0200 bit set. @@ -1080,7 +1084,7 @@ ((and (not first) (eq char ?\C-m)) (setq done t)) ((not first) - (setq unread-command-events (list char) + (setq unread-command-events (this-single-command-raw-keys) done t)) (t (setq code char done t))) @@ -1952,7 +1956,7 @@ (defun make-temp-file (prefix &optional dir-flag suffix) "Create a temporary file. The returned file name (created by appending some random characters at the end -of PREFIX, and expanding against `temporary-file-directory' if necessary, +of PREFIX, and expanding against `temporary-file-directory' if necessary), is guaranteed to point to a newly created empty file. You can then use `write-region' to write new data into the file.