gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vc.el - Implementation of cvs admin -mrev:message file


From: Sandip Chitale
Subject: Re: vc.el - Implementation of cvs admin -mrev:message file
Date: Mon, 16 Aug 2004 09:41:35 -0700

"Kevin Rodgers" <address@hidden> wrote in message
news:address@hidden
> Sandip Chitale wrote:
>  > (defun vc-cvs-version-list (file)
>  >   "Return list of versions for FILE."
>  >   (let (versions)
>  >     (with-temp-buffer
>  >       (vc-do-command t 0 "cvs" file "log" "-N")
>  >       (goto-char (point-min))
>  >       (while (re-search-forward "^revision \\([0-9.]+\\)" nil t)
>  >  (append-to-list 'versions (list (cons (match-string 1) nil)))
>  >  (goto-char (match-end 0))))
>  >     versions))
>
> The usual lisp idiom for constructing a list like that is to push each
> element on the front and then destructively reverse it.  The idea is
> to avoid unnecessary cons'ing with append and unnecessary list
> traversal with append or nconc.
>
> (defun vc-cvs-version-list (file)
>    "Return list of versions for FILE."
>    (let (versions)
>      (with-temp-buffer
>        (vc-do-command t 0 "cvs" file "log" "-N")
>        (goto-char (point-min))
>        (while (re-search-forward "^revision \\([0-9.]+\\)" nil t)
>          (setq versions (cons (match-string 1) version))))
>      (nreverse versions)))
>

Thanks for the tip. This is helping me learn to write better lisp.

Regards,
Sandip




reply via email to

[Prev in Thread] Current Thread [Next in Thread]