Two examples (both are in the
*scratch* buffer and under lexical scoping rule):
(setq xx :default) (let ((xx :let)) (with-current-buffer (get-buffer-create "tmp") (make-local-variable 'xx) ;; set the value of xx, buffer-locally (setq xx :tmp)) ; exit from "tmp" xx) ; ==> :tmp ;; I think that: after exiting from "tmp", ;; xx would restore its previous value ;; bound by `let`. ;; But in fact, it didn't evaluate to :let. (with-current-buffer "tmp" xx) ; ==> :default ;; It seems that even though `let`-binding was ;; created in "*scratch*", it removed the ;; binding of the buffer-local variable ;; in the buffer "tmp" so that this form didn't ;; evaluate to :tmp.
(defvar yy :default) (let ((yy :let)) (with-current-buffer (get-buffer-create "tmp") (make-local-variable 'yy) (setq yy :tmp)) yy) ; ==> :let ;; yy restored its value created by `let`-bing ;; after switching back to the original buffer. ;; This is intuitive. (with-current-buffer "tmp" yy) ; ==> :tmp ;; `let`-binding didn't remove the binding created ;; by (setq yy :tmp). ;; It behaved differently from the previous example.
These comments show my two kinds of understanding, neither is self-consistent. And they are contradictory to each other.
Why are the results different for these two examples?
Is there any section, in the manual, explaining the above behaviors?
I did not find it.