aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGerd Moellmann2001-10-05 09:26:17 +0000
committerGerd Moellmann2001-10-05 09:26:17 +0000
commit08b1f8a12ee617698dccf25f9c1dd9d0e2c32e97 (patch)
treee66846edf456c8780ce72fea20337087d9513359 /lisp
parent802a980a596407d8de800b26380944fd1303a366 (diff)
downloademacs-08b1f8a12ee617698dccf25f9c1dd9d0e2c32e97.tar.gz
emacs-08b1f8a12ee617698dccf25f9c1dd9d0e2c32e97.zip
(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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/subr.el66
1 files changed, 25 insertions, 41 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index eb09e39fb59..309338c4577 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -396,10 +396,7 @@ of the map. Note that AFTER must be an event type (like KEY), NOT a command
396\(like DEFINITION). 396\(like DEFINITION).
397 397
398If AFTER is t or omitted, the new binding goes at the end of the keymap. 398If AFTER is t or omitted, the new binding goes at the end of the keymap.
399 399AFTER should be a single event type--a symbol or a character, not a sequence.
400KEY must contain just one event type--that is to say, it must be a
401string or vector of length 1, but AFTER should be a single event
402type--a symbol or a character, not a sequence.
403 400
404Bindings are always added before any inherited map. 401Bindings are always added before any inherited map.
405 402
@@ -407,14 +404,19 @@ The order of bindings in a keymap matters when it is used as a menu."
407 (unless after (setq after t)) 404 (unless after (setq after t))
408 (or (keymapp keymap) 405 (or (keymapp keymap)
409 (signal 'wrong-type-argument (list 'keymapp keymap))) 406 (signal 'wrong-type-argument (list 'keymapp keymap)))
410 (if (> (length key) 1) 407 (setq key
411 (error "multi-event key specified in `define-key-after'")) 408 (if (<= (length key) 1) (aref key 0)
412 (let ((tail keymap) done inserted 409 (setq keymap (lookup-key keymap
413 (first (aref key 0))) 410 (apply 'vector
411 (butlast (mapcar 'identity key)))))
412 (aref key (1- (length key)))))
413 (let ((tail keymap) done inserted)
414 (while (and (not done) tail) 414 (while (and (not done) tail)
415 ;; Delete any earlier bindings for the same key. 415 ;; Delete any earlier bindings for the same key.
416 (if (eq (car-safe (car (cdr tail))) first) 416 (if (eq (car-safe (car (cdr tail))) key)
417 (setcdr tail (cdr (cdr tail)))) 417 (setcdr tail (cdr (cdr tail))))
418 ;; If we hit an included map, go down that one.
419 (if (keymapp (car tail)) (setq tail (car tail)))
418 ;; When we reach AFTER's binding, insert the new binding after. 420 ;; When we reach AFTER's binding, insert the new binding after.
419 ;; If we reach an inherited keymap, insert just before that. 421 ;; If we reach an inherited keymap, insert just before that.
420 ;; If we reach the end of this keymap, insert at the end. 422 ;; If we reach the end of this keymap, insert at the end.
@@ -430,7 +432,7 @@ The order of bindings in a keymap matters when it is used as a menu."
430 (setq done t)) 432 (setq done t))
431 ;; Don't insert more than once. 433 ;; Don't insert more than once.
432 (or inserted 434 (or inserted
433 (setcdr tail (cons (cons (aref key 0) definition) (cdr tail)))) 435 (setcdr tail (cons (cons key definition) (cdr tail))))
434 (setq inserted t))) 436 (setq inserted t)))
435 (setq tail (cdr tail))))) 437 (setq tail (cdr tail)))))
436 438
@@ -694,7 +696,7 @@ work in concert: running the hook actually runs all the hook
694functions listed in *either* the local value *or* the global value 696functions listed in *either* the local value *or* the global value
695of the hook variable. 697of the hook variable.
696 698
697This function works by making `t' a member of the buffer-local value, 699This function works by making t a member of the buffer-local value,
698which acts as a flag to run the hook functions in the default value as 700which acts as a flag to run the hook functions in the default value as
699well. This works for all normal hooks, but does not work for most 701well. This works for all normal hooks, but does not work for most
700non-normal hooks yet. We will be changing the callers of non-normal 702non-normal hooks yet. We will be changing the callers of non-normal
@@ -711,6 +713,7 @@ Do not use `make-local-variable' to make a hook variable buffer-local."
711 (make-local-variable hook) 713 (make-local-variable hook)
712 (set hook (list t))) 714 (set hook (list t)))
713 hook) 715 hook)
716(make-obsolete 'make-local-hook "Not necessary any more." "21.1")
714 717
715(defun add-hook (hook function &optional append local) 718(defun add-hook (hook function &optional append local)
716 "Add to the value of HOOK the function FUNCTION. 719 "Add to the value of HOOK the function FUNCTION.
@@ -722,15 +725,14 @@ FUNCTION is added at the end.
722The optional fourth argument, LOCAL, if non-nil, says to modify 725The optional fourth argument, LOCAL, if non-nil, says to modify
723the hook's buffer-local value rather than its default value. 726the hook's buffer-local value rather than its default value.
724This makes the hook buffer-local if needed. 727This makes the hook buffer-local if needed.
725To make a hook variable buffer-local, always use
726`make-local-hook', not `make-local-variable'.
727 728
728HOOK should be a symbol, and FUNCTION may be any valid function. If 729HOOK should be a symbol, and FUNCTION may be any valid function. If
729HOOK is void, it is first set to nil. If HOOK's value is a single 730HOOK is void, it is first set to nil. If HOOK's value is a single
730function, it is changed to a list of functions." 731function, it is changed to a list of functions."
731 (or (boundp hook) (set hook nil)) 732 (or (boundp hook) (set hook nil))
732 (or (default-boundp hook) (set-default hook nil)) 733 (or (default-boundp hook) (set-default hook nil))
733 (if local (unless (local-variable-if-set-p hook) (make-local-hook hook)) 734 (if local (unless (local-variable-if-set-p hook)
735 (set (make-local-variable hook) (list t)))
734 ;; Detect the case where make-local-variable was used on a hook 736 ;; Detect the case where make-local-variable was used on a hook
735 ;; and do what we used to do. 737 ;; and do what we used to do.
736 (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook))) 738 (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook)))
@@ -756,12 +758,11 @@ list of hooks to run in HOOK, then nothing is done. See `add-hook'.
756 758
757The optional third argument, LOCAL, if non-nil, says to modify 759The optional third argument, LOCAL, if non-nil, says to modify
758the hook's buffer-local value rather than its default value. 760the hook's buffer-local value rather than its default value.
759This makes the hook buffer-local if needed. 761This makes the hook buffer-local if needed."
760To make a hook variable buffer-local, always use
761`make-local-hook', not `make-local-variable'."
762 (or (boundp hook) (set hook nil)) 762 (or (boundp hook) (set hook nil))
763 (or (default-boundp hook) (set-default hook nil)) 763 (or (default-boundp hook) (set-default hook nil))
764 (if local (unless (local-variable-if-set-p hook) (make-local-hook hook)) 764 (if local (unless (local-variable-if-set-p hook)
765 (set (make-local-variable hook) (list t)))
765 ;; Detect the case where make-local-variable was used on a hook 766 ;; Detect the case where make-local-variable was used on a hook
766 ;; and do what we used to do. 767 ;; and do what we used to do.
767 (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook))) 768 (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook)))
@@ -1283,7 +1284,7 @@ and replace a sub-expression, e.g.
1283 ;; string looking for matches of REGEXP and building up a (reversed) 1284 ;; string looking for matches of REGEXP and building up a (reversed)
1284 ;; list MATCHES. This comprises segments of STRING which weren't 1285 ;; list MATCHES. This comprises segments of STRING which weren't
1285 ;; matched interspersed with replacements for segments that were. 1286 ;; matched interspersed with replacements for segments that were.
1286 ;; [For a `large' number of replacments it's more efficient to 1287 ;; [For a `large' number of replacements it's more efficient to
1287 ;; operate in a temporary buffer; we can't tell from the function's 1288 ;; operate in a temporary buffer; we can't tell from the function's
1288 ;; args whether to choose the buffer-based implementation, though it 1289 ;; args whether to choose the buffer-based implementation, though it
1289 ;; might be reasonable to do so for long enough STRING.] 1290 ;; might be reasonable to do so for long enough STRING.]
@@ -1347,29 +1348,12 @@ and replace a sub-expression, e.g.
1347(defun make-syntax-table (&optional oldtable) 1348(defun make-syntax-table (&optional oldtable)
1348 "Return a new syntax table. 1349 "Return a new syntax table.
1349If OLDTABLE is non-nil, copy OLDTABLE. 1350If OLDTABLE is non-nil, copy OLDTABLE.
1350Otherwise, create a syntax table which inherits 1351Otherwise, create a syntax table which inherits from the
1351all letters and control characters from the standard syntax table; 1352`standard-syntax-table'."
1352other characters are copied from the standard syntax table."
1353 (if oldtable 1353 (if oldtable
1354 (copy-syntax-table oldtable) 1354 (copy-syntax-table oldtable)
1355 (let ((table (copy-syntax-table)) 1355 (let ((table (make-char-table 'syntax-table nil)))
1356 i) 1356 (set-char-table-parent table (standard-syntax-table))
1357 (setq i 0)
1358 (while (<= i 31)
1359 (aset table i nil)
1360 (setq i (1+ i)))
1361 (setq i ?A)
1362 (while (<= i ?Z)
1363 (aset table i nil)
1364 (setq i (1+ i)))
1365 (setq i ?a)
1366 (while (<= i ?z)
1367 (aset table i nil)
1368 (setq i (1+ i)))
1369 (setq i 128)
1370 (while (<= i 255)
1371 (aset table i nil)
1372 (setq i (1+ i)))
1373 table))) 1357 table)))
1374 1358
1375(defun add-to-invisibility-spec (arg) 1359(defun add-to-invisibility-spec (arg)
@@ -1501,7 +1485,7 @@ If DIR-FLAG is non-nil, create a new empty directory instead of a file."
1501 (make-directory file) 1485 (make-directory file)
1502 (write-region "" nil file nil 'silent nil 'excl)) 1486 (write-region "" nil file nil 'silent nil 'excl))
1503 nil) 1487 nil)
1504 (file-already-exists t)) 1488 (file-already-exists t))
1505 ;; the file was somehow created by someone else between 1489 ;; the file was somehow created by someone else between
1506 ;; `make-temp-name' and `write-region', let's try again. 1490 ;; `make-temp-name' and `write-region', let's try again.
1507 nil) 1491 nil)