[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
signature.asc
Description: Digital signature
- Re: Lexical vs. dynamic: small examples?, (continued)
RE: [External] : Lexical vs. dynamic: small examples?, Drew Adams, 2021/08/14
Re: Lexical vs. dynamic: small examples?, Gregory Heytings, 2021/08/14
Re: Lexical vs. dynamic: small examples?, tomas, 2021/08/14
RE: [External] : Re: Lexical vs. dynamic: small examples?, Drew Adams, 2021/08/14
- Re: [External] : Re: Lexical vs. dynamic: small examples?, Emanuel Berg, 2021/08/14
- Re: [External] : Re: Lexical vs. dynamic: small examples?, Emanuel Berg, 2021/08/14
- Re: [External] : Re: Lexical vs. dynamic: small examples?, Emanuel Berg, 2021/08/14
- Re: [External] : Re: Lexical vs. dynamic: small examples?, Emanuel Berg, 2021/08/15
- Re: [External] : Re: Lexical vs. dynamic: small examples?, Emanuel Berg, 2021/08/15
- RE: [External] : Re: Lexical vs. dynamic: small examples?, Drew Adams, 2021/08/15
- Re: [External] : Re: Lexical vs. dynamic: small examples?, Emanuel Berg, 2021/08/15