unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Advice on writing predicates
@ 2009-06-25 22:27 Sarir Khamsi
  2009-06-25 23:23 ` Anselm Helbig
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Sarir Khamsi @ 2009-06-25 22:27 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-06-29 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-25 22:27 Advice on writing predicates Sarir Khamsi
2009-06-25 23:23 ` Anselm Helbig
2009-06-29 19:18   ` chickenphat
2009-06-26  6:40 ` Daniel Pittman
2009-06-26  7:37 ` Andreas Röhler
2009-06-26  9:13 ` Pascal J. Bourguignon
2009-06-26 11:02 ` Thien-Thi Nguyen

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).