unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Lisp hints with VM, BBDB and Personality Crisis
@ 2003-09-14 22:16 spam
  2003-09-15  2:28 ` Jesper Harder
  0 siblings, 1 reply; 3+ messages in thread
From: spam @ 2003-09-14 22:16 UTC (permalink / raw)


Hello,

I have been playing around with the Personality Crisis package for
VM. I have written the following code which basically is a test to see
if the recipient of the e-mail is a friend. It goes in the bbdb record
for the e-mail handle and sees if there is a string like "efriend" in
the note field.

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). 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"
  (interactive)
  (let ((header (vmpc-get-current-header-contents "to")))
	(unless (eq header nil)
	  (when (string-match "<\\(.*\\)>" header)
		(let* ((email (match-string 1 header))
			   (record (bbdb-search-simple "" email)))
		  (unless (eq record nil)
			(let ((note (bbdb-record-notes record)))
			  (unless (eq note nil)
				(when (string-match "efriend" note) t)))))))))

-- 
/-----------------------------------------------------------------------------*
|   "At Group L, Stoffel oversees six first-rate   |         Ivan Kanis       |
|   programmers, a managerial challenge roughly    |    Software Developper   |
|   comparable to herding cats."                   |        www.kanis.cc      |
|   (The Wasington Post, June 9, 1985)             |                          |
*-----------------------------------------------------------------------------/

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

end of thread, other threads:[~2003-09-18 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-14 22:16 Lisp hints with VM, BBDB and Personality Crisis spam
2003-09-15  2:28 ` Jesper Harder
2003-09-18 13:07   ` Ivan Kanis

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