From 79372165fe5a1ba70dd74f0333141ce40d7829af Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 23 Nov 2000 22:54:54 +0000 Subject: [PATCH] (add-hook, remove-hook): Don't call make-local-hook if the variable is make-variable-buffer-local. --- lisp/ChangeLog | 5 ++++- lisp/subr.el | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d97542037ea..13f9a463000 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2000-11-23 Stefan Monnier + * subr.el (add-hook, remove-hook): Don't call make-local-hook + if the variable is make-variable-buffer-local. + * progmodes/ada-stmt.el (ada-template-map): Initialize and bind it to C-c t in ada-mode-map. (ada-stmt-mode-hook): New function extracted from old code. @@ -887,7 +890,7 @@ * complete.el (partial-completion-mode): Drop unneeded positional args. * info.el (Info-mode): - * comint.el (comint-mode): Don't both with make-local-hook. + * comint.el (comint-mode): Don't bother with make-local-hook. * log-edit.el (log-edit-menu): New menu. diff --git a/lisp/subr.el b/lisp/subr.el index 1c494d763eb..6e43d28a8c6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -227,6 +227,15 @@ but optional second arg NODIGITS non-nil treats them like other chars." (define-key map (char-to-string loop) 'digit-argument) (setq loop (1+ loop)))))) +(when (and (not (fboundp 'set-keymap-parents)) + (fboundp 'make-composed-keymap)) + (defun set-keymap-parents (map parents) + "Set MAP to inherit from PARENTS. +PARENTS can be either nil or a keymap or a list of keymaps." + (set-keymap-parent map + (if (or (null parents) (keymapp parents)) parents + (make-composed-keymap parents))))) + ;Moved to keymap.c ;(defun copy-keymap (keymap) ; "Return a copy of KEYMAP" @@ -697,6 +706,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. @@ -716,7 +726,7 @@ 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 (make-local-hook hook) + (if local (unless (local-variable-if-set-p hook) (make-local-hook hook)) ;; 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))) @@ -747,7 +757,7 @@ To make a hook variable buffer-local, always use `make-local-hook', not `make-local-variable'." (or (boundp hook) (set hook nil)) (or (default-boundp hook) (set-default hook nil)) - (if local (make-local-hook hook) + (if local (unless (local-variable-if-set-p hook) (make-local-hook hook)) ;; 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))) @@ -1245,13 +1255,9 @@ Modifies the match data; use `save-match-data' if necessary." (defun subst-char-in-string (fromchar tochar string &optional inplace) "Replace FROMCHAR with TOCHAR in STRING each time it occurs. Unless optional argument INPLACE is non-nil, return a new string." - (let ((i (length string)) - (newstr (if inplace string (copy-sequence string)))) - (while (> i 0) - (setq i (1- i)) - (if (eq (aref newstr i) fromchar) - (aset newstr i tochar))) - newstr)) + (if inplace (error "bouh!")) + (mapconcat (lambda (c) (char-to-string (if (equal c fromchar) tochar c))) + string "")) (defun replace-regexp-in-string (regexp rep string &optional fixedcase literal subexp start) -- 2.39.2