Mercurial > emacs
comparison lisp/subr.el @ 10825:4dba26c66bf5
(global_set_key, local_set_key, global_unset_key)
(local_unset_key): Functions moved here from keyboard.c.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 25 Feb 1995 04:44:08 +0000 |
parents | 4443f78a2117 |
children | bd0ab0601489 |
comparison
equal
deleted
inserted
replaced
10824:894369e950f5 | 10825:4dba26c66bf5 |
---|---|
930 (setq i 128) | 930 (setq i 128) |
931 (while (<= i 255) | 931 (while (<= i 255) |
932 (aset table i 13) | 932 (aset table i 13) |
933 (setq i (1+ i))) | 933 (setq i (1+ i))) |
934 table))) | 934 table))) |
935 | 935 |
936 (defun global-set-key (key command) | |
937 "Give KEY a global binding as COMMAND. | |
938 COMMAND is a symbol naming an interactively-callable function. | |
939 KEY is a key sequence (a string or vector of characters or event types). | |
940 Non-ASCII characters with codes above 127 (such as ISO Latin-1) | |
941 can be included if you use a vector. | |
942 Note that if KEY has a local binding in the current buffer | |
943 that local binding will continue to shadow any global binding." | |
944 (interactive "KSet key globally: \nCSet key %s to command: ") | |
945 (or (vectorp key) (stringp key) | |
946 (signal 'wrong-type-argument (list 'arrayp key))) | |
947 (define-key (current-global-map) key command) | |
948 nil) | |
949 | |
950 (defun local-set-key (key command) | |
951 "Give KEY a local binding as COMMAND. | |
952 COMMAND is a symbol naming an interactively-callable function. | |
953 KEY is a key sequence (a string or vector of characters or event types). | |
954 Non-ASCII characters with codes above 127 (such as ISO Latin-1) | |
955 can be included if you use a vector. | |
956 The binding goes in the current buffer's local map, | |
957 which in most cases is shared with all other buffers in the same major mode." | |
958 (interactive "KSet key locally: \nCSet key %s locally to command: ") | |
959 (let ((map (current-local-map))) | |
960 (or map | |
961 (use-local-map (setq map (make-sparse-keymap)))) | |
962 (or (vectorp key) (stringp key) | |
963 (signal 'wrong-type-argument (list 'arrayp key))) | |
964 (define-key map key command)) | |
965 nil) | |
966 | |
967 (defun global-unset-key (key) | |
968 "Remove global binding of KEY. | |
969 KEY is a string representing a sequence of keystrokes." | |
970 (interactive "kUnset key globally: ") | |
971 (global-set-key key nil)) | |
972 | |
973 (defun local-unset-key | |
974 "Remove local binding of KEY. | |
975 KEY is a string representing a sequence of keystrokes." | |
976 (interactive "kUnset key locally: ") | |
977 (if (current-local-map) | |
978 (local-set-key (current-local-map) key nil)) | |
979 nil) | |
980 | |
936 ;; now in fns.c | 981 ;; now in fns.c |
937 ;(defun nth (n list) | 982 ;(defun nth (n list) |
938 ; "Returns the Nth element of LIST. | 983 ; "Returns the Nth element of LIST. |
939 ;N counts from zero. If LIST is not that long, nil is returned." | 984 ;N counts from zero. If LIST is not that long, nil is returned." |
940 ; (car (nthcdr n list))) | 985 ; (car (nthcdr n list))) |