[Top][All Lists]

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

Re: No calc in pretest?

From: Juanma Barranquero
Subject: Re: No calc in pretest?
Date: Tue, 02 Jul 2002 11:50:42 +0200

On 02 Jul 2002 11:43:55 +0200, address@hidden (Kim F. Storm) wrote:

> I don't know any code which breaks because of this though.

Not very significative, I know, but my .emacs is an example ;-)

I update my .emacs frequently and share it between GNU/Linux, Windows 95
and Windows 2K, and between 20.7, 21.1, 21.2, EMACS_21_1_RC and HEAD

I have the following code in it, just to support checking the version
and system:

(defconst lk-emacs-sub-version
    (string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)" emacs-version)
    (string-to-int (match-string 1 emacs-version)))
  "Sub-version number of this version of Emacs.")

(defun lk-check-version (major &rest arguments)
  "Check Emacs version.
By default it checks that `emacs-major-version' is greater or equal than MAJOR.
ARGUMENTS can include a minor version number (to check against 
a subversion number (for version numbers of the form 21.X.Y), and a test 
function to
replace the default >= check."
  (let ((minor nil)
        (sub nil)
        (test #'>=))
    (dolist (value arguments)
      (cond ((numberp value) (if minor (setq sub value) (setq minor value)))
            ((functionp value) (setq test value))
            (t (error "wrong argument list %s" arguments))))
    (and (funcall test emacs-major-version major)
         (or (not minor)
             (funcall test emacs-minor-version minor))
         (or (not sub)
             (funcall test lk-emacs-sub-version sub)))))

(defmacro on-system (variable &rest arguments)
  `(let ((result nil))
    (while (and arguments (not result))
      (let ((system (caar arguments)))
        (if (or (and (listp system) (memq ,variable system))
                (eq system t)
                (eq system ,variable))
            (setq result (cdar arguments))
          (setq arguments (cdr arguments)))))
    (and result (cons 'progn result))))

(defmacro on-window-system (&rest arguments)
  (on-system window-system arguments))

(defmacro on-system-type (&rest arguments)
  (on-system system-type arguments))

And then I do things like

(when (lk-check-version 21 2 50)

which break on release renumberings. (Yeah, I use fboundp and featurep,
etc., but sometimes the changes are functional and checking the version
is the only option.)

A more logical way to numbering releases would be welcome. Still, I
dislike the even/odd convention, because it is obvious to programmers
and people who follows closely the software development cycle, but not
so obvious to casual users and/or non-programmers.

On the same vein, upping the release to 22 doesn't seem like a good idea
to me. Emacs went from 19.X to 20.X when it incorpored MULE, I think,
and from it to 21.X with a new and much better redisplay engine able to
support images and non-proportional fonts and you-name-it. Those aren't
just incremental changes. I'd expect 22.X to be the full-Unicode-support
release :)


reply via email to

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