unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* extract URLs from an emacs (especially gnus) buffer
@ 2014-02-20 21:18 Sam Steingold
  2014-05-14 18:20 ` Sam Steingold
  0 siblings, 1 reply; 2+ messages in thread
From: Sam Steingold @ 2014-02-20 21:18 UTC (permalink / raw)
  To: emacs-devel

Hi,
How do I extract all URLs from an emacs buffer?
(I am especially interested in gnus *Article* buffers).
E.g., the slashdot articles contain _buttons_, not actual urls, so what
I need to do is:

--8<---------------cut here---------------start------------->8---
    (let ((urls ()) (pos (point-min)))
      (while (setq pos (next-single-property-change pos 'follow-link))
        (push (get-char-property pos 'shr-url) urls)
        (setq pos (next-single-property-change pos 'follow-link)))
       urls)
--8<---------------cut here---------------end--------------->8---

On the other hand, raw URLs in other articles (e.g., in this group) have
to be collected by

--8<---------------cut here---------------start------------->8---
    (let ((urls ()) (pos (point-min)))
      (while (setq pos (next-single-property-change pos 'button))
        (let ((widget (get-char-property pos 'button)))
          (push (buffer-substring-no-properties
                  (widget-get widget :from)
                  (widget-get widget :to))
                urls))
        (setq pos (next-single-property-change pos 'button)))
      urls)
--8<---------------cut here---------------end--------------->8---

Maybe there are other ways for other modes?

So, how do I automate the following algorithm in elisp:

1. (goto-char (point-min))
2. until eobp
3.  find next clickable area
4.  if the click target is a url, click on it

Thanks.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://truepeace.org http://iris.org.il
http://palestinefacts.org http://memri.org http://ffii.org
Nothing is as important as you think it is when you are thinking about it.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-14 18:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 21:18 extract URLs from an emacs (especially gnus) buffer Sam Steingold
2014-05-14 18:20 ` Sam Steingold

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).