From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18161 invoked from network); 8 Mar 2022 20:51:01 -0000 Received: from mx1.math.uh.edu (129.7.128.32) by inbox.vuxu.org with ESMTPUTF8; 8 Mar 2022 20:51:01 -0000 Received: from lists1.math.uh.edu ([129.7.128.208]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nRgnL-00D8dj-57 for ml@inbox.vuxu.org; Tue, 08 Mar 2022 14:50:59 -0600 Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.94.2) (envelope-from ) id 1nRgnK-005MJ4-Jz for ml@inbox.vuxu.org; Tue, 08 Mar 2022 14:50:58 -0600 Received: from mx1.math.uh.edu ([129.7.128.32]) by lists1.math.uh.edu with esmtp (Exim 4.94.2) (envelope-from ) id 1nRgnH-005MIv-VR for ding@lists.math.uh.edu; Tue, 08 Mar 2022 14:50:55 -0600 Received: from quimby.gnus.org ([95.216.78.240]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nRgnE-00D8dG-Qe for ding@lists.math.uh.edu; Tue, 08 Mar 2022 14:50:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:Reply-To:References: In-Reply-To:Subject:Cc:To:From:Sender:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Jxz0WsfhFyHWyRw4H8/r1BEWI6tmQIvrI1oFvUPpPRk=; b=WA+rkw4p3UoTVnVcQA+6/CC7fP EslqcfROqqnoK0mz47F66q8fXYFwaIwhbpq16BZML3CLH8gHiOQqP8AtkADFUImGWXNus2iLRp53k 23OSlzK2Q7RXBzN5V+pWevdUfziv9XZnv9B9DSiIbmAXCSOOFzGJrlJYRgWGizfLa+Io=; Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]) by quimby.gnus.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nRgn7-0007x2-DR; Tue, 08 Mar 2022 21:50:48 +0100 Received: by mail-qv1-xf2b.google.com with SMTP id x3so413086qvd.8; Tue, 08 Mar 2022 12:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:in-reply-to:references:user-agent :return-receipt-to:reply-to:date:message-id:mime-version; bh=Jxz0WsfhFyHWyRw4H8/r1BEWI6tmQIvrI1oFvUPpPRk=; b=KkF+1rcOm+nkgPY4NCGEQ+Wnnofr6Qs1fgIGeS8E0OT/I55X0RlBKaD/+UPfGTDLSC PKg55eS964P+23l6jh616SheCXhopt9n9eDwNV1yhYJsOkZy2/98x12sNKB94Ru4Pl7D d/9jlP8ccddeBB8JAw5bZs3PhqUh3QAxh87DRC5fDbxopIyuII4tMk13xxIY4Bf2YhYg +yC2WZqpnlS6ByCfz+gsyVBNo67nLNLklin5K8uEG8ISMiouW8SDlFB42zXHyo1Q0vUJ oYGriBGiGsOPy3e2DcMgNocSxiuopjCWW6wPoWAlWwGciNOoxTew4oqRpGulur3spKsB Wfuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :user-agent:return-receipt-to:reply-to:date:message-id:mime-version; bh=Jxz0WsfhFyHWyRw4H8/r1BEWI6tmQIvrI1oFvUPpPRk=; b=lDdJO5HVGvGf+Ghc7NOn3cTted/5j36pfswavXwnGadtXGB8ddzMXIUl2WS4utbJLo 2YH5uSimQddOst7HcW3BMUU1h36Dx3cRHQBiULbP6jpl2rlspqeLbaRm+XK7fcnA3zMM 5o2exZ+njmM/uCDWYi9lCI16TV7PF/v+KVYAo6QPCzJNV4y1pQAx3RiYkbtmXY0qPSEw ShHCAJ8JsWUqzF8wap07kmAbGPOx/8c4op/OT/N40B/0Wd4Ohv3Uamv1VR6T5httcnsC rK074HSqQiE7j2DC315x0//sT63/RbNF2nWWlo1EXRrC1RcxhDveidQQUsfOvOFn27Zs vquA== X-Gm-Message-State: AOAM532uNCNZdGOvgDAmLkYOCvjIOynOVpZKJGxf2EOpUORHmleGyIvN m9egslYVDpxo8qlGVqVMmzpTS3e8nA== X-Google-Smtp-Source: ABdhPJyZ5vMWG9DHq9J5LaarsKuZbujovzHxCd/dft65v7pblJJ4fb18XnPauMGQn+8QWqo6t0Sqjw== X-Received: by 2002:ad4:5aa9:0:b0:42d:a6d:b49f with SMTP id u9-20020ad45aa9000000b0042d0a6db49fmr13703410qvg.81.1646772642830; Tue, 08 Mar 2022 12:50:42 -0800 (PST) Received: from 3c22fb11fdab.ant.amazon.com (pool-108-30-23-113.nycmny.fios.verizon.net. [108.30.23.113]) by smtp.gmail.com with ESMTPSA id az33-20020a05620a172100b00648af7287desm7222qkb.26.2022.03.08.12.50.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Mar 2022 12:50:42 -0800 (PST) From: Sam Steingold To: Lars Ingebrigtsen Cc: ding@gnus.org Subject: Re: hackernews & gnus-summary-browse-url In-Reply-To: <87zgm079ip.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 08 Mar 2022 16:23:58 +0100") References: <87k0d5xrf4.fsf@ericabrahamsen.net> <87zgm079ip.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Reply-To: sds@gnu.org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Date: Tue, 08 Mar 2022 15:50:41 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain List-ID: Precedence: bulk > * Lars Ingebrigtsen [2022-03-08 16:23:58 +0100]: > > Sam Steingold writes: > >> Nah, this just affects the _default_ for "w". >> It does not let me open _both_ URLs in _one_ keystroke. >> It also screws up the rest of gnus, where I _do_ want >> `gnus-collect-urls-primary-text' to be "Link". > > I use: > > (require 'gnus-sum) > (define-key gnus-summary-mode-map > "w" (lambda () > (interactive) > (let (urls target) > (gnus-summary-select-article) > (gnus-with-article-buffer > (article-goto-body) > ;; Back up a char, in case body starts with a button. > (backward-char) > (setq urls (gnus-collect-urls)) > (setq target (car urls)) > (if target > (funcall browse-url-secondary-browser-function target) > (message "No URLs found.")))))) > > Alter to open both (car urls) and (car (last urls)). If you use it yourself, would you mind if I apply this patch? --8<---------------cut here---------------start------------->8--- diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 1be5a48068..09170ff8ac 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -2010,6 +2010,7 @@ :keymap "s" #'gnus-summary-isearch-article "TAB" #'gnus-summary-button-forward "" #'gnus-summary-button-backward + "v" #'gnus-summary-browse-all-urls "w" #'gnus-summary-browse-url "t" #'gnus-summary-toggle-header "g" #'gnus-summary-show-article @@ -2196,6 +2197,7 @@ :keymap "s" #'gnus-summary-isearch-article "TAB" #'gnus-summary-button-forward "" #'gnus-summary-button-backward + "v" #'gnus-summary-browse-all-urls "w" #'gnus-summary-browse-url "P" #'gnus-summary-print-article "S" #'gnus-sticky-article @@ -9445,6 +9447,16 @@ gnus-collect-urls (push primary urls)) (delete-dups urls))) +(defun gnus-collect-urls-from-article () + "Select the article and return the list of URLs in it. +See 'gnus-collect-urls'." + (gnus-summary-select-article) + (gnus-with-article-buffer + (article-goto-body) + ;; Back up a char, in case body starts with a button. + (backward-char) + (gnus-collect-urls))) + (defun gnus-shorten-url (url max) "Return an excerpt from URL not exceeding MAX characters." (if (<= (length url) max) @@ -9456,37 +9468,38 @@ gnus-shorten-url (concat "#" target))))) (concat host (string-truncate-left rest (- max (length host))))))) -(defun gnus-summary-browse-url (&optional external) +(defun gnus-summary-browse-url (&optional _external) "Scan the current article body for links, and offer to browse them. Links are opened using `browse-url' unless a prefix argument is -given: Then `browse-url-secondary-browser-function' is used instead. +given: then `browse-url-secondary-browser-function' is used instead. If only one link is found, browse that directly, otherwise use completion to select a link. The first link marked in the article text with `gnus-collect-urls-primary-text' is the default." (interactive "P" gnus-summary-mode) - (let (urls target) - (gnus-summary-select-article) - (gnus-with-article-buffer - (article-goto-body) - ;; Back up a char, in case body starts with a button. - (backward-char) - (setq urls (gnus-collect-urls)) - (setq target - (cond ((= (length urls) 1) - (car urls)) - ((> (length urls) 1) - (completing-read - (format-prompt "URL to browse" - (gnus-shorten-url (car urls) 40)) - urls nil t nil nil (car urls))))) - (if target - (if external - (funcall browse-url-secondary-browser-function target) - (browse-url target)) - (message "No URLs found."))))) + (let* ((urls (gnus-collect-urls-from-article)) + (target + (cond ((= (length urls) 1) + (car urls)) + ((> (length urls) 1) + (completing-read + (format-prompt "URL to browse" + (gnus-shorten-url (car urls) 40)) + urls nil t nil nil (car urls)))))) + (if target + (browse-url-button-open-url target) + (message "No URLs found.")))) + +(defun gnus-summary-browse-all-urls (&optional _external) + "Scan the current article body for links, and browse them. + +Links are opened using `browse-url' unless a prefix argument is +given: then `browse-url-secondary-browser-function' is used instead." + (interactive "P" gnus-summary-mode) + (dolist (url (gnus-collect-urls-from-article)) + (browse-url-button-open-url url))) (defun gnus-summary-isearch-article (&optional regexp-p) "Do incremental search forward on the current article. --8<---------------cut here---------------end--------------->8--- -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113 http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com https://www.peaceandtolerance.org/ https://thereligionofpeace.com Yellow wine is called "white" because it is made out of green grapes.