Mercurial > emacs
comparison lisp/simple.el @ 11140:97ed670a6123
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 28 Mar 1995 03:49:39 +0000 |
parents | c5fbb6f272f2 |
children | edf66df6fbe9 |
comparison
equal
deleted
inserted
replaced
11139:311f3ea4a759 | 11140:97ed670a6123 |
---|---|
2807 (select-window (get-buffer-window "*Completions*")) | 2807 (select-window (get-buffer-window "*Completions*")) |
2808 (goto-char (point-min)) | 2808 (goto-char (point-min)) |
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 |
2815 ;;; bindings for the function key symbols, then those bindings will | 2876 ;;; bindings for the function key symbols, then those bindings will |
2816 ;;; override these, so this shouldn't interfere with any existing | 2877 ;;; override these, so this shouldn't interfere with any existing |