comparison lisp/keymap.el @ 5801:0e9f791cc655

Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU lisp/ChangeLog addition: 2014-07-02 Aidan Kehoe <kehoea@parhasard.net> * cmdloop.el: * cmdloop.el (read-char-1): New. * cmdloop.el (read-char, read-char-exclusive): Use #'read-char-1 in these function; sync their API with that of GNU, respect `function-key-map' where we didn't before, add initial support for Quail input methods. * keymap.el (next-key-event): Accept EVENT and PROMPT arguments, as does #'next-command-event. * keymap.el (event-apply-modifiers): Use #'functionp here, no need to exclude lambdas from `function-key-map'. * keymap.el (synthesize-keysym): Correct this function's docstring. src/ChangeLog addition: 2014-07-02 Aidan Kehoe <kehoea@parhasard.net> * event-stream.c (Fnext_command_event): Only snooze displaying keystrokes if PROMPT is nil. If prompt is non-nil, our callers want to see it.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 02 Jul 2014 16:32:19 +0100
parents f9e4d44504a4
children 1b984807a299
comparison
equal deleted inserted replaced
5800:be3ca9e58c92 5801:0e9f791cc655
379 (signal 'wrong-type-argument 379 (signal 'wrong-type-argument
380 (list 'key-press-event-p event)))) 380 (list 'key-press-event-p event))))
381 (setq i (1+ i))) 381 (setq i (1+ i)))
382 new)))) 382 new))))
383 383
384 (defun next-key-event () 384 (defun next-key-event (&optional event prompt)
385 "Return the next available keyboard event." 385 "Return the next available keyboard event."
386 (let (event) 386 (while (not (key-press-event-p
387 (while (not (key-press-event-p (setq event (next-command-event)))) 387 (setq event (next-command-event event prompt))))
388 (dispatch-event event)) 388 (dispatch-event event))
389 event)) 389 event)
390 390
391 (defun key-sequence-list-description (keys) 391 (defun key-sequence-list-description (keys)
392 "Convert a key sequence KEYS to the full [(modifiers... key)...] form. 392 "Convert a key sequence KEYS to the full [(modifiers... key)...] form.
393 Argument KEYS can be in any form accepted by `define-key' function. 393 Argument KEYS can be in any form accepted by `define-key' function.
394 The output is always in a canonical form, meaning you can use this 394 The output is always in a canonical form, meaning you can use this
455 (setq events 455 (setq events
456 (append events (list (next-key-event))))))))) 456 (append events (list (next-key-event)))))))))
457 (if binding ; found a binding 457 (if binding ; found a binding
458 (progn 458 (progn
459 ;; allow for several modifiers 459 ;; allow for several modifiers
460 (if (and (symbolp binding) (fboundp binding)) 460 (if (functionp binding)
461 (setq binding (funcall binding nil))) 461 (setq binding (funcall binding nil)))
462 (setq events (append binding nil)) 462 (setq events (append binding nil))
463 ;; put remaining keystrokes back into input queue 463 ;; put remaining keystrokes back into input queue
464 (setq unread-command-events 464 (setq unread-command-events
465 (mapcar 'character-to-event (cdr events)))) 465 (mapcar 'character-to-event (cdr events))))
475 "Return the next key event, with a single modifier applied. 475 "Return the next key event, with a single modifier applied.
476 See `event-apply-modifiers'." 476 See `event-apply-modifiers'."
477 (event-apply-modifiers (list symbol))) 477 (event-apply-modifiers (list symbol)))
478 478
479 (defun synthesize-keysym (ignore-prompt) 479 (defun synthesize-keysym (ignore-prompt)
480 "Read a sequence of keys, and returned the corresponding key symbol. 480 "Read a sequence of characters, and return the corresponding keysym.
481 The characters must be from the [-_a-zA-Z0-9]. Reading is terminated 481 The characters must be ?-, or ?_, or have word syntax. Reading is
482 by RET (which is discarded)." 482 terminated by RET (which is discarded)."
483 (let ((continuep t) 483 (let ((continuep t)
484 event char list) 484 event char list)
485 (while continuep 485 (while continuep
486 (setq event (next-key-event)) 486 (setq event (next-key-event))
487 (cond ((and (setq char (event-to-character event)) 487 (cond ((and (setq char (event-to-character event))