(while (cdr x)
(setq x (cdr x)))
x))
+
+(defun assoc-default (key alist &optional test default)
+ "Find object KEY in a pseudo-alist ALIST.
+ALIST is a list of conses or objects. Each element (or the element's car,
+if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY).
+If that is non-nil, the element matches;
+then `assoc-default' returns the element's cdr, if it is a cons,
+or DEFAULT if the element is not a cons.
+
+If no element matches, the value is nil.
+If TEST is omitted or nil, `equal' is used."
+ (let (found (tail alist) value)
+ (while (and tail (not found))
+ (let ((elt (car tail)))
+ (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key)
+ (setq found t value (if (consp elt) (cdr elt) default))))
+ (setq tail (cdr tail)))
+ value))
\f
;;;; Keymap support.
(defalias 'compiled-function-p 'byte-code-function-p)
(defalias 'define-function 'defalias)
-(defun sref (string byte-index)
- "Obsolete function returning a character in STRING at BYTE-INDEX.
-Please convert your programs to use `aref' with character-base index."
- (let ((byte 0) (char 0))
- (while (< byte byte-index)
- (setq byte (+ byte (char-bytes (aref string char)))
- char (1+ char)))
- (aref string char)))
+(defalias 'sref 'aref)
+(make-obsolete 'sref 'aref)
+(make-obsolete 'char-bytes "Now this function always returns 1")
;; Some programs still use this as a function.
(defun baud-rate ()
(and (local-variable-if-set-p hook)
(not (memq t (symbol-value hook)))))
;; Alter the local value only.
- (or (if (consp function)
+ (or (if (or (consp function) (byte-code-function-p function))
(member function (symbol-value hook))
(memq function (symbol-value hook)))
(set hook
(cons function (symbol-value hook)))))
;; Alter the global value (which is also the only value,
;; if the hook doesn't have a local value).
- (or (if (consp function)
+ (or (if (or (consp function) (byte-code-function-p function))
(member function (default-value hook))
(memq function (default-value hook)))
(set-default hook
or the octal character code.
RET terminates the character code and is discarded;
any other non-digit terminates the character code and is then used as input."))
- (and prompt (message "%s-" prompt))
- (setq char (read-event))
+ (setq char (read-event (and prompt (format "%s-" prompt)) t))
(if inhibit-quit (setq quit-flag nil)))
;; Translate TAB key into control-I ASCII character, and so on.
(and char