emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extract URLs from an emacs (especially gnus) buffer


From: Sam Steingold
Subject: Re: extract URLs from an emacs (especially gnus) buffer
Date: Wed, 14 May 2014 14:20:39 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin)

> * Sam Steingold <address@hidden> [2014-02-20 16:18:40 -0500]:
>
> How do I extract all URLs from an emacs buffer?
> (I am especially interested in gnus *Article* buffers).

This is not what I originally wanted (without a filter it pushes all
buttons including e-mail addresses) but, I guess, it will do for now:

--8<---------------cut here---------------start------------->8---
(defun sds-push-button (buffer button)
  (with-current-buffer buffer
    (widget-apply button :action nil)))
(defun sds-push-all-buttons (buffer &optional filter)
  "Push all buttons in the buffer matching the filter."
  (interactive "bBuffer: \nP")
  (with-current-buffer buffer
    (setq filter (cond ((stringp filter) filter)
                       ((null filter) "^Link$")
                       (t (read-string "Filter (regexp): "))))
    (let ((delay 1) (count 0) (pos (point-min)))
      (while (setq pos (next-property-change pos))
        (let ((button (get-char-property pos 'button)))
          (when (and button (widgetp button)
                     (string-match filter
                                   (buffer-substring-no-properties
                                    (widget-get button :from)
                                    (widget-get button :to))))
            (run-with-timer delay nil 'sds-push-button buffer button)
            (incf delay 5)
            (incf count))))
      (message "Scheduled loading %d URLs" count))))
--8<---------------cut here---------------end--------------->8---


-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://memri.org http://ffii.org
http://jihadwatch.org http://americancensorship.org http://mideasttruth.com
People with a good taste are especially appreciated by cannibals.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]