* version> and version>=
@ 2022-02-01 14:50 goncholden via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 16+ messages in thread
From: goncholden via Users list for the GNU Emacs text editor @ 2022-02-01 14:50 UTC (permalink / raw)
To: goncholden via Users list for the GNU Emacs text editor
I have seen that the possible completions for version are:
version<
version<=
Could there also be
version>
version>=
^ permalink raw reply [flat|nested] 16+ messages in thread
* version> and version>=
@ 2022-02-01 18:01 goncholden
2022-02-01 23:20 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-02 3:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 16+ messages in thread
From: goncholden @ 2022-02-01 18:01 UTC (permalink / raw)
To: Drew Adams; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, February 1st, 2022 at 5:52 PM, Drew Adams <drew.adams@oracle.com> wrote:
> I have seen that the possible completions for version are:
>
> version<
>
> version<=
>
> Could there also be
>
> version>
>
> version>=
(not (version<= V1 V2))
(not (version< V1 V2))
What is the best way to check the version
(if (version< emacs-version "28.0")
or
(< emacs-version 28.0)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-01 18:01 version> and version>= goncholden
@ 2022-02-01 23:20 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-02 3:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 16+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-01 23:20 UTC (permalink / raw)
To: help-gnu-emacs
goncholden wrote:
> What is the best way to check the version
>
> (version< emacs-version "28.0")
This, since it works.
BTW in Gnus article mode the paren highlight matches the right
parenthesis with the less-than sign ...
> or
>
> (< emacs-version 28.0)
DNC. Eval it to learn why ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-01 18:01 version> and version>= goncholden
2022-02-01 23:20 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-02-02 3:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-02-02 10:21 ` goncholden
1 sibling, 1 reply; 16+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-02-02 3:47 UTC (permalink / raw)
To: help-gnu-emacs
> What is the best way to check the version
>
> (if (version< emacs-version "28.0")
>
> or
>
> (< emacs-version 28.0)
(< emacs-major-version 28)
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* version> and version>=
2022-02-02 3:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-02-02 10:21 ` goncholden
2022-02-02 13:38 ` Tassilo Horn
2022-02-02 15:00 ` Yuri Khan
0 siblings, 2 replies; 16+ messages in thread
From: goncholden @ 2022-02-02 10:21 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, February 2nd, 2022 at 3:47 AM, Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> What is the best way to check the version
>
> (if (version< emacs-version "28.0")
>
> or
>
> (< emacs-version 28.0)
(< emacs-major-version 28)
Stefan
Am working on colouring comments according to whether the background is light or dark.
But I am encountering
if: Wrong type argument: number-or-marker-p, "27.2"
Code:
(defvar annotation-chroma
'( (dark . ((low . "#8300E0") (mid . "#AA33FF") (high . "#C370FF")))
(light . ((low . "#C16BFF") (mid . "#AA33FF") (high . "#8000DB"))) )
"Colour contrast for comments, indigo on dark and light background.")
(defun annotation-typeface (chroma)
"Set the foreground colour for comments."
(let* ( (colors annotation-chroma)
(levels
(if (>= emacs-version 28.0)
(alist-get (frame--current-backround-mode nil) colors)
(message "GonCholden"))) )
(face-remap-add-relative 'font-lock-comment-face
`(:foreground ,(alist-get chroma levels)))
(message "annotation: %s contrast" chroma)) )
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 10:21 ` goncholden
@ 2022-02-02 13:38 ` Tassilo Horn
2022-02-02 13:48 ` goncholden
2022-02-02 15:00 ` Yuri Khan
1 sibling, 1 reply; 16+ messages in thread
From: Tassilo Horn @ 2022-02-02 13:38 UTC (permalink / raw)
To: goncholden; +Cc: help-gnu-emacs, Stefan Monnier
goncholden <goncholden@protonmail.com> writes:
>> (< emacs-version 28.0)
>
> (< emacs-major-version 28)
>
> Stefan
>
> Am working on colouring comments according to whether the background
> is light or dark.
>
> But I am encountering
>
> if: Wrong type argument: number-or-marker-p, "27.2"
>
>
> Code:
> (if (>= emacs-version 28.0)
`emacs-version' is a string, 28.0 is a float. You cannot compare them.
Stefan suggested to use `emacs-major-version' with 28 (both integers)
instead.
HTH,
Tassilo
^ permalink raw reply [flat|nested] 16+ messages in thread
* version> and version>=
2022-02-02 13:38 ` Tassilo Horn
@ 2022-02-02 13:48 ` goncholden
2022-02-02 13:52 ` Tassilo Horn
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: goncholden @ 2022-02-02 13:48 UTC (permalink / raw)
To: Tassilo Horn; +Cc: Stefan Monnier, help-gnu-emacs
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, February 2nd, 2022 at 1:38 PM, Tassilo Horn <tsdh@gnu.org> wrote:
> goncholden goncholden@protonmail.com writes:
>
> > > (< emacs-version 28.0)
> >
> > (< emacs-major-version 28)
> >
> > Stefan
> >
> > Am working on colouring comments according to whether the background
> >
> > is light or dark.
> >
> > But I am encountering
> >
> > if: Wrong type argument: number-or-marker-p, "27.2"
> >
> > Code:
> >
> > (if (>= emacs-version 28.0)
>
> `emacs-version' is a string, 28.0 is a float. You cannot compare them. Stefan suggested to use` emacs-major-version' with 28 (both integers)
> instead.
>
> HTH,
> Tassilo
It would be convenient if there was a function that could handle floats, so that one can condition
not just on a major version, but upon the complete version number.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 13:48 ` goncholden
@ 2022-02-02 13:52 ` Tassilo Horn
2022-02-02 14:14 ` goncholden
2022-02-02 14:15 ` Tassilo Horn
2022-02-02 14:51 ` Eli Zaretskii
2 siblings, 1 reply; 16+ messages in thread
From: Tassilo Horn @ 2022-02-02 13:52 UTC (permalink / raw)
To: goncholden; +Cc: help-gnu-emacs, Stefan Monnier
goncholden <goncholden@protonmail.com> writes:
>> `emacs-version' is a string, 28.0 is a float. You cannot compare
>> them. Stefan suggested to use` emacs-major-version' with 28 (both
>> integers) instead.
>
> It would be convenient if there was a function that could handle
> floats, so that one can condition not just on a major version, but
> upon the complete version number.
Well, usually there should be no API-breaking changes between Emacs X.Y
und X.Z, so version-checks more detailed than major version shouldn't be
needed.
And there is already
(version<= "28.0" emacs-version)
if you want to test with version strings and have more control over
minor and even micro version. (Using floats for versions is just plain
wrong.)
Bye,
Tassilo
^ permalink raw reply [flat|nested] 16+ messages in thread
* version> and version>=
2022-02-02 13:52 ` Tassilo Horn
@ 2022-02-02 14:14 ` goncholden
2022-02-02 14:23 ` Tassilo Horn
0 siblings, 1 reply; 16+ messages in thread
From: goncholden @ 2022-02-02 14:14 UTC (permalink / raw)
To: Tassilo Horn; +Cc: Stefan Monnier, help-gnu-emacs
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, February 2nd, 2022 at 1:52 PM, Tassilo Horn <tsdh@gnu.org> wrote:
> goncholden goncholden@protonmail.com writes:
>
> > > `emacs-version' is a string, 28.0 is a float. You cannot compare them. Stefan suggested to use` emacs-major-version' with 28 (both
> > > integers) instead.
> >
> > It would be convenient if there was a function that could handle
> > floats, so that one can condition not just on a major version, but
> > upon the complete version number.
>
> Well, usually there should be no API-breaking changes between Emacs X.Y
> und X.Z, so version-checks more detailed than major version shouldn't be
> needed.
>
> And there is already
>
> (version<= "28.0" emacs-version)
>
> if you want to test with version strings and have more control over
> minor and even micro version. (Using floats for versions is just plain
> wrong.)
>
> Bye,
> Tassilo
You make a good point about the "No API-Breaking Changes". Then perhaps
(>= emacs-version "28.0") if one does not like floats. Although there is
nothing wrong about floats because version numbers can easily be sorted
numerically. In the old days, strings took over. I wish scripts could
handle numeric computations better.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 13:48 ` goncholden
2022-02-02 13:52 ` Tassilo Horn
@ 2022-02-02 14:15 ` Tassilo Horn
2022-02-02 14:27 ` goncholden
2022-02-02 14:51 ` Eli Zaretskii
2 siblings, 1 reply; 16+ messages in thread
From: Tassilo Horn @ 2022-02-02 14:15 UTC (permalink / raw)
To: goncholden; +Cc: help-gnu-emacs, Stefan Monnier
goncholden <goncholden@protonmail.com> writes:
>> `emacs-version' is a string, 28.0 is a float. You cannot compare
>> them. Stefan suggested to use` emacs-major-version' with 28 (both
>> integers) instead.
>
> It would be convenient if there was a function that could handle
> floats, so that one can condition not just on a major version, but
> upon the complete version number.
As said in my other mail, floats are not good for this because in math,
1.2 is greater than 1.10 but with versions, 1.10 is greater than 1.2.
See my other mail: if you really need to check major, minor, and maybe
even micro version, then use `version<' with the version strings.
Bye,
Tassilo
PS: Could you please teach your mail client not to remove the Re: from
the subject of replies? Every reply of yours looks like a new
thread on first sight.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 14:14 ` goncholden
@ 2022-02-02 14:23 ` Tassilo Horn
0 siblings, 0 replies; 16+ messages in thread
From: Tassilo Horn @ 2022-02-02 14:23 UTC (permalink / raw)
To: goncholden; +Cc: help-gnu-emacs, Stefan Monnier
goncholden <goncholden@protonmail.com> writes:
> Although there is nothing wrong about floats because version numbers
> can easily be sorted numerically.
No, they cannot.
ELISP> (sort '(1.2 1.12) #'<)
(1.12 1.2)
ELISP> (sort '("1.2" "1.12") #'version<)
("1.2" "1.12")
Also, the common version 0.1 (and many other fractions) cannot be
represented as a float. 0.1 is not really 0.1 which you only see if you
print enough digits:
*** Eval error *** Format string ends in middle of format specifier
ELISP> (format "%.20f" 0.1)
"0.10000000000000000555"
Aside from that, versions tend to have the form major.minor.micro with
optionally even stuff like -<alpha|beta|rc><number> appended. Hard to
encode into a float.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 16+ messages in thread
* version> and version>=
2022-02-02 14:15 ` Tassilo Horn
@ 2022-02-02 14:27 ` goncholden
2022-02-02 14:30 ` Tassilo Horn
0 siblings, 1 reply; 16+ messages in thread
From: goncholden @ 2022-02-02 14:27 UTC (permalink / raw)
To: Tassilo Horn; +Cc: Stefan Monnier, help-gnu-emacs
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, February 2nd, 2022 at 2:15 PM, Tassilo Horn <tsdh@gnu.org> wrote:
> goncholden goncholden@protonmail.com writes:
>
> > > `emacs-version' is a string, 28.0 is a float. You cannot compare them. Stefan suggested to use` emacs-major-version' with 28 (both
> > >
> > > integers) instead.
> >
> > It would be convenient if there was a function that could handle
> >
> > floats, so that one can condition not just on a major version, but
> >
> > upon the complete version number.
>
> As said in my other mail, floats are not good for this because in math,
> 1.2 is greater than 1.10 but with versions, 1.10 is greater than 1.2.
> See my other mail: if you really need to check major, minor, and maybe
> even micro version, then use `version<' with the version strings.
I missed that, you are correct then.
> Bye,
> Tassilo
> PS: Could you please teach your mail client not to remove the Re: from
> the subject of replies? Every reply of yours looks like a new
> thread on first sight.
Ok, I thought the Re: should not be there.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 14:27 ` goncholden
@ 2022-02-02 14:30 ` Tassilo Horn
0 siblings, 0 replies; 16+ messages in thread
From: Tassilo Horn @ 2022-02-02 14:30 UTC (permalink / raw)
To: goncholden; +Cc: help-gnu-emacs, Stefan Monnier
goncholden <goncholden@protonmail.com> writes:
>> PS: Could you please teach your mail client not to remove the Re:
>> from the subject of replies? Every reply of yours looks like a new
>> thread on first sight.
>
> Ok, I thought the Re: should not be there.
It should. It clearly shows that this mail is a reply to another mail.
It is alright to remove successive Re:s, e.g., with
Re: Re: AW: Re: version> and version>=
it's alright to strip down to
Re: version> and version>=
because the additional Re:s and the "translated" AW: were inserted by
broken clients like Outlook.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 13:48 ` goncholden
2022-02-02 13:52 ` Tassilo Horn
2022-02-02 14:15 ` Tassilo Horn
@ 2022-02-02 14:51 ` Eli Zaretskii
2 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2022-02-02 14:51 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 02 Feb 2022 13:48:56 +0000
> From: goncholden <goncholden@protonmail.com>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, help-gnu-emacs@gnu.org
>
> It would be convenient if there was a function that could handle floats, so that one can condition
> not just on a major version, but upon the complete version number.
We already have that: version< and similar functions.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 10:21 ` goncholden
2022-02-02 13:38 ` Tassilo Horn
@ 2022-02-02 15:00 ` Yuri Khan
2022-02-02 15:07 ` goncholden
1 sibling, 1 reply; 16+ messages in thread
From: Yuri Khan @ 2022-02-02 15:00 UTC (permalink / raw)
To: goncholden; +Cc: help-gnu-emacs, Stefan Monnier
On Wed, 2 Feb 2022 at 17:21, goncholden <goncholden@protonmail.com> wrote:
> > What is the best way to check the version
> >
> > (if (version< emacs-version "28.0")
> >
> > or
> >
> > (< emacs-version 28.0)
A typical case of the XY Problem. You want to solve X, you think Y
will help you, and you ask how to do Y. You will get helpful comments
on how to do Y, but miss out on all the better ways to do X.
> Am working on colouring comments according to whether the background is light or dark.
This is your original X. The solution to that is to look at
(frame-parameter nil 'background-mode), as told in the other thread.
> (frame--current-backround-mode nil)
This is your assumed solution, Y.
In fact, you have another case of XY here. You discover
‘frame--current-background-mode’ is not available in Emacs < 28. Your
actual problem is “how do I know a function is available in my Emacs”.
You assume you need to check the Emacs version, but in fact you should
check for features, not versions. (fboundp
'frame--current-background-mode) will return t if the function is
available, nil if not.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: version> and version>=
2022-02-02 15:00 ` Yuri Khan
@ 2022-02-02 15:07 ` goncholden
0 siblings, 0 replies; 16+ messages in thread
From: goncholden @ 2022-02-02 15:07 UTC (permalink / raw)
To: Yuri Khan; +Cc: Stefan Monnier, help-gnu-emacs
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, February 2nd, 2022 at 3:00 PM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> On Wed, 2 Feb 2022 at 17:21, goncholden goncholden@protonmail.com wrote:
>
> > > What is the best way to check the version
> > >
> > > (if (version< emacs-version "28.0")
> > >
> > > or
> > >
> > > (< emacs-version 28.0)
>
> A typical case of the XY Problem. You want to solve X, you think Y
>
> will help you, and you ask how to do Y. You will get helpful comments
>
> on how to do Y, but miss out on all the better ways to do X.
>
> > Am working on colouring comments according to whether the background is light or dark.
>
> This is your original X. The solution to that is to look at
>
> (frame-parameter nil 'background-mode), as told in the other thread.
>
> > (frame--current-backround-mode nil)
>
> This is your assumed solution, Y.
>
> In fact, you have another case of XY here. You discover
> ‘frame--current-background-mode’ is not available in Emacs < 28. Your
> actual problem is “how do I know a function is available in my Emacs”.
>
> You assume you need to check the Emacs version, but in fact you should
> check for features, not versions. (fboundp
> 'frame--current-background-mode) will return t if the function is
> available, nil if not.
Correct, the availability problem winded me up a little bit.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-02-02 15:07 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-01 18:01 version> and version>= goncholden
2022-02-01 23:20 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-02 3:47 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-02-02 10:21 ` goncholden
2022-02-02 13:38 ` Tassilo Horn
2022-02-02 13:48 ` goncholden
2022-02-02 13:52 ` Tassilo Horn
2022-02-02 14:14 ` goncholden
2022-02-02 14:23 ` Tassilo Horn
2022-02-02 14:15 ` Tassilo Horn
2022-02-02 14:27 ` goncholden
2022-02-02 14:30 ` Tassilo Horn
2022-02-02 14:51 ` Eli Zaretskii
2022-02-02 15:00 ` Yuri Khan
2022-02-02 15:07 ` goncholden
-- strict thread matches above, loose matches on Subject: below --
2022-02-01 14:50 goncholden via Users list for the GNU Emacs text editor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).