* Re: master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially
[not found] ` <20190716212509.24A6E20BE2@vcs0.savannah.gnu.org>
@ 2019-07-24 3:14 ` Eric Abrahamsen
2019-07-24 12:54 ` Lars Ingebrigtsen
2019-07-24 15:56 ` Sam Steingold
0 siblings, 2 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2019-07-24 3:14 UTC (permalink / raw)
To: emacs-devel; +Cc: sds
Could we put this back the way it was? I don't know why "Link" as link
text should be treated specially -- now if any of the urls are called
"Link" I have to delete the text. At least make it the default argument
to `completing-read', not the inital input. But I don't see why this
text is treated specially.
> branch: master
> commit 5aa6a15e20f6e97febff45bb291fac59c11ec1ac
> Author: Sam Steingold <sds@gnu.org>
> Commit: Sam Steingold <sds@gnu.org>
>
> Treat the "Link" link in gnus-summary-browse-urls specially
>
> * lisp/gnus/gnus-sum.el (gnus-collect-urls): Make sure that
> the URL labeled "Link" is the first in the return list.
> (gnus-summary-browse-url): Use the 1st URL as the default.
> * lisp/wid-edit.el (widget-text): New function.
> ---
> lisp/gnus/gnus-sum.el | 25 ++++++++++++++++---------
> lisp/wid-edit.el | 7 +++++++
> 2 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
> index 019b47d..1f330e3 100644
> --- a/lisp/gnus/gnus-sum.el
> +++ b/lisp/gnus/gnus-sum.el
> @@ -9435,17 +9435,24 @@ With optional ARG, move across that many fields."
> (widget-backward arg)))
>
> (defun gnus-collect-urls ()
> - "Return the list of URLs in the buffer after (point)."
> - (let ((pt (point)) urls)
> - (while (progn (widget-forward 1)
> - ;; `widget-forward' wraps around to top of buffer.
> + "Return the list of URLs in the buffer after (point).
> +The 1st element is the one named 'Link', if any."
> + (let ((pt (point)) urls link)
> + (while (progn (widget-move 1)
> + ;; `widget-move' wraps around to top of buffer.
> (> (point) pt))
> (setq pt (point))
> - (when-let ((u (or (get-text-property (point) 'shr-url)
> - (get-text-property (point) 'gnus-string))))
> + (when-let ((w (widget-at pt))
> + (u (or (widget-value w)
> + (get-text-property pt 'gnus-string))))
> (when (string-match-p "\\`[[:alpha:]]+://" u)
> - (push u urls))))
> - (nreverse (delete-dups urls))))
> + (if (and (null link) (string= "Link" (widget-text w)))
> + (setq link u)
> + (push u urls)))))
> + (setq urls (nreverse urls))
> + (when link
> + (push link urls))
> + (delete-dups urls)))
>
> (defun gnus-summary-browse-url (arg)
> "Scan the current article body for links, and offer to browse them.
> @@ -9468,7 +9475,7 @@ browse that directly, otherwise use completion to select a link."
> (cond ((= (length urls) 1)
> (car urls))
> ((> (length urls) 1)
> - (completing-read "URL to browse: " urls nil t))))
> + (completing-read "URL to browse: " urls nil t (car urls)))))
> (if target
> (browse-url target)
> (message "No URLs found.")))))
> diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
> index 376e3e5..5dee898 100644
> --- a/lisp/wid-edit.el
> +++ b/lisp/wid-edit.el
> @@ -831,6 +831,13 @@ button end points."
> (delete-overlay field))
> (mapc 'widget-leave-text (widget-get widget :children))))
>
> +(defun widget-text (widget)
> + "Get the text representation of the widget."
> + (when-let ((from (widget-get widget :from))
> + (to (widget-get widget :to)))
> + (when (eq (marker-buffer from) (marker-buffer to)) ; is this check necessary?
> + (buffer-substring-no-properties from to))))
> +
> ;;; Keymap and Commands.
>
> ;; This alias exists only so that one can choose in doc-strings (e.g.
>
> _______________________________________________
> Emacs-diffs mailing list
> Emacs-diffs@gnu.org
> https://lists.gnu.org/mailman/listinfo/emacs-diffs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially
2019-07-24 3:14 ` master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially Eric Abrahamsen
@ 2019-07-24 12:54 ` Lars Ingebrigtsen
2019-07-24 16:01 ` Sam Steingold
2019-07-24 15:56 ` Sam Steingold
1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-24 12:54 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: sds, emacs-devel
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Could we put this back the way it was? I don't know why "Link" as link
> text should be treated specially -- now if any of the urls are called
> "Link" I have to delete the text. At least make it the default argument
> to `completing-read', not the inital input. But I don't see why this
> text is treated specially.
As a DWIM thing, it may make sense? But, yes, it shouldn't be the
initial input. As a default it's nice, though. But then perhaps it
should say (in the prompt) what the default is, which will make the
default very long...
Other usability nits in that function: It uses widget-move, which will
echo the contents, which is very annoying, because that means that it
flashes a large number of things in the echo area.
And the prefix argument to `w' should probably be to act the same as in
eww; i.e., use `shr-external-browser' for the browser.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially
2019-07-24 3:14 ` master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially Eric Abrahamsen
2019-07-24 12:54 ` Lars Ingebrigtsen
@ 2019-07-24 15:56 ` Sam Steingold
2019-07-24 17:13 ` Eric Abrahamsen
1 sibling, 1 reply; 5+ messages in thread
From: Sam Steingold @ 2019-07-24 15:56 UTC (permalink / raw)
To: emacs-devel
> * Eric Abrahamsen <revp@revpnoenunzfra.arg> [2019-07-23 20:14:09 -0700]:
>
> I don't know why "Link" as link text should be treated specially --
Because in newsgroups that stem from reddit and slashdot, the web source
of the article is marked as "link" as opposed to all the other links
that may appear in the article.
> now if any of the urls are called "Link" I have to delete the text.
If "C-a C-k" is too much, I can make "Link" customizable and you will
just set it to nil. Or, if you prefer, I will set it to "Link".
Thanks.
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1671
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
http://camera.org http://memri.org http://islamexposedonline.com
You think Oedipus had a problem -- Adam was Eve's mother.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially
2019-07-24 12:54 ` Lars Ingebrigtsen
@ 2019-07-24 16:01 ` Sam Steingold
0 siblings, 0 replies; 5+ messages in thread
From: Sam Steingold @ 2019-07-24 16:01 UTC (permalink / raw)
To: emacs-devel
> * Lars Ingebrigtsen <ynefv@tahf.bet> [2019-07-24 14:54:14 +0200]:
>
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Could we put this back the way it was? I don't know why "Link" as link
>> text should be treated specially -- now if any of the urls are called
>> "Link" I have to delete the text. At least make it the default argument
>> to `completing-read', not the inital input. But I don't see why this
>> text is treated specially.
>
> As a DWIM thing, it may make sense? But, yes, it shouldn't be the
> initial input. As a default it's nice, though. But then perhaps it
> should say (in the prompt) what the default is, which will make the
> default very long...
Precisely why I chose to use it as the initial input instead - because
if you do not like it, "C-a C-k" is fast enough.
> Other usability nits in that function: It uses widget-move, which will
> echo the contents, which is very annoying, because that means that it
> flashes a large number of things in the echo area.
That I will fix, thanks.
> And the prefix argument to `w' should probably be to act the same as in
> eww; i.e., use `shr-external-browser' for the browser.
Alas, the prefix argument is already used there ("also collect links
from message headers"), and it was so before my change, I will leave it
to you to change (personally, I never use eww).
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1671
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
http://iris.org.il http://honestreporting.com http://islamexposedonline.com
Linux: Telling Microsoft where to go since 1991.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially
2019-07-24 15:56 ` Sam Steingold
@ 2019-07-24 17:13 ` Eric Abrahamsen
0 siblings, 0 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2019-07-24 17:13 UTC (permalink / raw)
To: emacs-devel
Sam Steingold <sds@gnu.org> writes:
>> * Eric Abrahamsen <revp@revpnoenunzfra.arg> [2019-07-23 20:14:09 -0700]:
>>
>> I don't know why "Link" as link text should be treated specially --
>
> Because in newsgroups that stem from reddit and slashdot, the web source
> of the article is marked as "link" as opposed to all the other links
> that may appear in the article.
This seems like one of those conveniences that will be just as
inconvenient to some as it is convenient to others. I use this for
opening Hacker News links via Gwene, where I only ever open "Comment",
not "Link", so now it does exactly the wrong thing.
>> now if any of the urls are called "Link" I have to delete the text.
>
> If "C-a C-k" is too much, I can make "Link" customizable and you will
> just set it to nil. Or, if you prefer, I will set it to "Link".
I think a customization option is a fine idea, but it's impossible to
guess what any given user is going to want from it.
Thanks,
Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-07-24 17:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20190716212507.31541.72823@vcs0.savannah.gnu.org>
[not found] ` <20190716212509.24A6E20BE2@vcs0.savannah.gnu.org>
2019-07-24 3:14 ` master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially Eric Abrahamsen
2019-07-24 12:54 ` Lars Ingebrigtsen
2019-07-24 16:01 ` Sam Steingold
2019-07-24 15:56 ` Sam Steingold
2019-07-24 17:13 ` Eric Abrahamsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).