From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/88324 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: Re: Command for browsing article URLs? Date: Thu, 10 Jan 2019 09:53:43 -0800 Message-ID: <87a7k8wg9k.fsf@ericabrahamsen.net> References: <878szwwdjw.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1547142771 32199 195.159.176.226 (10 Jan 2019 17:52:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 Jan 2019 17:52:51 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: ding@gnus.org To: Haider Rizvi Original-X-From: ding-owner+M36533@lists.math.uh.edu Thu Jan 10 18:52:47 2019 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from lists1.math.uh.edu ([129.7.128.208]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gheVa-0008El-Gb for ding-account@gmane.org; Thu, 10 Jan 2019 18:52:46 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.91) (envelope-from ) id 1gheWl-00029x-LT; Thu, 10 Jan 2019 11:53:59 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by lists1.math.uh.edu with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from ) id 1gheWf-000276-Gb for ding@lists.math.uh.edu; Thu, 10 Jan 2019 11:53:53 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gheWd-0003Jq-MQ for ding@lists.math.uh.edu; Thu, 10 Jan 2019 11:53:53 -0600 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]) by quimby.gnus.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1gheWY-0001Cf-Pc for ding@gnus.org; Thu, 10 Jan 2019 18:53:49 +0100 Original-Received: from localhost (71-212-20-199.tukw.qwest.net [71.212.20.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id E88543F03F; Thu, 10 Jan 2019 17:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1547142824; bh=D+d1XhkcO5Pn1qfjfZcwWcTGe3F5FY6Ly7sQdWKCCSo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=jP59y5gepGor4R54+GF3zGw9tqRNv1TU3xd2eJfOTRDKswcF+Yx/uMr47k3V7umbj fpcqKoIOBHOvq2xno9x+L8CByoyT/Xq6bpH0J60mhePDWRW849q6YLE2fXWeW84PlX j43QOL6tCGKdiAU/mE2bcPN5+lbGSVWgQvXh/syI= In-Reply-To: (Haider Rizvi's message of "Tue, 08 Jan 2019 10:07:53 -0700") X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Haider Rizvi writes: > Eric Abrahamsen writes: > >> I'd like to have a command, call it `gnus-article-browse-url', which >> collects all the links/URLs in the article body, and then offers to >> [...] Content analysis details: (-4.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [50.56.99.223 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid X-Spam-Score: -4.9 (----) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:88324 Archived-At: Haider Rizvi writes: > Eric Abrahamsen writes: > >> I'd like to have a command, call it `gnus-article-browse-url', which >> collects all the links/URLs in the article body, and then offers to >> browse one of them (choosing with completion). Bound to "K l", >> naturally. > > I use two functions along these lines but not exactly what you asked > for. > > 1. ace-link-gnus: I've it bound to M-o for some historical reason. In > typical ace-fashion, it highlights all urls in the article and you use > a key to browse the url in your browser. > > 2. my-gnus-browse function: Based on the newsgroup name, it calls > various functions to find parent url for this article from the article > headers. For example, gwene/gmane add a Archived-at header to point to > the original article. I had various mailing lists that I found it useful for. > > Let me know if you want to see the latter. Okay, here's what I've got so far. It seems to work fine, except on links in the article headers (eg the List-Subscribe header contains a "mailto:" link). It's weird because if I click that link with the mouse, or move point to it and hit "", it works fine. But if I programmatically call `widget-button-press' (which is all "" is doing), nothing happens. Also, I have no idea what the difference between 'gnus-string and 'gnus-data text properties is: 'gnus-data in particular seems pretty complicated. Haider, is this something you've encountered (and maybe solved)? Thanks, Eric #+begin_src elisp (defun gnus-article-browse-url (arg) "Scan the current article body for links, and offer to browse them. With prefix ARG, also collect links from message headers. Links are opened via `widget-button-press'. If only one link is found, browse that directly, otherwise use completion to select a link." (interactive "P") (let ((opened (and (gnus-buffer-live-p gnus-article-buffer) (get-buffer-window gnus-article-buffer t))) pt urls target) (unless (and opened ;; We might have opened an article, but then moved to ;; a different summary line. (= gnus-current-article (gnus-summary-article-number))) (gnus-summary-select-article) (gnus-configure-windows 'article)) (gnus-with-article-buffer (if arg (goto-char (point-min)) (article-goto-body) ;; Back up a char, in case body starts with a widget. (backward-char)) (setq pt (point)) (while (progn (widget-forward 1) (> (point) pt)) (setq pt (point)) (when-let ((u (or (get-text-property (point) 'gnus-string) (get-text-property (point) 'gnus-data) (get-text-property (point) 'shr-url)))) (push (cons u pt) urls))) (setq target (assoc (cond ((= (length urls) 1) (caar urls)) ((> (length urls) 1) (completing-read "URL to browse: " (delete-dups urls) nil t))) urls)) (if target (widget-button-press (1+ (cdr target))) (message "No URLs found."))) (gnus-summary-expand-window opened))) (with-eval-after-load "gnus-sum" (define-key gnus-summary-mime-map (kbd "l") #'gnus-article-browse-url)) #+end_src