aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-02-25 04:44:08 +0000
committerRichard M. Stallman1995-02-25 04:44:08 +0000
commitbaed0109364f28f12cabdc8a13e363b6f2f105fc (patch)
tree315f9104f76866680deb12601b89ef19c8dd1162
parentb03471782d533dac71a8b02e6ec2287c78329f9f (diff)
downloademacs-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.el45
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.
938COMMAND is a symbol naming an interactively-callable function.
939KEY is a key sequence (a string or vector of characters or event types).
940Non-ASCII characters with codes above 127 (such as ISO Latin-1)
941can be included if you use a vector.
942Note that if KEY has a local binding in the current buffer
943that 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.
952COMMAND is a symbol naming an interactively-callable function.
953KEY is a key sequence (a string or vector of characters or event types).
954Non-ASCII characters with codes above 127 (such as ISO Latin-1)
955can be included if you use a vector.
956The binding goes in the current buffer's local map,
957which 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.
969KEY 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.
975KEY 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.