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

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

bug#26624: 26.0.50; Generalized variable `buffer-local-value' does't res


From: Michael Heerdegen
Subject: bug#26624: 26.0.50; Generalized variable `buffer-local-value' does't restore local flag
Date: Sun, 11 Feb 2018 21:56:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Philipp Stephani <p.stephani2@gmail.com> writes:

> it should rather expand to
>
> (let ((old-state (internal-get-state place)))
>   (setf place val)
>   (unwind-protect body
>     (internal-reset-state place old-state)))
>
> with suitably defined `internal-get-state` and
> `internal-reset-state`. For most use cases `internal-get-state` and
> `internal-reset-state` could just be `identity` and `setf `, but for
> the cases discussed here they would contain additional information.

Is that even well-defined?  What happens when the code inside `letf'
also alters this state?

For example, code like

#+begin_src emacs-lisp
(let ((my-alist '((x 1))))
  (cl-letf (((alist-get 'y my-alist) 2))
    (push (cons 'y 17) my-alist))
  my-alist)
#+end_src

or

#+begin_src emacs-lisp
(cl-letf (((buffer-local-value 'x my-buffer) 20))
  ...
  (with-current-buffer my-buffer
    (set (make-local-variable 'x) 0))
  ...)
#+end_src

what would "reset the state" mean?


Michael.





reply via email to

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