emacs-devel
[Top][All Lists]
Advanced

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

[Suggestion] New function `emacs-version>='


From: Wedler, Christoph
Subject: [Suggestion] New function `emacs-version>='
Date: Fri, 2 May 2003 21:55:31 +0200

I would like to see the following function defined in Emacs[1]:

(defun emacs-version>= (major &optional minor patch)
  "Return true if the Emacs version is >= to the given version.
The version is provided by the required argument MAJOR, and the optional
arguments MINOR and PATCH.  Only the non-nil arguments are used in the
test."
  (cond ((> emacs-major-version major))
        ((< emacs-major-version major) nil)
        ((null minor))
        ((> emacs-minor-version minor))
        ((< emacs-minor-version minor) nil)
        ((null patch))
        ((string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)" emacs-version)
         (>= (string-to-int (match-string 1 emacs-version)) patch)))))

(Of course, a constant `emacs-patch-version' could be defined, as well.
The function above would be changed to use it.)

Specific features or bug fixes are only available in newer Emacsen and
packages must be able to cope with it.

A test like `fboundp' is only the right test iff the new feature to test
for availibility is a function, it is not the right test for

 - I need to check the availibility for feature/fix A
 - feature/fix A is provided with Emacs-X.Y
 - function F is new with Emacs-X.Y
 - therefore I test with (fboundp 'F)

The right test is

 - I need to check the availibility for feature/fix A
 - feature/fix A is provided with Emacs-X.Y
 - therefore I test with (emacs-version>= X Y)

Like it or not, a test like `emacs-version>=' would be useful for many
packages, thus a corresponding function would be useful to define in
Emacs.

- Christoph

[1] This function is already defined in XEmacs.




reply via email to

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