changeset 39557:fb85410efef7

(define-key-after): Allow `key' to be longer than 1. (make-local-hook): Make obsolete. (add-hook, remove-hook): Don't use make-local-hook any more. (make-syntax-table): Inherit all chars from s-s-t.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 05 Oct 2001 09:26:17 +0000
parents c12d72aa46b9
children 88e97e81d728
files lisp/subr.el
diffstat 1 files changed, 25 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Fri Oct 05 09:24:51 2001 +0000
+++ b/lisp/subr.el	Fri Oct 05 09:26:17 2001 +0000
@@ -396,10 +396,7 @@
 \(like DEFINITION).
 
 If AFTER is t or omitted, the new binding goes at the end of the keymap.
-
-KEY must contain just one event type--that is to say, it must be a
-string or vector of length 1, but AFTER should be a single event
-type--a symbol or a character, not a sequence.
+AFTER should be a single event type--a symbol or a character, not a sequence.
 
 Bindings are always added before any inherited map.
 
@@ -407,14 +404,19 @@
   (unless after (setq after t))
   (or (keymapp keymap)
       (signal 'wrong-type-argument (list 'keymapp keymap)))
-  (if (> (length key) 1)
-      (error "multi-event key specified in `define-key-after'"))
-  (let ((tail keymap) done inserted
-	(first (aref key 0)))
+  (setq key
+	(if (<= (length key) 1) (aref key 0)
+	  (setq keymap (lookup-key keymap
+				   (apply 'vector
+					  (butlast (mapcar 'identity key)))))
+	  (aref key (1- (length key)))))
+  (let ((tail keymap) done inserted)
     (while (and (not done) tail)
       ;; Delete any earlier bindings for the same key.
-      (if (eq (car-safe (car (cdr tail))) first)
+      (if (eq (car-safe (car (cdr tail))) key)
 	  (setcdr tail (cdr (cdr tail))))
+      ;; If we hit an included map, go down that one.
+      (if (keymapp (car tail)) (setq tail (car tail)))
       ;; When we reach AFTER's binding, insert the new binding after.
       ;; If we reach an inherited keymap, insert just before that.
       ;; If we reach the end of this keymap, insert at the end.
@@ -430,7 +432,7 @@
 		(setq done t))
 	    ;; Don't insert more than once.
 	    (or inserted
-		(setcdr tail (cons (cons (aref key 0) definition) (cdr tail))))
+		(setcdr tail (cons (cons key definition) (cdr tail))))
 	    (setq inserted t)))
       (setq tail (cdr tail)))))
 
@@ -694,7 +696,7 @@
 functions listed in *either* the local value *or* the global value
 of the hook variable.
 
-This function works by making `t' a member of the buffer-local value,
+This function works by making t a member of the buffer-local value,
 which acts as a flag to run the hook functions in the default value as
 well.  This works for all normal hooks, but does not work for most
 non-normal hooks yet.  We will be changing the callers of non-normal
@@ -711,6 +713,7 @@
     (make-local-variable hook)
     (set hook (list t)))
   hook)
+(make-obsolete 'make-local-hook "Not necessary any more." "21.1")
 
 (defun add-hook (hook function &optional append local)
   "Add to the value of HOOK the function FUNCTION.
@@ -722,15 +725,14 @@
 The optional fourth argument, LOCAL, if non-nil, says to modify
 the hook's buffer-local value rather than its default value.
 This makes the hook buffer-local if needed.
-To make a hook variable buffer-local, always use
-`make-local-hook', not `make-local-variable'.
 
 HOOK should be a symbol, and FUNCTION may be any valid function.  If
 HOOK is void, it is first set to nil.  If HOOK's value is a single
 function, it is changed to a list of functions."
   (or (boundp hook) (set hook nil))
   (or (default-boundp hook) (set-default hook nil))
-  (if local (unless (local-variable-if-set-p hook) (make-local-hook hook))
+  (if local (unless (local-variable-if-set-p hook)
+	      (set (make-local-variable hook) (list t)))
     ;; Detect the case where make-local-variable was used on a hook
     ;; and do what we used to do.
     (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook)))
@@ -756,12 +758,11 @@
 
 The optional third argument, LOCAL, if non-nil, says to modify
 the hook's buffer-local value rather than its default value.
-This makes the hook buffer-local if needed.
-To make a hook variable buffer-local, always use
-`make-local-hook', not `make-local-variable'."
+This makes the hook buffer-local if needed."
   (or (boundp hook) (set hook nil))
   (or (default-boundp hook) (set-default hook nil))
-  (if local (unless (local-variable-if-set-p hook) (make-local-hook hook))
+  (if local (unless (local-variable-if-set-p hook)
+	      (set (make-local-variable hook) (list t)))
     ;; Detect the case where make-local-variable was used on a hook
     ;; and do what we used to do.
     (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook)))
@@ -1283,7 +1284,7 @@
   ;; string looking for matches of REGEXP and building up a (reversed)
   ;; list MATCHES.  This comprises segments of STRING which weren't
   ;; matched interspersed with replacements for segments that were.
-  ;; [For a `large' number of replacments it's more efficient to
+  ;; [For a `large' number of replacements it's more efficient to
   ;; operate in a temporary buffer; we can't tell from the function's
   ;; args whether to choose the buffer-based implementation, though it
   ;; might be reasonable to do so for long enough STRING.]
@@ -1347,29 +1348,12 @@
 (defun make-syntax-table (&optional oldtable)
   "Return a new syntax table.
 If OLDTABLE is non-nil, copy OLDTABLE.
-Otherwise, create a syntax table which inherits
-all letters and control characters from the standard syntax table;
-other characters are copied from the standard syntax table."
+Otherwise, create a syntax table which inherits from the
+`standard-syntax-table'."
   (if oldtable
       (copy-syntax-table oldtable)
-    (let ((table (copy-syntax-table))
-	  i)
-      (setq i 0)
-      (while (<= i 31)
-	(aset table i nil)
-	(setq i (1+ i)))
-      (setq i ?A)
-      (while (<= i ?Z)
-	(aset table i nil)
-	(setq i (1+ i)))
-      (setq i ?a)
-      (while (<= i ?z)
-	(aset table i nil)
-	(setq i (1+ i)))
-      (setq i 128)
-      (while (<= i 255)
-	(aset table i nil)
-	(setq i (1+ i)))
+    (let ((table (make-char-table 'syntax-table nil)))
+      (set-char-table-parent table (standard-syntax-table))
       table)))
 
 (defun add-to-invisibility-spec (arg)
@@ -1501,7 +1485,7 @@
 		     (make-directory file)
 		   (write-region "" nil file nil 'silent nil 'excl))
 		 nil)
-	    (file-already-exists t))
+	     (file-already-exists t))
       ;; the file was somehow created by someone else between
       ;; `make-temp-name' and `write-region', let's try again.
       nil)