diff options
| author | Richard M. Stallman | 1995-02-25 04:44:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-02-25 04:44:08 +0000 |
| commit | baed0109364f28f12cabdc8a13e363b6f2f105fc (patch) | |
| tree | 315f9104f76866680deb12601b89ef19c8dd1162 | |
| parent | b03471782d533dac71a8b02e6ec2287c78329f9f (diff) | |
| download | emacs-baed0109364f28f12cabdc8a13e363b6f2f105fc.tar.gz emacs-baed0109364f28f12cabdc8a13e363b6f2f105fc.zip | |
(global_set_key, local_set_key, global_unset_key)
(local_unset_key): Functions moved here from keyboard.c.
| -rw-r--r-- | lisp/subr.el | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 11abcdc3aa1..7f6db387cce 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -932,7 +932,52 @@ syntax table; other characters are copied from the standard syntax table." | |||
| 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 | |||
| 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) | ||
| 935 | 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. |