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.devel Subject: Re: master 5aa6a15: Treat the "Link" link in gnus-summary-browse-urls specially Date: Tue, 23 Jul 2019 20:14:09 -0700 Message-ID: <87imrsjf9a.fsf@ericabrahamsen.net> References: <20190716212507.31541.72823@vcs0.savannah.gnu.org> <20190716212509.24A6E20BE2@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="1300"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: sds@gnu.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 24 05:14:33 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hq7jc-0000CS-77 for ged-emacs-devel@m.gmane.org; Wed, 24 Jul 2019 05:14:32 +0200 Original-Received: from localhost ([::1]:48296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hq7jb-0007Te-21 for ged-emacs-devel@m.gmane.org; Tue, 23 Jul 2019 23:14:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38354) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hq7jS-0007TI-SD for emacs-devel@gnu.org; Tue, 23 Jul 2019 23:14:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hq7jR-0001OG-Ge for emacs-devel@gnu.org; Tue, 23 Jul 2019 23:14:22 -0400 Original-Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:41950 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hq7jR-0001NT-A1 for emacs-devel@gnu.org; Tue, 23 Jul 2019 23:14:21 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hq7jO-0018H9-Vl for emacs-devel@gnu.org; Wed, 24 Jul 2019 05:14:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:QRBd4SkVZ0/5GYmnQY1RWwuRmDs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238862 Archived-At: 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 > Commit: Sam Steingold > > 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