856 |
(set (make-local-variable hook) (list t))) |
(set (make-local-variable hook) (list t))) |
857 |
;; Detect the case where make-local-variable was used on a hook |
;; Detect the case where make-local-variable was used on a hook |
858 |
;; and do what we used to do. |
;; and do what we used to do. |
859 |
(unless (and (consp (symbol-value hook)) (memq t (symbol-value hook))) |
(when (and (local-variable-p hook) |
860 |
|
(not (and (consp (symbol-value hook)) |
861 |
|
(memq t (symbol-value hook))))) |
862 |
(setq local t))) |
(setq local t))) |
863 |
(let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
(let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
864 |
;; If the hook value is a single function, turn it into a list. |
;; If the hook value is a single function, turn it into a list. |
880 |
list of hooks to run in HOOK, then nothing is done. See `add-hook'. |
list of hooks to run in HOOK, then nothing is done. See `add-hook'. |
881 |
|
|
882 |
The optional third argument, LOCAL, if non-nil, says to modify |
The optional third argument, LOCAL, if non-nil, says to modify |
883 |
the hook's buffer-local value rather than its default value. |
the hook's buffer-local value rather than its default value." |
|
This makes the hook buffer-local if needed." |
|
884 |
(or (boundp hook) (set hook nil)) |
(or (boundp hook) (set hook nil)) |
885 |
(or (default-boundp hook) (set-default hook nil)) |
(or (default-boundp hook) (set-default hook nil)) |
886 |
(if local (unless (local-variable-if-set-p hook) |
;; Do nothing if LOCAL is t but this hook has no local binding. |
887 |
(set (make-local-variable hook) (list t))) |
(unless (and local (not (local-variable-p hook))) |
888 |
;; Detect the case where make-local-variable was used on a hook |
;; Detect the case where make-local-variable was used on a hook |
889 |
;; and do what we used to do. |
;; and do what we used to do. |
890 |
(unless (and (consp (symbol-value hook)) (memq t (symbol-value hook))) |
(when (and (local-variable-p hook) |
891 |
(setq local t))) |
(not (and (consp (symbol-value hook)) |
892 |
(let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
(memq t (symbol-value hook))))) |
893 |
;; Remove the function, for both the list and the non-list cases. |
(setq local t)) |
894 |
(if (or (not (listp hook-value)) (eq (car hook-value) 'lambda)) |
(let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
895 |
(if (equal hook-value function) (setq hook-value nil)) |
;; Remove the function, for both the list and the non-list cases. |
896 |
(setq hook-value (delete function (copy-sequence hook-value)))) |
(if (or (not (listp hook-value)) (eq (car hook-value) 'lambda)) |
897 |
;; If the function is on the global hook, we need to shadow it locally |
(if (equal hook-value function) (setq hook-value nil)) |
898 |
;;(when (and local (member function (default-value hook)) |
(setq hook-value (delete function (copy-sequence hook-value)))) |
899 |
;; (not (member (cons 'not function) hook-value))) |
;; If the function is on the global hook, we need to shadow it locally |
900 |
;; (push (cons 'not function) hook-value)) |
;;(when (and local (member function (default-value hook)) |
901 |
;; Set the actual variable |
;; (not (member (cons 'not function) hook-value))) |
902 |
(if (not local) |
;; (push (cons 'not function) hook-value)) |
903 |
(set-default hook hook-value) |
;; Set the actual variable |
904 |
(if (equal hook-value '(t)) |
(if (not local) |
905 |
(kill-local-variable hook) |
(set-default hook hook-value) |
906 |
(set hook hook-value))))) |
(if (equal hook-value '(t)) |
907 |
|
(kill-local-variable hook) |
908 |
|
(set hook hook-value)))))) |
909 |
|
|
910 |
(defun add-to-list (list-var element &optional append) |
(defun add-to-list (list-var element &optional append) |
911 |
"Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. |
"Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. |