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

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

Re: Lexical vs. dynamic: small examples?


From: Emanuel Berg
Subject: Re: Lexical vs. dynamic: small examples?
Date: Sat, 14 Aug 2021 23:05:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Gregory Heytings wrote:

>>> (defvar saved-buffer-read-only)
>>> (defun delete-whitespace-at-eol ()
>>>   (interactive)
>>>   (setq saved-buffer-read-only buffer-read-only)
>>>   (setq buffer-read-only nil)
>>>   (save-excursion (replace-regexp " *$" "" nil (point-min) (point-max)))
>>>   (setq buffer-read-only saved-buffer-read-only))
>>
>> OK, but you don't need to store the old value in a global variable...
>>
> Of course you do, you need to restore the original value [...]

But there is still no need to use a global variable...

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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