bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9469: buffer-local variables seem to remember previous values


From: Le Wang
Subject: bug#9469: buffer-local variables seem to remember previous values
Date: Mon, 12 Sep 2011 03:18:39 +0800

On Mon, Sep 12, 2011 at 2:54 AM, Lars Magne Ingebrigtsen <address@hidden> wrote:
> If I read your code correctly, Andreas is correct and precise as usual,
> if a bit terse.  :-)

Ok, that was my fault.  I didn't know how to make heads or tails of
the situation, so included some red herrings in my original snippet.
This should clarify my exact point of confusion:

(setq foo-alist nil)
        ;; => nil

(defun reset-var-in-foo-alist ()
  (push '(:var . 0) foo-alist))
        ;; => reset-var-in-foo-alist

(defun increment-var-in-foo-alist ()
  (let ((var-cons (assq :var foo-alist)))
    (setcdr var-cons (1+ (cdr var-cons)))))
        ;; => increment-var-in-foo-alist


(reset-var-in-foo-alist)
        ;; => ((:var . 0))
(increment-var-in-foo-alist)
        ;; => 1
(reset-var-in-foo-alist)
        ;; => ((:var . 1) (:var . 1))


Again, my misunderstanding was that in `reset-var-in-foo-alist' quote
does not cons, I assumed it did.

-- 
Le





reply via email to

[Prev in Thread] Current Thread [Next in Thread]