|
From: | martin rudalics |
Subject: | Re: Opening and Closing a buffer in elisp, and elisp regexp |
Date: | Mon, 24 Jul 2006 08:53:38 +0200 |
User-agent: | Mozilla Thunderbird 1.0 (Windows/20041206) |
(defun get-last-urls (count) "Build a list of the count most recent urls in the buffer" ;; Let `actual' count the actual number of urls found, calling `length' ;; in a loop is not very elegant. (let (urls (actual 0)) (save-excursion (while (and (< actual count) ; Did not find yet enough. ;; Move re-search into `and' to stop when no more matches are ;; found and set third argument to t to avoid that it barfs ;; when there are no more matches. Note: This finds only text ;; starting with "<http://" and terminating with a word ;; character - whatever that is in the current buffer - on the ;; same line. (re-search-backward "<\\(http://.*\\)\\>" nil t)) (setq actual (1+ actual)) ;; Use "(match-string 1)" to strip the leading "<". (add-to-list 'urls (match-string 1)))) urls))
[Prev in Thread] | Current Thread | [Next in Thread] |