[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Opening and Closing a buffer in elisp, and elisp regexp
From: |
Anselm Helbig |
Subject: |
Re: Opening and Closing a buffer in elisp, and elisp regexp |
Date: |
Sun, 23 Jul 2006 13:42:21 +0200 |
User-agent: |
Wanderlust/2.11.30 (Wonderwall) Emacs/22.0 Mule/5.0 (SAKAKI) |
hi brett,
> [writing some elisp to extract urls from an erc buffer and select
> them for opening in another buffer]
just some short comments on your code.
> (defun get-last-urls (count)
> "Build a list of the <count> most recent urls in the buffer"
> (let ((urls '()))
> (save-excursion
> (while (or (< (length urls) count) (< (point) 0))
^^^^^^^^^^^^^
point can never be smaller than 1!
you should include the search in your while condition like this
(while (and (< (length urls) count)
(search-backward-regexp "<\\(http://.*\\)\\>" nil t))
^- ignore
errors!
> (search-backward-regexp "<\\(http://.*\\)\\>")
> (add-to-list 'urls (match-string 0))))
^- this should be 1, 0
means the entire match,
not the parenthesized expression
> urls))
>
> (defun handle-url-select ()
> "Open the URL, close buffer - this doesn't completely work yet"
> (progn
> (browse-url (thing-at-point 'url))
> (with-current-buffer buf (kill-buffer buf))))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this wont work. this code tries to make the buffer designated by
`buf' current, if `buf' is unbound this will throw an error.
use (kill-buffer (current-buffer)) instead. OTOH, (bury-buffer)
might serve you just as well.
use M-x re-builder. use M-x ielm. use the online documentation (C-h f,
C-h v, C-h i, ...). use eldoc-mode. if all else fails, have a look at
edebug.
there may be better java-ides out there, but there's no better IDE for
elisp than emacs. 8-)
happy hacking!
anselm