[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Elisp function(s) to get the most recent n urls in a buffer
From: |
vfoley |
Subject: |
Re: Elisp function(s) to get the most recent n urls in a buffer |
Date: |
19 Jun 2006 08:16:13 -0700 |
User-agent: |
G2/0.2 |
You know that I'm not expert, but without looking at how you wrote your
function, here's the solution I came up with:
(defun get-last-urls (count)
(let ((urls '()))
(save-excursion
(while (< (length urls) count)
(search-backward-regexp "\\(http://.*\\)\\b")
(add-to-list 'urls (match-string 0))))
urls))
It seems cleaner than your version and doesn't use a global variable.
Upon looking at your code, I see that you specifiy the line at which
you want to start looking, that would be easy to add.
Vince
Brett Kelly wrote:
> This is my first foray into actual elisp programming, so be gentle ;)
>
> My idea is this: I'd like to be able to execute a function in ERC
> (emacs IRC client) to open a new buffer and show me the last n urls
> that appear in the ERC buffer. From there, I'd like to select (using
> RET) one url, have it open in my browser (using browse-url-at-point, I
> imagine) and have the list buffer close and return me to the ERC buffer
> from which I called the function.
>
> So, I'm attempting to write a function that builds and returns a list
> of the last n urls in a buffer. Here's what I've got so far:
>
> (setf urllist '())
>
> (defun get-urls (loc count)
> (interactive)
> (save-excursion
> (goto-char loc)
> (while (> count (length 'urllist))
> (progn
> (- (search-backward-regexp "http:") 5)
> (cons (thing-at-point 'url) '(urllist))
> (goto-char (- point 1)))
> ('urllist))))
>
> I'm not really having a problem, per se - just looking for some
> guidance and some style recommendations. Assuming this is somewhat
> correct (or at least on the right track), what would be my next step?
>
> Thanks!