From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jesper Harder Newsgroups: gmane.emacs.help Subject: Re: Lisp hints with VM, BBDB and Personality Crisis Date: Mon, 15 Sep 2003 04:28:26 +0200 Organization: http://purl.org/harder/ Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <87znh7aue5.fsf@dell.i-did-not-set--mail-host-address--so-shoot-me> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1063593085 6852 80.91.224.253 (15 Sep 2003 02:31:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 15 Sep 2003 02:31:25 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 15 04:31:23 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19yj99-0001NO-00 for ; Mon, 15 Sep 2003 04:31:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19yj8c-0000CL-7c for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Sep 2003 22:30:50 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: ^RrvqCr7c,P$zTR:QED"@h9+BTm-"fjZJJ-3=OU7.)i/K]<.J88}s>'Z_$r; List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12516 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12516 spam@juliva.com writes: > I am not an expert in elisp and I was wondering if there is a way to > shorten the code? Especially, in checking nil variables, I tend to do > a lot of (unless (eq thingy nil). You can express it more succinctly as: (when thingy ...) which is equivalent to (unless (eq thingy nil) ...). There's also `null', which is the usual way of testing for a nil value: (null thingy) == (eq thingy nil) Sometimes `not' (which is just another name for `null') might express your intent better. > Any other comments are appreciated. > > (defun my-check-efriend() > "Fetch the 'to' address from the e-mail. Look up in bbdb for the given > address. Look in the note field and check for the string > 'efriend'. Returns t when that's the case" The style guideline is to write the first line of a docstring as a self-contained sentence. Because in some cases -- e.g. when you use `M-x apropos' -- only the first line is displayed. > (when (string-match "efriend" note) t) `when' is redundant here. Just returning the result of (string-match "efriend" note) is the conventional way of doing it (the docstring should then say "Return non-nil when ...", of course).