From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: extract URLs from an emacs (especially gnus) buffer Date: Wed, 14 May 2014 14:20:39 -0400 Organization: disorganization Message-ID: References: Reply-To: sds@gnu.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1400091682 20635 80.91.229.3 (14 May 2014 18:21:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 May 2014 18:21:22 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 14 20:21:18 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wkdnm-00058N-C8 for ged-emacs-devel@m.gmane.org; Wed, 14 May 2014 20:21:14 +0200 Original-Received: from localhost ([::1]:53562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkdnl-0005ym-UC for ged-emacs-devel@m.gmane.org; Wed, 14 May 2014 14:21:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkdne-0005qn-RR for emacs-devel@gnu.org; Wed, 14 May 2014 14:21:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wkdna-00022X-MO for emacs-devel@gnu.org; Wed, 14 May 2014 14:21:06 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:55565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkdna-00022S-GP for emacs-devel@gnu.org; Wed, 14 May 2014 14:21:02 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WkdnQ-0004Fv-Os for emacs-devel@gnu.org; Wed, 14 May 2014 20:20:52 +0200 Original-Received: from static-72-80-117-250.nycmny.fios.verizon.net ([72.80.117.250]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 May 2014 20:20:52 +0200 Original-Received: from sds by static-72-80-117-250.nycmny.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 14 May 2014 20:20:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 39 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: static-72-80-117-250.nycmny.fios.verizon.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin) X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Cancel-Lock: sha1:a6kV1f7lY53AgYKf8gZJdvJQIuQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:171838 Archived-At: > * Sam Steingold [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.