From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#34052: Acknowledgement (27.0.50; New command gnus-summary-press-button) Date: Wed, 30 Jan 2019 13:31:31 -0800 Message-ID: <87ef8tn87g.fsf@ericabrahamsen.net> References: <87tvidbkre.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="17260"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 34052@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 30 22:32:19 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 esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goxT0-0004Ls-4B for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Jan 2019 22:32:18 +0100 Original-Received: from localhost ([127.0.0.1]:44509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goxSz-0007ei-3B for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 Jan 2019 16:32:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goxSo-0007dc-HS for bug-gnu-emacs@gnu.org; Wed, 30 Jan 2019 16:32:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goxSn-00008e-9P for bug-gnu-emacs@gnu.org; Wed, 30 Jan 2019 16:32:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goxSk-00007d-PZ for bug-gnu-emacs@gnu.org; Wed, 30 Jan 2019 16:32:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1goxSk-00072c-IO for bug-gnu-emacs@gnu.org; Wed, 30 Jan 2019 16:32: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: Wed, 30 Jan 2019 21:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34052 X-GNU-PR-Package: emacs Original-Received: via spool by 34052-submit@debbugs.gnu.org id=B34052.154888390227040 (code B ref 34052); Wed, 30 Jan 2019 21:32:02 +0000 Original-Received: (at 34052) by debbugs.gnu.org; 30 Jan 2019 21:31:42 +0000 Original-Received: from localhost ([127.0.0.1]:51995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1goxSP-000723-Q3 for submit@debbugs.gnu.org; Wed, 30 Jan 2019 16:31:42 -0500 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:47097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1goxSN-00071v-QB for 34052@debbugs.gnu.org; Wed, 30 Jan 2019 16:31:40 -0500 Original-Received: from localhost (50-251-205-17-static.hfc.comcastbusiness.net [50.251.205.17]) (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 E866241E92 for <34052@debbugs.gnu.org>; Wed, 30 Jan 2019 21:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1548883898; bh=SFlcVs8UBSpJrQkQEEAmj8HFvnfw2KnDh6S1sGWgqHk=; h=From:To:Subject:References:Date:In-Reply-To:From; b=Zp94jKhFOxTgj1BXpKM/wh4PNinJGd1sireEfDLp3V0EtGrMjNHKLUkPMmZESRK/W JRAxnikABXSTpolULFWE4XdISew/bQ/nNl6irGZxP5aGNtoLwyH2QSOpjLrS0Hv5dS Bhi0ATCfEX8VK2qKn6c/9nyjK5lFyX6R7KOowkiw= In-Reply-To: (GNU bug Tracking System's message of "Sat, 12 Jan 2019 22:08:02 +0000") 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:154912 Archived-At: --=-=-= Content-Type: text/plain Here's a new (lightly user-tested) version of the command. I guess if there's no objection I'll push this in a few days. Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-command-gnus-summary-press-button.patch >From 6f9e518bccee479a11114a128bdafb95f80539b7 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 | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 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..d3e3ff1927 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,75 @@ gnus-summary-widget-backward (goto-char (point-max))) (widget-backward arg)) +(defun gnus-summary-press-button (arg) + "Scan the current article body for buttons, and offer to press them. +With prefix ARG, also collect buttons from message headers. + +Buttons are pressed using `widget-button-press'. If only one +button is found, press that directly, otherwise use completion to +select a button." + (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 buttons 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-match-p "^>"))) + ;; This is a "so-and-so wrote:" quote. + (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) + ;; Does a marker always signify the + ;; signature? We may never know. + ((pred markerp) + "") + ;; Sometimes this is also a "so-and-so wrote" quote. + (`(((,(and (pred markerp) start) . + ,(and (pred markerp) end))) + _) + (buffer-substring-no-properties start end)) + ;; There are more weird cases, add as + ;; necessary. + ((pred stringp) dat))))))) + (push (cons u pt) buttons))) + (setq target + (assoc (cond ((= (length buttons) 1) + (caar buttons)) + ((> (length buttons) 1) + (completing-read + "URL to browse: " + (setq buttons (nreverse (delete-dups buttons))) + nil t))) + buttons)) + (if target + (funcall-interactively #'widget-button-press (1+ (cdr target))) + (message "No buttons 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 --=-=-=--