diff options
| author | Gerd Moellmann | 2001-10-05 09:26:17 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-10-05 09:26:17 +0000 |
| commit | 08b1f8a12ee617698dccf25f9c1dd9d0e2c32e97 (patch) | |
| tree | e66846edf456c8780ce72fea20337087d9513359 /lisp | |
| parent | 802a980a596407d8de800b26380944fd1303a366 (diff) | |
| download | emacs-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.el | 66 |
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 | ||
| 398 | If AFTER is t or omitted, the new binding goes at the end of the keymap. | 398 | If AFTER is t or omitted, the new binding goes at the end of the keymap. |
| 399 | 399 | AFTER should be a single event type--a symbol or a character, not a sequence. | |
| 400 | KEY must contain just one event type--that is to say, it must be a | ||
| 401 | string or vector of length 1, but AFTER should be a single event | ||
| 402 | type--a symbol or a character, not a sequence. | ||
| 403 | 400 | ||
| 404 | Bindings are always added before any inherited map. | 401 | Bindings 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 | |||
| 694 | functions listed in *either* the local value *or* the global value | 696 | functions listed in *either* the local value *or* the global value |
| 695 | of the hook variable. | 697 | of the hook variable. |
| 696 | 698 | ||
| 697 | This function works by making `t' a member of the buffer-local value, | 699 | This function works by making t a member of the buffer-local value, |
| 698 | which acts as a flag to run the hook functions in the default value as | 700 | which acts as a flag to run the hook functions in the default value as |
| 699 | well. This works for all normal hooks, but does not work for most | 701 | well. This works for all normal hooks, but does not work for most |
| 700 | non-normal hooks yet. We will be changing the callers of non-normal | 702 | non-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. | |||
| 722 | The optional fourth argument, LOCAL, if non-nil, says to modify | 725 | The optional fourth argument, LOCAL, if non-nil, says to modify |
| 723 | the hook's buffer-local value rather than its default value. | 726 | the hook's buffer-local value rather than its default value. |
| 724 | This makes the hook buffer-local if needed. | 727 | This makes the hook buffer-local if needed. |
| 725 | To make a hook variable buffer-local, always use | ||
| 726 | `make-local-hook', not `make-local-variable'. | ||
| 727 | 728 | ||
| 728 | HOOK should be a symbol, and FUNCTION may be any valid function. If | 729 | HOOK should be a symbol, and FUNCTION may be any valid function. If |
| 729 | HOOK is void, it is first set to nil. If HOOK's value is a single | 730 | HOOK is void, it is first set to nil. If HOOK's value is a single |
| 730 | function, it is changed to a list of functions." | 731 | function, 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 | ||
| 757 | The optional third argument, LOCAL, if non-nil, says to modify | 759 | The optional third argument, LOCAL, if non-nil, says to modify |
| 758 | the hook's buffer-local value rather than its default value. | 760 | the hook's buffer-local value rather than its default value. |
| 759 | This makes the hook buffer-local if needed. | 761 | This makes the hook buffer-local if needed." |
| 760 | To 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. |
| 1349 | If OLDTABLE is non-nil, copy OLDTABLE. | 1350 | If OLDTABLE is non-nil, copy OLDTABLE. |
| 1350 | Otherwise, create a syntax table which inherits | 1351 | Otherwise, create a syntax table which inherits from the |
| 1351 | all letters and control characters from the standard syntax table; | 1352 | `standard-syntax-table'." |
| 1352 | other 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) |