According to the
write-file-functions doc-string, "[t]his variable's value is permanent if it is given a local binding."
Step 1: Start from
emacs -qusing Emacs 25.2.1.
Step 2: Switch to the
Step 3: Type the following in the
*scratch*buffer, so that it gets modified and so that we can later evaluate what we typed.
(add-hook 'write-file-functions (lambda () (message "hello-world")) 'append 'local)
Step 4: Evaluate the statement that we typed in Step 3 above -- e.g.,
M-x save-bufferand save it anywhere that is appropriate. I chose to call the file
fooand I saved it as
M-x describe-variable RET write-file-functions RET; or,
C-h vand then the name of the variable we are looking up.
write-file-functions is a variable defined in ‘files.el’.
Its value is nil
I expected the
write-file-functions hook to maintain the original value because it is
permanent when given a local binding. Why is my assumption incorrect?