[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emac
From: |
Richard Stallman |
Subject: |
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? |
Date: |
Tue, 05 Sep 2023 20:58:38 -0400 |
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> For example, in CC Mode there is a chunk of code looking like ....
> (when (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later.
> (electric-indent-local-mode (if c-electric-flag 1 0)))
> , and there are quite a few instances like it. Here, there is a comment
> about which versions are relevant, but that is somewhat unusual. Note
> here that we would have to test both the major and minor version numbers
> to do this correctly.
> I intend to replace that code with
> (static-if (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later.
> (electric-indent-local-mode (if c-electric-flag 1 0)))
> .. (hash-if has been renamed static-if.) It would be more work to
> replace it with
> (when (or (> emacs-major-version 24)
> (and (= emacs-major-version 24)
> (>= emacs-minor-version 4)))
> (electric-indent-local-mode (if c-electric-flag 1 0)))
If you want to have a conditional about version mumbers,
I think that is the right way to write it.
Or, if you want to keep the condition about the availability of
electric-indent-local-mode, how about keeping the code unchanged
> (when (fboundp 'electric-indent-local-mode) ; Emacs 24.4 or later.
> (electric-indent-local-mode (if c-electric-flag 1 0)))
and inform the byte compiler that (fboundp 'electric-indent-local-mode)
can be optimized based on the Emacs cersion? This way you won't need
to change the source code, and we will get the ideal results,
> static-if is a completely ordinary macro which is 10 lines long
> (including doc string), and there's a new section in the elisp manual for
> it.
I think the simplicity of the source code as it will be
counts for more than the simplicity of a new macro
which, with my approach, we don't need o add.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, (continued)
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Stefan Monnier, 2023/09/02
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Stefan Monnier, 2023/09/02
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Richard Stallman, 2023/09/03
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?,
Richard Stallman <=
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Andreas Schwab, 2023/09/06
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Alan Mackenzie, 2023/09/06
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Alan Mackenzie, 2023/09/06
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Richard Stallman, 2023/09/08
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Ihor Radchenko, 2023/09/09
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Richard Stallman, 2023/09/09
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Ihor Radchenko, 2023/09/10
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Richard Stallman, 2023/09/13
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Ihor Radchenko, 2023/09/20
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Ulrich Mueller, 2023/09/05