Commit 08b1f8a1 authored by Gerd Moellmann's avatar Gerd Moellmann

(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.
parent 802a980a
......@@ -396,10 +396,7 @@ of the map. Note that AFTER must be an event type (like KEY), NOT a command
\(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 @@ The order of bindings in a keymap matters when it is used as a menu."
(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 @@ The order of bindings in a keymap matters when it is used as a menu."
(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 @@ work in concert: running the hook actually runs all the hook
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 @@ Do not use `make-local-variable' to make a hook variable buffer-local."
(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 @@ FUNCTION is added at the end.
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 @@ list of hooks to run in HOOK, then nothing is done. See `add-hook'.
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 @@ and replace a sub-expression, e.g.
;; 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 @@ and replace a sub-expression, e.g.
(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 @@ If DIR-FLAG is non-nil, create a new empty directory instead of a file."
(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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment