GNU bug report logs - #34052
27.0.50; New command gnus-summary-press-button

Previous Next

Package: emacs;

Reported by: Eric Abrahamsen <eric <at> ericabrahamsen.net>

Date: Sat, 12 Jan 2019 22:08:02 UTC

Severity: normal

Found in version 27.0.50

Done: Eric Abrahamsen <eric <at> ericabrahamsen.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34052 in the body.
You can then email your comments to 34052 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sat, 12 Jan 2019 22:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Abrahamsen <eric <at> ericabrahamsen.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 12 Jan 2019 22:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; New command gnus-summary-press-button
Date: Sat, 12 Jan 2019 13:59:01 -0800
[Message part 1 (text/plain, inline)]
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.

[0001-New-command-gnus-summary-press-button.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Wed, 30 Jan 2019 21:32:02 GMT) Full text and rfc822 format available.

Message #8 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Wed, 30 Jan 2019 13:31:31 -0800
[Message part 1 (text/plain, inline)]
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

[0001-New-command-gnus-summary-press-button.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sat, 22 Jun 2019 13:11:02 GMT) Full text and rfc822 format available.

Message #11 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sat, 22 Jun 2019 15:10:38 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> 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.

*taps calendar*

Looks good to me, but as I said over on the ding mailing list:

> +@item A l

I think this is such a useful command that we should bind it to `w'
instead.  Or some other unused single key keystroke.

> +      (if target
> +	  (funcall-interactively #'widget-button-press (1+ (cdr target)))

And I didn't quite get why you're not just using browse-url directly
here, which seems less fragile and more controllable.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sat, 22 Jun 2019 16:40:01 GMT) Full text and rfc822 format available.

Message #14 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sat, 22 Jun 2019 09:38:49 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> 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.
>
> *taps calendar*

Ahem...

> Looks good to me, but as I said over on the ding mailing list:
>
>> +@item A l
>
> I think this is such a useful command that we should bind it to `w'
> instead.  Or some other unused single key keystroke.

No objection here.

>> + (if target
>> + (funcall-interactively #'widget-button-press (1+ (cdr target)))
>
> And I didn't quite get why you're not just using browse-url directly
> here, which seems less fragile and more controllable.

I think once I was using widget-forward to collect buttons, it seemed
natural to be able to handle all the types of buttons, not just URLs.
For instance, I'd like to be able to start composing messages to mailto:
buttons. Then the only reliable way to "do" what the button does was to
press it. Later Eric Fraga posted a variant that checked if the URL was
a http URL, and used `browse-url' directly in that case. The whole
function could be a lot simpler if we only collected http links. Though
I'd still like to compose messages to email addresses...

I'm posting the most recent version of the function below. Another bad
thing is does is tries to manage window state, returning the
summary/article config to what it was before clicking links, and I think
that should be removed -- it's fragile, and none of the other
summary/article commands do that.

Anyway, let me know what you think about the button vs link issue...

#+begin_src elisp
(defun gnus-summary-press-button (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 using `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)
		     ;; We might have opened an article, but then moved to
		     ;; a different summary line.
		     (= gnus-current-article (gnus-summary-article-number))))
	(wc (current-window-configuration))
	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-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)
			     "<signature>")
			    ;; 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) urls)))
      (setq target
	    (assoc (cond ((= (length urls) 1)
			  (caar urls))
			 ((> (length urls) 1)
			  (completing-read "URL to browse: "
					   (setq urls (nreverse (delete-dups urls)))
					   nil t)))
		   urls))
      (if target
	  (funcall-interactively #'widget-button-press (1+ (cdr target)))
	(message "No URLs found.")))
    ;; Now what?  If pressing the button changed our window layout, do
    ;; nothing.  Otherwise, if the article wasn't opened to begin
    ;; with, close it after we follow the link.
    (unless (equal wc (current-window-configuration))
      (gnus-summary-expand-window opened))))
#+end_src




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 12:17:02 GMT) Full text and rfc822 format available.

Message #17 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 14:16:28 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> I think once I was using widget-forward to collect buttons, it seemed
> natural to be able to handle all the types of buttons, not just URLs.
> For instance, I'd like to be able to start composing messages to mailto:
> buttons.

Hm...  I think that sounds less useful, really.  In 99.9% of the cases,
you don't want to hit anything but the URLs, I think, and "polluting"
the list of URLs with mailto: stuff would make the feature more
cumbersome to use, in my opinion.

> Then the only reliable way to "do" what the button does was to
> press it. Later Eric Fraga posted a variant that checked if the URL was
> a http URL, and used `browse-url' directly in that case. The whole
> function could be a lot simpler if we only collected http links. Though
> I'd still like to compose messages to email addresses...

If we want to have a "collect mailto: addresses" thing, that could be a
separate command.

> I'm posting the most recent version of the function below. Another bad
> thing is does is tries to manage window state, returning the
> summary/article config to what it was before clicking links, and I think
> that should be removed -- it's fragile, and none of the other
> summary/article commands do that.

Yeah, good point.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 15:31:02 GMT) Full text and rfc822 format available.

Message #20 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 08:30:24 -0700
[Message part 1 (text/plain, inline)]
On 06/23/19 14:16 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> I think once I was using widget-forward to collect buttons, it seemed
>> natural to be able to handle all the types of buttons, not just URLs.
>> For instance, I'd like to be able to start composing messages to mailto:
>> buttons.
>
> Hm...  I think that sounds less useful, really.  In 99.9% of the cases,
> you don't want to hit anything but the URLs, I think, and "polluting"
> the list of URLs with mailto: stuff would make the feature more
> cumbersome to use, in my opinion.
>
>> Then the only reliable way to "do" what the button does was to
>> press it. Later Eric Fraga posted a variant that checked if the URL was
>> a http URL, and used `browse-url' directly in that case. The whole
>> function could be a lot simpler if we only collected http links. Though
>> I'd still like to compose messages to email addresses...
>
> If we want to have a "collect mailto: addresses" thing, that could be a
> separate command.
>
>> I'm posting the most recent version of the function below. Another bad
>> thing is does is tries to manage window state, returning the
>> summary/article config to what it was before clicking links, and I think
>> that should be removed -- it's fragile, and none of the other
>> summary/article commands do that.
>
> Yeah, good point.

Okay, all sounds good. Here's a proper commit, with docs. I've bound it
to both "w" and "A w".

My only problem is, right now I'm getting URLs out of the buttons like
so:

(or (get-text-property (point) 'shr-url)
    (get-text-property (point) 'gnus-string))

In my experiments, I've only found http URLs from 'gnus-string not
'shr-url, and the 'gnus-string values also include things like email
addresses. (I just noticed that having the `url-handler-mode' minor mode
enabled breaks `browse-url's ability to browse mailto: links.)

I could just filter URLs out based on a "http" prefix, but it still
feels a bit limited. WDYT?

[0001-New-command-gnus-summary-browse-url.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 15:33:01 GMT) Full text and rfc822 format available.

Message #23 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 17:32:38 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> I could just filter URLs out based on a "http" prefix, but it still
> feels a bit limited. WDYT?

I think explicitly filtering out some URL schemes instead would be nice,
because you want file: and data: and ftp: to work, perhaps...

So just filter out the mailto: ones?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 16:01:02 GMT) Full text and rfc822 format available.

Message #26 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 08:59:53 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> I could just filter URLs out based on a "http" prefix, but it still
>> feels a bit limited. WDYT?
>
> I think explicitly filtering out some URL schemes instead would be nice,
> because you want file: and data: and ftp: to work, perhaps...
>
> So just filter out the mailto: ones?

The problem is, there are 'gnus-string properties that just look like
"larsi <at> gnus.org", ie no scheme at all. I suppose we could just drop
anything that doesn't look like "`[a-z]+://"...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 16:18:02 GMT) Full text and rfc822 format available.

Message #29 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 18:17:46 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> The problem is, there are 'gnus-string properties that just look like
> "larsi <at> gnus.org", ie no scheme at all. I suppose we could just drop
> anything that doesn't look like "`[a-z]+://"...

Oh, I didn't quite get what you were saying about `gnus-string' and
`shr-url'.

In my Gnus buffers, the URLs all have `shr-url' on them:

(text-property-search-forward 'gnus-string)
=> nil

in an HTML article that has links...

(text-property-search-forward 'shr-url)
=> #s(prop-match 202 206 "http://9gag.com/gag/av8Kj8n")

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 16:38:02 GMT) Full text and rfc822 format available.

Message #32 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 09:37:47 -0700
On 06/23/19 18:17 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> The problem is, there are 'gnus-string properties that just look like
>> "larsi <at> gnus.org", ie no scheme at all. I suppose we could just drop
>> anything that doesn't look like "`[a-z]+://"...
>
> Oh, I didn't quite get what you were saying about `gnus-string' and
> `shr-url'.
>
> In my Gnus buffers, the URLs all have `shr-url' on them:
>
> (text-property-search-forward 'gnus-string)
> => nil
>
> in an HTML article that has links...
>
> (text-property-search-forward 'shr-url)
> => #s(prop-match 202 206 "http://9gag.com/gag/av8Kj8n")

Yeah, I'm just viewing the plain text. We'll want to support both plain
and html versions, so I think scanning for both properties is still
desirable. What do you think about just dropping scheme-less URLs?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 16:51:02 GMT) Full text and rfc822 format available.

Message #35 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 18:50:31 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> Yeah, I'm just viewing the plain text. We'll want to support both plain
> and html versions, so I think scanning for both properties is still
> desirable. 

Oh, yeah, plain text...

> What do you think about just dropping scheme-less URLs?

Yup; sounds good.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 17:07:02 GMT) Full text and rfc822 format available.

Message #38 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 10:06:15 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> Yeah, I'm just viewing the plain text. We'll want to support both plain
>> and html versions, so I think scanning for both properties is still
>> desirable. 
>
> Oh, yeah, plain text...
>
>> What do you think about just dropping scheme-less URLs?
>
> Yup; sounds good.

Done and pushed.

Thanks!
Eric




Reply sent to Eric Abrahamsen <eric <at> ericabrahamsen.net>:
You have taken responsibility. (Sun, 23 Jun 2019 17:08:02 GMT) Full text and rfc822 format available.

Notification sent to Eric Abrahamsen <eric <at> ericabrahamsen.net>:
bug acknowledged by developer. (Sun, 23 Jun 2019 17:08:02 GMT) Full text and rfc822 format available.

Message #43 received at 34052-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: 34052-done <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 10:07:08 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> Yeah, I'm just viewing the plain text. We'll want to support both plain
>> and html versions, so I think scanning for both properties is still
>> desirable. 
>
> Oh, yeah, plain text...
>
>> What do you think about just dropping scheme-less URLs?
>
> Yup; sounds good.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 17:10:01 GMT) Full text and rfc822 format available.

Message #46 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 19:09:16 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> Done and pushed.

Great!  This probably warrants a NEWS entry, too.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34052; Package emacs. (Sun, 23 Jun 2019 17:33:02 GMT) Full text and rfc822 format available.

Message #49 received at 34052 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 34052 <at> debbugs.gnu.org
Subject: Re: bug#34052: Acknowledgement (27.0.50;
 New command gnus-summary-press-button)
Date: Sun, 23 Jun 2019 10:31:49 -0700
On 06/23/19 19:09 PM, Lars Ingebrigtsen wrote:
> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> Done and pushed.
>
> Great!  This probably warrants a NEWS entry, too.

Aha. That's in as well.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 22 Jul 2019 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 276 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.