Q: How can I use y-or-n-p
-- instead of yes-or-no-p
-- when calling kill-buffer
for just the duration of a particular function?
In other words, I want the behavior of (fset 'yes-or-no-p 'y-or-n-p)
but only for the duration of a particular function without any lasting effect.
CAVEAT: I would like to please avoid using (fset 'yes-or-no-p 'y-or-n-p)
at the outset and (fset 'yes-or-no-p 'yes-or-no-p)
at the tail end of the function, just in case I decide to exit out of the function with a 'quit
signal such as C-g
, in which case the effect would become long-lasting rather than merely temporary.
Here is a test snippet to start with:
(let* (
(filename "/private/tmp/foofile")
(buf (get-buffer-create "*foo*")))
(with-current-buffer buf
(write-file filename)
(insert "Every good boy deserves fudge."))
(kill-buffer buf)
(delete-file filename))