diff options
| author | Richard M. Stallman | 1995-03-28 03:49:39 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-03-28 03:49:39 +0000 |
| commit | 82072f33f9384ddfd12a21004fff8820f063d700 (patch) | |
| tree | 4f152648d687a3e4bbcdb301dcffe7349f05d90b | |
| parent | c2cd5fb7934ecccc47d9306791e4396e88a28a0c (diff) | |
| download | emacs-82072f33f9384ddfd12a21004fff8820f063d700.tar.gz emacs-82072f33f9384ddfd12a21004fff8820f063d700.zip | |
(event-apply-modifier): New function.
(event-apply-control-modifier, event-apply-meta-modifier)
(event-apply-hyper-modifier, event-apply-shift-modifier)
(event-apply-alt-modifier, event-apply-super-modifier):
New functions, with bindings in function-key-map.
| -rw-r--r-- | lisp/simple.el | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 922912bd3e3..90ee2642c9d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2809,6 +2809,67 @@ select the completion near point.\n\n")) | |||
| 2809 | (search-forward "\n\n") | 2809 | (search-forward "\n\n") |
| 2810 | (forward-line 1)) | 2810 | (forward-line 1)) |
| 2811 | 2811 | ||
| 2812 | ;; Support keyboard commands to turn on various modifiers. | ||
| 2813 | |||
| 2814 | ;; These functions -- which are not commands -- each add one modifier | ||
| 2815 | ;; to the following event. | ||
| 2816 | |||
| 2817 | (defun event-apply-alt-modifier (ignore-prompt) | ||
| 2818 | (vector (event-apply-modifier (read-event) 'alt 22 "A-"))) | ||
| 2819 | (defun event-apply-super-modifier (ignore-prompt) | ||
| 2820 | (vector (event-apply-modifier (read-event) 'super 23 "s-"))) | ||
| 2821 | (defun event-apply-hyper-modifier (ignore-prompt) | ||
| 2822 | (vector (event-apply-modifier (read-event) 'hyper 24 "H-"))) | ||
| 2823 | (defun event-apply-shift-modifier (ignore-prompt) | ||
| 2824 | (vector (event-apply-modifier (read-event) 'shift 25 "S-"))) | ||
| 2825 | (defun event-apply-control-modifier (ignore-prompt) | ||
| 2826 | (vector (event-apply-modifier (read-event) 'control 26 "C-"))) | ||
| 2827 | (defun event-apply-meta-modifier (ignore-prompt) | ||
| 2828 | (vector (event-apply-modifier (read-event) 'meta 27 "M-"))) | ||
| 2829 | |||
| 2830 | (defun event-apply-modifier (event symbol lshiftby prefix) | ||
| 2831 | "Apply a modifier flag to event EVENT. | ||
| 2832 | SYMBOL is the name of this modifier, as a symbol. | ||
| 2833 | LSHIFTBY is the numeric value of this modifier, in keyboard events. | ||
| 2834 | PREFIX is the string that represents this modifier in an event type symbol." | ||
| 2835 | (if (numberp event) | ||
| 2836 | (cond ((eq symbol 'control) | ||
| 2837 | (if (and (< (downcase event) ?z) | ||
| 2838 | (> (downcase event) ?a)) | ||
| 2839 | (- (downcase event) ?a -1) | ||
| 2840 | (if (and (< (downcase event) ?Z) | ||
| 2841 | (> (downcase event) ?A)) | ||
| 2842 | (- (downcase event) ?A -1) | ||
| 2843 | (logior (lsh 1 lshiftby) event)))) | ||
| 2844 | ((eq symbol 'shift) | ||
| 2845 | (if (and (<= (downcase event) ?z) | ||
| 2846 | (>= (downcase event) ?a)) | ||
| 2847 | (upcase event) | ||
| 2848 | (logior (lsh 1 lshiftby) event))) | ||
| 2849 | (t | ||
| 2850 | (logior (lsh 1 lshiftby) event))) | ||
| 2851 | (if (memq symbol (event-modifiers event)) | ||
| 2852 | event | ||
| 2853 | (let ((event-type (if (symbolp event) event (car event)))) | ||
| 2854 | (setq event-type (intern (concat prefix (symbol-name event-type)))) | ||
| 2855 | (if (symbolp event) | ||
| 2856 | event-type | ||
| 2857 | (cons event-type (cdr event))))))) | ||
| 2858 | |||
| 2859 | (define-key function-key-map [?\C-x escape ?h] 'event-apply-hyper-modifier) | ||
| 2860 | (define-key function-key-map [?\C-x escape ?s] 'event-apply-super-modifier) | ||
| 2861 | (define-key function-key-map [?\C-x escape ?m] 'event-apply-meta-modifier) | ||
| 2862 | (define-key function-key-map [?\C-x escape ?a] 'event-apply-alt-modifier) | ||
| 2863 | (define-key function-key-map [?\C-x escape ?S] 'event-apply-shift-modifier) | ||
| 2864 | (define-key function-key-map [?\C-x escape ?c] 'event-apply-control-modifier) | ||
| 2865 | |||
| 2866 | (define-key function-key-map [?\C-x ?\e ?h] 'event-apply-hyper-modifier) | ||
| 2867 | (define-key function-key-map [?\C-x ?\e ?s] 'event-apply-super-modifier) | ||
| 2868 | (define-key function-key-map [?\C-x ?\e ?m] 'event-apply-meta-modifier) | ||
| 2869 | (define-key function-key-map [?\C-x ?\e ?a] 'event-apply-alt-modifier) | ||
| 2870 | (define-key function-key-map [?\C-x ?\e ?S] 'event-apply-shift-modifier) | ||
| 2871 | (define-key function-key-map [?\C-x ?\e ?c] 'event-apply-control-modifier) | ||
| 2872 | |||
| 2812 | ;;;; Keypad support. | 2873 | ;;;; Keypad support. |
| 2813 | 2874 | ||
| 2814 | ;;; Make the keypad keys act like ordinary typing keys. If people add | 2875 | ;;; Make the keypad keys act like ordinary typing keys. If people add |