[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-wiki-discuss] Help with my elisp
From: |
Mark Triggs |
Subject: |
Re: [emacs-wiki-discuss] Help with my elisp |
Date: |
Wed, 30 Mar 2005 23:32:38 +1000 |
User-agent: |
No Gnus v0.3 |
Chris Lowis <address@hidden> writes:
> Hello group,
>
> I wrote a little elisp function (almost my first!) to replace a selected
> name in my planner page with the appropriate bbdb:// link. It works, but
> I am sure it is a terrible elisp style. Any suggestions on how to
> improve it ? I hope to learn some good elisp style from you !
Just to throw my two cents in, I'd probably write it something like:
(defun planner-create-bbdb-link (beg end)
(interactive "r")
(save-excursion
(let ((name (delete-and-extract-region beg end)))
(goto-char beg)
(insert (format "[[bbdb://%s][%s]]"
(replace-regexp-in-string " " ".*" name)
name)))))
which is pretty much the same as yours, except that I'm storing the
contents of the region in a variable instead of the kill ring, and I'm
using the "r" argument of `interactive' to indicate that this function
operates on regions, rather than dealing with (point) and (mark)
explicitly.
Cheers,
Mark
--
Mark Triggs
<address@hidden>