From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#34052: 27.0.50; New command gnus-summary-press-button Date: Sat, 12 Jan 2019 13:59:01 -0800 Message-ID: <87tvidbkre.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1547330766 29948 195.159.176.226 (12 Jan 2019 22:06:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 12 Jan 2019 22:06:06 +0000 (UTC) To: 34052@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 12 23:06:02 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1giRPl-0007g4-MI for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Jan 2019 23:06:02 +0100 Original-Received: from localhost ([127.0.0.1]:56285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giRRs-0001mz-Jv for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Jan 2019 17:08:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giRRj-0001lh-Rk for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 17:08:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1giRRi-00070O-PV for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 17:08:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1giRRi-000708-Ix for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 17:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1giRRi-0005VW-8K for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 17:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Jan 2019 22:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34052 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.154733083721114 (code B ref -1); Sat, 12 Jan 2019 22:08:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Jan 2019 22:07:17 +0000 Original-Received: from localhost ([127.0.0.1]:57193 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1giRQy-0005UU-F9 for submit@debbugs.gnu.org; Sat, 12 Jan 2019 17:07:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1giRQw-0005UG-Am for submit@debbugs.gnu.org; Sat, 12 Jan 2019 17:07:14 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:40090) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1giRQq-00062k-Rx for submit@debbugs.gnu.org; Sat, 12 Jan 2019 17:07:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giRQo-00016Q-Qg for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 17:07:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1giRJY-0000fr-G5 for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 16:59:37 -0500 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:59549) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1giRJO-0000Mq-G0 for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2019 16:59:29 -0500 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 B93963F05C for ; Sat, 12 Jan 2019 21:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1547330343; bh=3jMaD1RHhCBwpcStoSq3K8OQIYYKiWmqnQir6TJO2cI=; h=From:To:Subject:Date:From; b=hPTnPu2KM4paxLwCsQLxJ1OeoXALU2k96D2fd9nKB9K+GWFAP1Y8ABpALRuwXbjoE a/1iYFRyVhTapZC8vhLJTWKllDyixlCAZWdR6ug+rosdry9zVqgDv02HR4moT0OrYx CJn2P/1BHlaiGxbVSqQM41zojyw5tVIb5yb6lTFg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:154395 Archived-At: --=-=-= Content-Type: text/plain The attached patch adds a new Gnus summary buffer command, that clicks a link in the article buffer. Technically, it calls `widget-button-press' on one of the widgets in the article buffer, offering completion if there's more than one. I'm not sure I've handled all the possible values of the 'gnus-data text property, but more would be easy to add. Basically this just lets you follow a link without actually moving point or the mouse into the article buffer. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-command-gnus-summary-press-button.patch >From 3f85945b445fe5871fe14b0b5f4a337ac3e64b9b Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sat, 12 Jan 2019 13:44:23 -0800 Subject: [PATCH] New command gnus-summary-press-button * lisp/gnus/gnus-sum.el (gnus-summary-press-button): Summary buffer command to press a button in the article buffer. Uses completion to choose one of the buttons. * doc/misc/gnus.texi (Article Commands): Document. --- doc/misc/gnus.texi | 11 ++++++++ lisp/gnus/gnus-sum.el | 63 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 2862264312..de7291b2a9 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -10156,6 +10156,17 @@ Article Commands the @kbd{A C} command (@code{gnus-summary-show-complete-article}) will do so. +@item A l +@cindex buttons +@findex gnus-summary-press-button +@kindex A l @r{(Summary)} +Press one of the button widgets in the article buffer. This behaves +as if the user had navigated into the article buffer and pressed +@key{RET} on a widget. If there is more than one button widget, the +button text is used for completion. With a prefix arg, allow +selection of buttons in the message headers, in addition to the +message body. + @end table diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 911bf89f23..d765c67492 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -2101,6 +2101,7 @@ gnus-article-commands-menu "g" gnus-summary-show-article "s" gnus-summary-isearch-article "\t" gnus-summary-widget-forward + "l" gnus-summary-press-button [backtab] gnus-summary-widget-backward "P" gnus-summary-print-article "S" gnus-sticky-article @@ -9368,6 +9369,68 @@ gnus-summary-widget-backward (goto-char (point-max))) (widget-backward arg)) +(defun gnus-summary-press-button (arg) + "From the *Summary* buffer, \"press\" an article button. +With prefix ARG, offer buttons in the message headers as well as +body. + +If only one button is found, press that directly, otherwise use +completion to select a button. Buttons are pressed using +`widget-button-press'." + (interactive "P") + (let ((opened (and (gnus-buffer-live-p gnus-article-buffer) + (get-buffer-window gnus-article-buffer t) + ;; We might have opened an article, but then moved to + ;; a different summary line. + (= gnus-current-article (gnus-summary-article-number)))) + pt urls target) + (unless opened + (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 (cond + ((get-text-property (point) 'shr-url)) + ((get-text-property (point) 'gnus-string)) + ((let ((dat (get-text-property (point) 'gnus-data))) + (pcase dat + ('nil nil) + ((and (pred (stringp) (pred (string= ">")))) + (buffer-substring (line-beginning-position) + (line-end-position))) + ;; Does a marker always signify the + ;; signature? We may never know. + ((pred (markerp)) + "") + ;; There are more weird cases, add as + ;; necessary. + (_ dat))))))) + (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 + (funcall-interactively #'widget-button-press (1+ (cdr target))) + (message "No URLs found."))) + ;; Now what? If we're not in the *Summary* buffer anymore (i.e., + ;; pressing the button created a new buffer), do nothing. + ;; Otherwise, if the article wasn't opened to begin with, close it + ;; after we follow the link. + (when (get-buffer-window gnus-summary-buffer) + (gnus-summary-expand-window opened)))) + (defun gnus-summary-isearch-article (&optional regexp-p) "Do incremental search forward on the current article. If REGEXP-P (the prefix) is non-nil, do regexp isearch." -- 2.20.1 --=-=-=--