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

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

Advice on writing predicates


From: Sarir Khamsi
Subject: Advice on writing predicates
Date: Thu, 25 Jun 2009 15:27:19 -0700
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (windows-nt)

I wrote a simple predicate that returns t if the Emacs major version
number is greater than 22 and would like some advice/comments:

The following

(defun sk-emacs-version-greater-than23-p ()
  "Return non-nil if current Emacs version is greater than 22."
  (interactive)
  (setq version-string (replace-regexp-in-string 
".*?\\([0-9]+\\)\.\\([0-9]+\\)\.\\([0-9]+\\)[()-.a-zA-Z0-9 \n]+" "\\1 \\2 \\3" 
(emacs-version)))
  (setq version-num (mapcar 'string-to-number (split-string version-string)))
  (if (> 22 (car version-num))
      t
    nil))

seems to work. I know that I don't need to save \2 and \3 but wanted
that for a later function. Any comments or suggestions on how to make
this better? Thanks.

Sarir

-- 
Sarir Khamsi
software guy
sarir.khamsi@raytheon.com


reply via email to

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