unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: vfoley@gmail.com
Subject: Re: Elisp function(s) to get the most recent n urls in a buffer
Date: 19 Jun 2006 08:16:13 -0700	[thread overview]
Message-ID: <1150730173.299451.199770@f6g2000cwb.googlegroups.com> (raw)
In-Reply-To: <1150698151.471076.227210@r2g2000cwb.googlegroups.com>

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!

      reply	other threads:[~2006-06-19 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-19  6:22 Elisp function(s) to get the most recent n urls in a buffer Brett  Kelly
2006-06-19 15:16 ` vfoley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1150730173.299451.199770@f6g2000cwb.googlegroups.com \
    --to=vfoley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).