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

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

Re: version> and version>=


From: Yuri Khan
Subject: Re: version> and version>=
Date: Wed, 2 Feb 2022 22:00:59 +0700

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.



reply via email to

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