Mercurial > hg > xemacs-beta
comparison lisp/keymap.el @ 5549:493c487cbc3f
Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
2011-08-10 Aidan Kehoe <kehoea@parhasard.net>
* keymap.el:
* keymap.el (event-apply-alt-modifier):
* keymap.el (event-apply-super-modifier):
* keymap.el (event-apply-hyper-modifier):
* keymap.el (event-apply-shift-modifier):
* keymap.el (event-apply-control-modifier):
* keymap.el (event-apply-meta-modifier):
* keymap.el (event-apply-modifiers): New.
* keymap.el (event-apply-modifier): Implement in terms of
#'event-apply-modifier.
Rework #'event-apply-modifier to take a list of modifiers, and
change its name appropriately. Keep the old name around, too.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 10 Aug 2011 16:50:37 +0100 |
parents | 3d1f8f0e690f |
children | 3bc58dc9d688 |
comparison
equal
deleted
inserted
replaced
5548:b90c153730c7 | 5549:493c487cbc3f |
---|---|
441 | 441 |
442 ;;; These functions -- which are not commands -- each add one modifier | 442 ;;; These functions -- which are not commands -- each add one modifier |
443 ;;; to the following event. | 443 ;;; to the following event. |
444 | 444 |
445 (defun event-apply-alt-modifier (ignore-prompt) | 445 (defun event-apply-alt-modifier (ignore-prompt) |
446 (event-apply-modifier 'alt)) | 446 (event-apply-modifiers '(alt))) |
447 (defun event-apply-super-modifier (ignore-prompt) | 447 (defun event-apply-super-modifier (ignore-prompt) |
448 (event-apply-modifier 'super)) | 448 (event-apply-modifiers '(super))) |
449 (defun event-apply-hyper-modifier (ignore-prompt) | 449 (defun event-apply-hyper-modifier (ignore-prompt) |
450 (event-apply-modifier 'hyper)) | 450 (event-apply-modifiers '(hyper))) |
451 (defun event-apply-shift-modifier (ignore-prompt) | 451 (defun event-apply-shift-modifier (ignore-prompt) |
452 (event-apply-modifier 'shift)) | 452 (event-apply-modifiers '(shift))) |
453 (defun event-apply-control-modifier (ignore-prompt) | 453 (defun event-apply-control-modifier (ignore-prompt) |
454 (event-apply-modifier 'control)) | 454 (event-apply-modifiers '(control))) |
455 (defun event-apply-meta-modifier (ignore-prompt) | 455 (defun event-apply-meta-modifier (ignore-prompt) |
456 (event-apply-modifier 'meta)) | 456 (event-apply-modifiers '(meta))) |
457 | 457 |
458 ;;; #### `key-translate-map' is ignored for now. | 458 ;;; #### `key-translate-map' is ignored for now. |
459 (defun event-apply-modifier (symbol) | 459 (defun event-apply-modifiers (list) |
460 "Return the next key event, with a modifier flag applied. | 460 "Return the next key event, with a list of modifiers applied. |
461 SYMBOL is the name of this modifier, as a symbol. | 461 LIST describes the names of these modifier, a list of symbols. |
462 `function-key-map' is scanned for prefix bindings." | 462 `function-key-map' is scanned for prefix bindings." |
463 (let (events binding) | 463 (let (events binding) |
464 ;; read keystrokes scanning `function-key-map' | 464 ;; read keystrokes scanning `function-key-map' |
465 (while (keymapp | 465 (while (keymapp |
466 (setq binding | 466 (setq binding |
477 (setq events (append binding nil)) | 477 (setq events (append binding nil)) |
478 ;; put remaining keystrokes back into input queue | 478 ;; put remaining keystrokes back into input queue |
479 (setq unread-command-events | 479 (setq unread-command-events |
480 (mapcar 'character-to-event (cdr events)))) | 480 (mapcar 'character-to-event (cdr events)))) |
481 (setq unread-command-events (cdr events))) | 481 (setq unread-command-events (cdr events))) |
482 ;; add a modifier SYMBOL to the first keystroke or event | 482 ;; add modifiers LIST to the first keystroke or event |
483 (vector | 483 (vector |
484 (append (list symbol) | 484 (append list |
485 (delq symbol | 485 (set-difference (aref (key-sequence-list-description (car events)) |
486 (aref (key-sequence-list-description (car events)) 0)))))) | 486 0) |
487 list :stable t))))) | |
488 | |
489 (defun event-apply-modifier (symbol) | |
490 "Return the next key event, with a single modifier applied. | |
491 See `event-apply-modifiers'." | |
492 (event-apply-modifiers (list symbol))) | |
487 | 493 |
488 (defun synthesize-keysym (ignore-prompt) | 494 (defun synthesize-keysym (ignore-prompt) |
489 "Read a sequence of keys, and returned the corresponding key symbol. | 495 "Read a sequence of keys, and returned the corresponding key symbol. |
490 The characters must be from the [-_a-zA-Z0-9]. Reading is terminated | 496 The characters must be from the [-_a-zA-Z0-9]. Reading is terminated |
491 by RET (which is discarded)." | 497 by RET (which is discarded)." |