From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sarir Khamsi Newsgroups: gmane.emacs.help Subject: Advice on writing predicates Date: Thu, 25 Jun 2009 15:27:19 -0700 Organization: Raytheon Company Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1245992088 6565 80.91.229.12 (26 Jun 2009 04:54:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Jun 2009 04:54:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 26 06:54:41 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MK3ST-00044l-G1 for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Jun 2009 06:54:41 +0200 Original-Received: from localhost ([127.0.0.1]:47821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MK3ST-0001zu-1i for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Jun 2009 00:54:41 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!4.24.21.218.MISMATCH!newsfeed2.dallas1.level3.net!news.level3.com!bos-service1.raytheon.com!dfw-service2.ext.ray.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (windows-nt) Cancel-Lock: sha1:ZyFVXiJH2qtJH0N03JY3EUq3jDA= Original-Lines: 24 Original-NNTP-Posting-Host: 147.24.52.80 Original-X-Complaints-To: news@ext.ray.com Original-X-Trace: dfw-service2.ext.ray.com 1245968839 147.24.52.80 (Thu, 25 Jun 2009 22:27:19 UTC) Original-NNTP-Posting-Date: Thu, 25 Jun 2009 22:27:19 UTC Original-Xref: news.stanford.edu gnu.emacs.help:170310 X-Mailman-Approved-At: Fri, 26 Jun 2009 00:53:12 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65538 Archived-At: 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