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: tomas
Subject: Re: Lexical vs. dynamic: small examples?
Date: Sat, 14 Aug 2021 23:13:31 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Aug 14, 2021 at 11:05:53PM +0200, Emanuel Berg via Users list for the 
GNU Emacs text editor wrote:
> 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...

That's not the point. You perhaps don't want to trample on one. The
let-binding helps you with that. In both cases.

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

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