From debbugs-submit-bounces@debbugs.gnu.org Thu May 07 21:18:26 2020 Received: (at submit) by debbugs.gnu.org; 8 May 2020 01:18:26 +0000 Received: from localhost ([127.0.0.1]:44198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWrej-0005zL-CH for submit@debbugs.gnu.org; Thu, 07 May 2020 21:18:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:48330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWreh-0005zC-Kr for submit@debbugs.gnu.org; Thu, 07 May 2020 21:18:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWreh-0006eZ-Ev for bug-gnu-emacs@gnu.org; Thu, 07 May 2020 21:18:23 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:33892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jWref-0000m4-Qw for bug-gnu-emacs@gnu.org; Thu, 07 May 2020 21:18:23 -0400 Received: by mail-wr1-x42c.google.com with SMTP id y3so8664695wrt.1 for ; Thu, 07 May 2020 18:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:user-agent:mime-version; bh=RVtXQSOqfiJnG5UocBWwsKPQoJ7VO7eQPwZcCeMa/HU=; b=fnoKaCek51JVC1VWZR7oWFxF2tmfR+i5JeeE1VdUmcSlQt1MpABcSSiu5RSl0WFlAv vo5yZt/pNaOM13kTRyX4Jiyy3Ug0TjZfOcGkBXg5jBXFmpnmy3JTezW/V0kl07V37mmD tt5yi4J2nHAiGszn4rCEVR9Kb724DYjYNWMAAjM8RZlETZJoQ5sW3I9ZvlpqRdJgEcrc ka6AkPBLYp1Srf+Oydhn+lzgD12Pl8MLKH47D3qjlPc36mJ0eDQ2pOYrCPVb7hRBvAZd jTXufxQsHYj9YMWOd2Gc/9Q8bhM3FKAL9/YqYPvz5NRvSyauroYDMDdkmDBzfizjJ7Z1 lgIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=RVtXQSOqfiJnG5UocBWwsKPQoJ7VO7eQPwZcCeMa/HU=; b=VoEIEwi3uD4/X4gPhLe3zAzV2oS0Y8Ri5d5/vR1L0cjOE85gZGcdZ7ufF90xjgHwTl 522UvR7i6GS87YzF7Dfq0VYpzSK1GyFC+HyvbJD5EHEdeld571v+0ZZ0R/XxCrs8rGY3 oUJEMZnjHiXigGtFAJhkBKqP2JTSOhVhYDlSoTWD/uSp7Lt4N/JsqjnV42uPg8MCMD2Q UzsJjF4nthX6dh8sb+4yD6+f8D4rbsWFPRyAwbAXd6hT2XZf0Pt7p/4XA50JBFkwkfD/ rm/aA7McfoYTO+CmQhhBFkkcaBaDCDxJb0qHaT8NBDgpslhc8TMQLaIQ3Sm24rZv+Egf VUlw== X-Gm-Message-State: AGi0PuZRaRkoakX4srIOt+MoijiADm/4qfwWVhbkWSDNm/7Yi/4AeQND ccKnZIgX1T1MS1q98qxtde8G7VmaSv8= X-Google-Smtp-Source: APiQypK4Az9B7jRvVnUU5vADlYy1unMsZfNlwa94WQ18kmPEjyLgW4wE+5DG8x8w0fl/o5NHoh2ktw== X-Received: by 2002:a5d:4e06:: with SMTP id p6mr17954460wrt.35.1588900699746; Thu, 07 May 2020 18:18:19 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id 128sm3125875wme.39.2020.05.07.18.18.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 18:18:18 -0700 (PDT) From: "Basil L. Contovounesios" To: bug-gnu-emacs@gnu.org Subject: 28.0.50; Respect browse-url user options in shr/eww Date: Fri, 08 May 2020 02:18:17 +0100 Message-ID: <87wo5njkbq.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=2a00:1450:4864:20::42c; envelope-from=contovob@tcd.ie; helo=mail-wr1-x42c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain X-Debbugs-Cc: Lars Ingebrigtsen , Tassilo Horn Severity: wishlist Tags: patch The commands shr-browse-url and eww-follow-link currently pass mailto URLs directly to browse-url-mail, which doesn't respect the user options browse-url-handlers and browse-url-mailto-function. Can't/shouldn't the commands call browse-url instead? WDYT of the attached patch that does this? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Improve-shr-eww-handling-of-mailto-URLs.patch >From 7a15f9a0a3aad8cae9d4f5da2250ca0ac054c4ee Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 6 May 2020 18:02:32 +0100 Subject: [PATCH] Improve shr/eww handling of mailto URLs * lisp/net/eww.el (eww): Use function-put in place of put, as recommended in "(elisp) Symbol Plists". (eww-follow-link): * lisp/net/shr.el (shr-browse-url): Rather than call browse-url-mail directly, call browse-url which respects the user options browse-url-handlers and browse-url-mailto-function. (shr--current-link-region): Return nil if there is no link at point. (shr--blink-link): Adapt accordingly. (shr-fill-line, shr-indent, shr-table-body): Refactor to avoid some unnecessary allocations. --- lisp/net/eww.el | 30 +++++++++--------- lisp/net/shr.el | 84 +++++++++++++++++++++---------------------------- 2 files changed, 52 insertions(+), 62 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index a6c1abdbb1..2a70560ca7 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -307,10 +307,10 @@ eww (insert (format "Loading %s..." url)) (goto-char (point-min))) (let ((url-mime-accept-string eww-accept-content-types)) - (url-retrieve url 'eww-render + (url-retrieve url #'eww-render (list url nil (current-buffer))))) -(put 'eww 'browse-url-browser-kind 'internal) +(function-put 'eww 'browse-url-browser-kind 'internal) (defun eww--dwim-expand-url (url) (setq url (string-trim url)) @@ -375,8 +375,8 @@ eww-search-words (let ((region-string (buffer-substring (region-beginning) (region-end)))) (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string)) (eww region-string) - (call-interactively 'eww))) - (call-interactively 'eww))) + (call-interactively #'eww))) + (call-interactively #'eww))) (defun eww-open-in-new-buffer () "Fetch link at point in a new EWW buffer." @@ -1013,7 +1013,7 @@ eww-reload (eww-display-html 'utf-8 url (plist-get eww-data :dom) (point) (current-buffer))) (let ((url-mime-accept-string eww-accept-content-types)) - (url-retrieve url 'eww-render + (url-retrieve url #'eww-render (list url (point) (current-buffer) encode)))))) ;; Form support. @@ -1576,8 +1576,10 @@ eww-follow-link (cond ((not url) (message "No link under point")) - ((string-match "^mailto:" url) - (browse-url-mail url)) + ((string-match-p "\\`mailto:" url) + ;; This respects the user options `browse-url-handlers' + ;; and `browse-url-mailto-function'. + (browse-url url)) ((and (consp external) (<= (car external) 4)) (funcall browse-url-secondary-browser-function url) (shr--blink-link)) @@ -1615,7 +1617,7 @@ eww-download (eww-current-url)))) (if (not url) (message "No URL under point") - (url-retrieve url 'eww-download-callback (list url))))) + (url-retrieve url #'eww-download-callback (list url))))) (defun eww-download-callback (status url) (unless (plist-get status :error) @@ -2128,12 +2130,12 @@ eww-desktop-misc-data Only the properties listed in `eww-desktop-data-save' are included. Generally, the list should not include the (usually overly large) :dom, :source and :text properties." - (let ((history (mapcar 'eww-desktop-data-1 - (cons eww-data eww-history)))) - (list :history (if eww-desktop-remove-duplicates - (cl-remove-duplicates - history :test 'eww-desktop-history-duplicate) - history)))) + (let ((history (mapcar #'eww-desktop-data-1 + (cons eww-data eww-history)))) + (list :history (if eww-desktop-remove-duplicates + (cl-remove-duplicates + history :test #'eww-desktop-history-duplicate) + history)))) (defun eww-restore-desktop (file-name buffer-name misc-data) "Restore an eww buffer from its desktop file record. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 1f80ab74db..03260c9e70 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -135,7 +135,7 @@ shr-content-function This is used for cid: URLs, and the function is called with the cid: URL as the argument.") -(defvar shr-put-image-function 'shr-put-image +(defvar shr-put-image-function #'shr-put-image "Function called to put image and alt string.") (defface shr-strike-through '((t :strike-through t)) @@ -365,25 +365,20 @@ shr-maybe-probe-and-copy-url (shr-copy-url url))) (defun shr--current-link-region () - (let ((current (get-text-property (point) 'shr-url)) - start) - (save-excursion - ;; Go to the beginning. - (while (and (not (bobp)) - (equal (get-text-property (point) 'shr-url) current)) - (forward-char -1)) - (unless (equal (get-text-property (point) 'shr-url) current) - (forward-char 1)) - (setq start (point)) - ;; Go to the end. - (while (and (not (eobp)) - (equal (get-text-property (point) 'shr-url) current)) - (forward-char 1)) - (list start (point))))) + "Return the start and end positions of the URL at point, if any. +Value is a pair of positions (START . END) if there is a non-nil +`shr-url' text property at point; otherwise nil." + (when (get-text-property (point) 'shr-url) + (let* ((end (or (next-single-property-change (point) 'shr-url) + (point-max))) + (beg (or (previous-single-property-change end 'shr-url) + (point-min)))) + (cons beg end)))) (defun shr--blink-link () - (let* ((region (shr--current-link-region)) - (overlay (make-overlay (car region) (cadr region)))) + "Briefly fontify URL at point with the face `shr-selected-link'." + (when-let* ((region (shr--current-link-region)) + (overlay (make-overlay (car region) (cdr region)))) (overlay-put overlay 'face 'shr-selected-link) (run-at-time 1 nil (lambda () (delete-overlay overlay))))) @@ -437,7 +432,7 @@ shr-insert-image (if (not url) (message "No image under point") (message "Inserting %s..." url) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) (1- (point)) (point-marker)) t)))) @@ -463,7 +458,7 @@ shr-zoom-image (when (> (- (point) start) 2) (delete-region start (1- (point))))) (message "Inserting %s..." url) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) (1- (point)) (point-marker) (list (cons 'size (cond ((or (eq size 'default) @@ -493,7 +488,7 @@ shr-indirect-call ((fboundp function) (apply function dom args)) (t - (apply 'shr-generic dom args))))) + (apply #'shr-generic dom args))))) (defun shr-descend (dom) (let ((function @@ -730,9 +725,10 @@ shr-fill-line (let ((gap-start (point)) (face (get-text-property (point) 'face))) ;; Extend the background to the end of the line. - (if face - (insert (propertize "\n" 'face (shr-face-background face))) - (insert "\n")) + (insert ?\n) + (when face + (put-text-property (1- (point)) (point) + 'face (shr-face-background face))) (shr-indent) (when (and (> (1- gap-start) (point-min)) (get-text-property (point) 'shr-url) @@ -935,12 +931,11 @@ shr-ensure-paragraph (defun shr-indent () (when (> shr-indentation 0) - (insert - (if (not shr-use-fonts) - (make-string shr-indentation ?\s) - (propertize " " - 'display - `(space :width (,shr-indentation))))))) + (if (not shr-use-fonts) + (insert-char ?\s shr-indentation) + (insert ?\s) + (put-text-property (1- (point)) (point) + 'display `(space :width (,shr-indentation)))))) (defun shr-fontize-dom (dom &rest types) (let ((start (point))) @@ -987,16 +982,11 @@ shr-browse-url (cond ((not url) (message "No link under point")) - ((string-match "^mailto:" url) - (browse-url-mail url)) + (external + (funcall browse-url-secondary-browser-function url) + (shr--blink-link)) (t - (if external - (progn - (funcall browse-url-secondary-browser-function url) - (shr--blink-link)) - (browse-url url (if new-window - (not browse-url-new-window-flag) - browse-url-new-window-flag))))))) + (browse-url url (xor new-window browse-url-new-window-flag)))))) (defun shr-save-contents (directory) "Save the contents from URL in a file." @@ -1005,7 +995,7 @@ shr-save-contents (if (not url) (message "No link under point") (url-retrieve (shr-encode-url url) - 'shr-store-contents (list url directory))))) + #'shr-store-contents (list url directory))))) (defun shr-store-contents (status url directory) (unless (plist-get status :error) @@ -1156,7 +1146,6 @@ shr-rescale-image ;; url-cache-extract autoloads url-cache. (declare-function url-cache-create-filename "url-cache" (url)) -(autoload 'browse-url-mail "browse-url") (defun shr-get-image-data (url) "Get image data for URL. @@ -1230,7 +1219,7 @@ shr-image-displayer (funcall shr-put-image-function image (buffer-substring start end)) (delete-region (point) end)))) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) start end) t t))))) @@ -1679,7 +1668,7 @@ shr-tag-img (or alt ""))) (insert " ") (url-queue-retrieve - (shr-encode-url url) 'shr-image-fetched + (shr-encode-url url) #'shr-image-fetched (list (current-buffer) start (set-marker (make-marker) (point)) (list :width width :height height)) t @@ -2006,12 +1995,11 @@ shr-table-body (cond ((null tbodies) dom) - ((= (length tbodies) 1) + ((null (cdr tbodies)) (car tbodies)) (t ;; Table with multiple tbodies. Convert into a single tbody. - `(tbody nil ,@(cl-reduce 'append - (mapcar 'dom-non-text-children tbodies))))))) + `(tbody nil ,@(mapcan #'dom-non-text-children tbodies)))))) (defun shr--fix-tbody (tbody) (nconc (list 'tbody (dom-attributes tbody)) @@ -2311,8 +2299,8 @@ shr-table-widths (dolist (column row) (aset natural-widths i (max (aref natural-widths i) column)) (setq i (1+ i))))) - (let ((extra (- (apply '+ (append suggested-widths nil)) - (apply '+ (append widths nil)) + (let ((extra (- (apply #'+ (append suggested-widths nil)) + (apply #'+ (append widths nil)) (* shr-table-separator-pixel-width (1+ (length widths))))) (expanded-columns 0)) ;; We have extra, unused space, so divide this space amongst the -- 2.26.2 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri May 08 02:37:56 2020 Received: (at 41133) by debbugs.gnu.org; 8 May 2020 06:37:56 +0000 Received: from localhost ([127.0.0.1]:44467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWwdv-0005nN-OL for submit@debbugs.gnu.org; Fri, 08 May 2020 02:37:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWwdu-0005nB-V8 for 41133@debbugs.gnu.org; Fri, 08 May 2020 02:37:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40166) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWwdp-0000Gx-4O; Fri, 08 May 2020 02:37:49 -0400 Received: from [176.228.60.248] (port=4466 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jWwdo-0005up-31; Fri, 08 May 2020 02:37:48 -0400 Date: Fri, 08 May 2020 09:37:34 +0300 Message-Id: <83368bj5jl.fsf@gnu.org> From: Eli Zaretskii To: "Basil L. Contovounesios" In-Reply-To: <87wo5njkbq.fsf@tcd.ie> (contovob@tcd.ie) Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41133 Cc: larsi@gnus.org, tsdh@gnu.org, 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "Basil L. Contovounesios" > Date: Fri, 08 May 2020 02:18:17 +0100 > Cc: lars ingebrigtsen , tassilo horn > > The commands shr-browse-url and eww-follow-link currently pass mailto > URLs directly to browse-url-mail, which doesn't respect the user options > browse-url-handlers and browse-url-mailto-function. > > Can't/shouldn't the commands call browse-url instead? > WDYT of the attached patch that does this? This would need a NEWS entry. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri May 08 03:18:57 2020 Received: (at 41133) by debbugs.gnu.org; 8 May 2020 07:18:57 +0000 Received: from localhost ([127.0.0.1]:44519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWxHd-0006qH-Ge for submit@debbugs.gnu.org; Fri, 08 May 2020 03:18:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWxHb-0006q2-N1 for 41133@debbugs.gnu.org; Fri, 08 May 2020 03:18:56 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40926) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWxHW-0003di-2n; Fri, 08 May 2020 03:18:50 -0400 Received: from auth1-smtp.messagingengine.com ([66.111.4.227]:49585) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1jWxHS-0004sD-V9; Fri, 08 May 2020 03:18:49 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 30A5C27C0054; Fri, 8 May 2020 03:18:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Fri, 08 May 2020 03:18:46 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrkedugdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefvrghsshhi lhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnheptd elieffkeeuffduueeffefhiedtjeeutdeuveegfffgtdejleekheegkeetkeevnecukfhp pedufeegrdduudelrddvgedrudelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehthhhorhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgr lhhithihqdekieejfeekjeekgedqieefhedvleekqdhtshguhheppehgnhhurdhorhhgse hfrghsthhmrghilhdrfhhm X-ME-Proxy: Received: from jiffyarch (j289989.servers.jiffybox.net [134.119.24.195]) by mail.messagingengine.com (Postfix) with ESMTPA id 085B330661F0; Fri, 8 May 2020 03:18:44 -0400 (EDT) From: Tassilo Horn To: "Basil L. Contovounesios" Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> Date: Fri, 08 May 2020 09:18:43 +0200 In-Reply-To: <87wo5njkbq.fsf@tcd.ie> (Basil L. Contovounesios's message of "Fri, 08 May 2020 02:18:17 +0100") Message-ID: <87h7wqlwrw.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41133 Cc: lars ingebrigtsen , 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) "Basil L. Contovounesios" writes: > X-Debbugs-Cc: Lars Ingebrigtsen , Tassilo Horn > Severity: wishlist > Tags: patch > > The commands shr-browse-url and eww-follow-link currently pass mailto > URLs directly to browse-url-mail, which doesn't respect the user options > browse-url-handlers and browse-url-mailto-function. > > Can't/shouldn't the commands call browse-url instead? > WDYT of the attached patch that does this? Looks good to me (I just looked at the parts calling browse-url), and I think it won't change any behavior unless the user customizes browse-url-handlers to catch mailto links with his own function instead of the default one in browse-url-default-handlers (which in turn just calls browse-url-mailto-function). BTW: I didn't know about function-put. Should that be preferred to put? I've tested that put/get also work with #'function, so where's the difference? Bye, Tassilo From debbugs-submit-bounces@debbugs.gnu.org Fri May 08 03:23:51 2020 Received: (at 41133) by debbugs.gnu.org; 8 May 2020 07:23:51 +0000 Received: from localhost ([127.0.0.1]:44531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWxMN-0006yz-Aw for submit@debbugs.gnu.org; Fri, 08 May 2020 03:23:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jWxML-0006yd-PY for 41133@debbugs.gnu.org; Fri, 08 May 2020 03:23:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41048) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWxMG-00015J-9g; Fri, 08 May 2020 03:23:44 -0400 Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:43755) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1jWxME-0005HH-0k; Fri, 08 May 2020 03:23:42 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 9A08227C0054; Fri, 8 May 2020 03:23:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Fri, 08 May 2020 03:23:41 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrkedugdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefvrghsshhi lhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnheptd elieffkeeuffduueeffefhiedtjeeutdeuveegfffgtdejleekheegkeetkeevnecukfhp pedufeegrdduudelrddvgedrudelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehthhhorhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgr lhhithihqdekieejfeekjeekgedqieefhedvleekqdhtshguhheppehgnhhurdhorhhgse hfrghsthhmrghilhdrfhhm X-ME-Proxy: Received: from jiffyarch (j289989.servers.jiffybox.net [134.119.24.195]) by mail.messagingengine.com (Postfix) with ESMTPA id A97B8328005E; Fri, 8 May 2020 03:23:40 -0400 (EDT) From: Tassilo Horn To: Eli Zaretskii Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <83368bj5jl.fsf@gnu.org> Date: Fri, 08 May 2020 09:23:39 +0200 In-Reply-To: <83368bj5jl.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 08 May 2020 09:37:34 +0300") Message-ID: <87d07elwjo.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41133 Cc: "Basil L. Contovounesios" , larsi@gnus.org, 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> From: "Basil L. Contovounesios" >> Date: Fri, 08 May 2020 02:18:17 +0100 >> Cc: lars ingebrigtsen , tassilo horn >> >> The commands shr-browse-url and eww-follow-link currently pass mailto >> URLs directly to browse-url-mail, which doesn't respect the user options >> browse-url-handlers and browse-url-mailto-function. >> >> Can't/shouldn't the commands call browse-url instead? >> WDYT of the attached patch that does this? > > This would need a NEWS entry. Agreed. The browse-url-handlers are already there, tho I think I should also add a new entry for the new browse-url-with-browser-kind command... Will do later. Bye, Tassilo From debbugs-submit-bounces@debbugs.gnu.org Sat May 09 09:27:37 2020 Received: (at 41133) by debbugs.gnu.org; 9 May 2020 13:27:37 +0000 Received: from localhost ([127.0.0.1]:46958 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXPVw-0007Zj-RQ for submit@debbugs.gnu.org; Sat, 09 May 2020 09:27:37 -0400 Received: from mail-wr1-f54.google.com ([209.85.221.54]:46645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXPVv-0007ZT-42 for 41133@debbugs.gnu.org; Sat, 09 May 2020 09:27:35 -0400 Received: by mail-wr1-f54.google.com with SMTP id w7so5154912wre.13 for <41133@debbugs.gnu.org>; Sat, 09 May 2020 06:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=uubQMW99aZp6GwNYlLZ+lkBGZBARJkZUHoWib+Qajhs=; b=AB2fS7iuzS6kb0mCwk1Fkl7iy09qRxDryYDJcqssE2ddH1jl+/cDgjBa7ccr+lv0L0 diSI/YTpSzjxN8y8eH0AGB4LwwnRwOConmk8TKthYrQs+6Hv+Iwkzlh+9Bqh35JyFuSF 3rgHVEt3bx9xMMA08CUMHcmftuotfoMAb+iIj+uMh4aFom697GyOH3zd6YGR5LriWWMZ 8rEp3Vp7dmtab/6gq3UsOvlibJOVlNMLvy+lK/9XdAwtyT8W9bxM1kuUFIL0JBveSAqC p+MXda0v8O/Kks7OWlyuUiXVSvq5qdTF/wTHrnwpPP26icZmZSrXZXAu0fAlWe+odiBf Nc+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=uubQMW99aZp6GwNYlLZ+lkBGZBARJkZUHoWib+Qajhs=; b=haWHp7CNRdxCRSiehHlQZo9Lj1QvXx8WWLLL5ON6BqL4mMkvNQ3fU80svQ8BAHi3eQ Hy+RLRvEmCgiXPncim6MWc4iq63e+5c3HbrDQZlevPBqT06AV3gx0KEzUIoKXmUH5OkW kHdyiU/ST1aGjsDLPANedja2BeHNZLvO49DyZrpY4c4z37XoYGou2on9mplxbh4MSog4 QnUp/XxNENs+nBnSJNIkXYmA95/BkuCQ34pY6E4qvIhEHtffwNdD0NbSab5H3oMgMn2n 3pL+qS3LNSNp18rpjsqldW/E5l7E7ZnU6DIShYI3wDqRQF6gCAcycpD4KLXblnQp1iLT pFvQ== X-Gm-Message-State: AGi0PuY6tyy3wbcPgxSzL1lEOi+MqehIehbxLWBxS1aQptswL/NwABCi IevXgyMPyNtPeGfh0KkA3bnblQ== X-Google-Smtp-Source: APiQypKyUmhilAh5dt66R7PuvaSTjNChRHL8weATQInR+AviYt57bdHmjwye0Ldfq33ke8s0ERVAsw== X-Received: by 2002:adf:efcb:: with SMTP id i11mr8159306wrp.278.1589030849190; Sat, 09 May 2020 06:27:29 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id y7sm18585150wmb.43.2020.05.09.06.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2020 06:27:28 -0700 (PDT) From: "Basil L. Contovounesios" To: Eli Zaretskii Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <83368bj5jl.fsf@gnu.org> Date: Sat, 09 May 2020 14:27:27 +0100 In-Reply-To: <83368bj5jl.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 08 May 2020 09:37:34 +0300") Message-ID: <873689utkw.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41133 Cc: larsi@gnus.org, tsdh@gnu.org, 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > This would need a NEWS entry. Right. How's the following? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Improve-shr-eww-handling-of-mailto-URLs.patch >From 2f73eb9919ff7de72ec40577ed2827615d79fef7 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 6 May 2020 18:02:32 +0100 Subject: [PATCH] Improve shr/eww handling of mailto URLs * lisp/net/eww.el (eww): Use function-put in place of put, as recommended in "(elisp) Symbol Plists". (eww-follow-link): * lisp/net/shr.el (shr-browse-url): Rather than call browse-url-mail directly, call browse-url which respects the user options browse-url-handlers and browse-url-mailto-function. (Bug#41133) (shr--current-link-region): Return nil if there is no link at point. (shr--blink-link): Adapt accordingly. (shr-fill-line, shr-indent, shr-table-body): Refactor to avoid some unnecessary allocations. * etc/NEWS: Announce that eww-follow-link and shr-browse-url support custom URL handlers. --- etc/NEWS | 20 ++++++++++++ lisp/net/eww.el | 30 +++++++++--------- lisp/net/shr.el | 84 +++++++++++++++++++++---------------------------- 3 files changed, 72 insertions(+), 62 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 12406eea82..bd5694e851 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -347,6 +347,26 @@ symbol property to the browsing functions. With a new command 'browse-url-with-browser-kind', an URL can explicitly be browsed with either an internal or external browser. +** SHR + ++++ +*** The command 'shr-browse-url' now supports custom mailto handlers. +Clicking on or otherwise following a 'mailto:' link in a HTML buffer +rendered by SHR previously invoked the command 'browse-url-mailto'. +This is still the case by default, but which function is invoked can +now be customized via the user options 'browse-url-mailto-function' +and 'browse-url-handlers'. + +** EWW + ++++ +*** The command 'eww-follow-link' now supports custom mailto handlers. +Clicking on or otherwise following a 'mailto:' link in an EWW buffer +previously invoked the command 'browse-url-mailto'. This is still the +case by default, but which function is invoked can now be customized +via the user options 'browse-url-mailto-function' and +'browse-url-handlers'. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/net/eww.el b/lisp/net/eww.el index a6c1abdbb1..2a70560ca7 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -307,10 +307,10 @@ eww (insert (format "Loading %s..." url)) (goto-char (point-min))) (let ((url-mime-accept-string eww-accept-content-types)) - (url-retrieve url 'eww-render + (url-retrieve url #'eww-render (list url nil (current-buffer))))) -(put 'eww 'browse-url-browser-kind 'internal) +(function-put 'eww 'browse-url-browser-kind 'internal) (defun eww--dwim-expand-url (url) (setq url (string-trim url)) @@ -375,8 +375,8 @@ eww-search-words (let ((region-string (buffer-substring (region-beginning) (region-end)))) (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string)) (eww region-string) - (call-interactively 'eww))) - (call-interactively 'eww))) + (call-interactively #'eww))) + (call-interactively #'eww))) (defun eww-open-in-new-buffer () "Fetch link at point in a new EWW buffer." @@ -1013,7 +1013,7 @@ eww-reload (eww-display-html 'utf-8 url (plist-get eww-data :dom) (point) (current-buffer))) (let ((url-mime-accept-string eww-accept-content-types)) - (url-retrieve url 'eww-render + (url-retrieve url #'eww-render (list url (point) (current-buffer) encode)))))) ;; Form support. @@ -1576,8 +1576,10 @@ eww-follow-link (cond ((not url) (message "No link under point")) - ((string-match "^mailto:" url) - (browse-url-mail url)) + ((string-match-p "\\`mailto:" url) + ;; This respects the user options `browse-url-handlers' + ;; and `browse-url-mailto-function'. + (browse-url url)) ((and (consp external) (<= (car external) 4)) (funcall browse-url-secondary-browser-function url) (shr--blink-link)) @@ -1615,7 +1617,7 @@ eww-download (eww-current-url)))) (if (not url) (message "No URL under point") - (url-retrieve url 'eww-download-callback (list url))))) + (url-retrieve url #'eww-download-callback (list url))))) (defun eww-download-callback (status url) (unless (plist-get status :error) @@ -2128,12 +2130,12 @@ eww-desktop-misc-data Only the properties listed in `eww-desktop-data-save' are included. Generally, the list should not include the (usually overly large) :dom, :source and :text properties." - (let ((history (mapcar 'eww-desktop-data-1 - (cons eww-data eww-history)))) - (list :history (if eww-desktop-remove-duplicates - (cl-remove-duplicates - history :test 'eww-desktop-history-duplicate) - history)))) + (let ((history (mapcar #'eww-desktop-data-1 + (cons eww-data eww-history)))) + (list :history (if eww-desktop-remove-duplicates + (cl-remove-duplicates + history :test #'eww-desktop-history-duplicate) + history)))) (defun eww-restore-desktop (file-name buffer-name misc-data) "Restore an eww buffer from its desktop file record. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 1f80ab74db..03260c9e70 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -135,7 +135,7 @@ shr-content-function This is used for cid: URLs, and the function is called with the cid: URL as the argument.") -(defvar shr-put-image-function 'shr-put-image +(defvar shr-put-image-function #'shr-put-image "Function called to put image and alt string.") (defface shr-strike-through '((t :strike-through t)) @@ -365,25 +365,20 @@ shr-maybe-probe-and-copy-url (shr-copy-url url))) (defun shr--current-link-region () - (let ((current (get-text-property (point) 'shr-url)) - start) - (save-excursion - ;; Go to the beginning. - (while (and (not (bobp)) - (equal (get-text-property (point) 'shr-url) current)) - (forward-char -1)) - (unless (equal (get-text-property (point) 'shr-url) current) - (forward-char 1)) - (setq start (point)) - ;; Go to the end. - (while (and (not (eobp)) - (equal (get-text-property (point) 'shr-url) current)) - (forward-char 1)) - (list start (point))))) + "Return the start and end positions of the URL at point, if any. +Value is a pair of positions (START . END) if there is a non-nil +`shr-url' text property at point; otherwise nil." + (when (get-text-property (point) 'shr-url) + (let* ((end (or (next-single-property-change (point) 'shr-url) + (point-max))) + (beg (or (previous-single-property-change end 'shr-url) + (point-min)))) + (cons beg end)))) (defun shr--blink-link () - (let* ((region (shr--current-link-region)) - (overlay (make-overlay (car region) (cadr region)))) + "Briefly fontify URL at point with the face `shr-selected-link'." + (when-let* ((region (shr--current-link-region)) + (overlay (make-overlay (car region) (cdr region)))) (overlay-put overlay 'face 'shr-selected-link) (run-at-time 1 nil (lambda () (delete-overlay overlay))))) @@ -437,7 +432,7 @@ shr-insert-image (if (not url) (message "No image under point") (message "Inserting %s..." url) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) (1- (point)) (point-marker)) t)))) @@ -463,7 +458,7 @@ shr-zoom-image (when (> (- (point) start) 2) (delete-region start (1- (point))))) (message "Inserting %s..." url) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) (1- (point)) (point-marker) (list (cons 'size (cond ((or (eq size 'default) @@ -493,7 +488,7 @@ shr-indirect-call ((fboundp function) (apply function dom args)) (t - (apply 'shr-generic dom args))))) + (apply #'shr-generic dom args))))) (defun shr-descend (dom) (let ((function @@ -730,9 +725,10 @@ shr-fill-line (let ((gap-start (point)) (face (get-text-property (point) 'face))) ;; Extend the background to the end of the line. - (if face - (insert (propertize "\n" 'face (shr-face-background face))) - (insert "\n")) + (insert ?\n) + (when face + (put-text-property (1- (point)) (point) + 'face (shr-face-background face))) (shr-indent) (when (and (> (1- gap-start) (point-min)) (get-text-property (point) 'shr-url) @@ -935,12 +931,11 @@ shr-ensure-paragraph (defun shr-indent () (when (> shr-indentation 0) - (insert - (if (not shr-use-fonts) - (make-string shr-indentation ?\s) - (propertize " " - 'display - `(space :width (,shr-indentation))))))) + (if (not shr-use-fonts) + (insert-char ?\s shr-indentation) + (insert ?\s) + (put-text-property (1- (point)) (point) + 'display `(space :width (,shr-indentation)))))) (defun shr-fontize-dom (dom &rest types) (let ((start (point))) @@ -987,16 +982,11 @@ shr-browse-url (cond ((not url) (message "No link under point")) - ((string-match "^mailto:" url) - (browse-url-mail url)) + (external + (funcall browse-url-secondary-browser-function url) + (shr--blink-link)) (t - (if external - (progn - (funcall browse-url-secondary-browser-function url) - (shr--blink-link)) - (browse-url url (if new-window - (not browse-url-new-window-flag) - browse-url-new-window-flag))))))) + (browse-url url (xor new-window browse-url-new-window-flag)))))) (defun shr-save-contents (directory) "Save the contents from URL in a file." @@ -1005,7 +995,7 @@ shr-save-contents (if (not url) (message "No link under point") (url-retrieve (shr-encode-url url) - 'shr-store-contents (list url directory))))) + #'shr-store-contents (list url directory))))) (defun shr-store-contents (status url directory) (unless (plist-get status :error) @@ -1156,7 +1146,6 @@ shr-rescale-image ;; url-cache-extract autoloads url-cache. (declare-function url-cache-create-filename "url-cache" (url)) -(autoload 'browse-url-mail "browse-url") (defun shr-get-image-data (url) "Get image data for URL. @@ -1230,7 +1219,7 @@ shr-image-displayer (funcall shr-put-image-function image (buffer-substring start end)) (delete-region (point) end)))) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) start end) t t))))) @@ -1679,7 +1668,7 @@ shr-tag-img (or alt ""))) (insert " ") (url-queue-retrieve - (shr-encode-url url) 'shr-image-fetched + (shr-encode-url url) #'shr-image-fetched (list (current-buffer) start (set-marker (make-marker) (point)) (list :width width :height height)) t @@ -2006,12 +1995,11 @@ shr-table-body (cond ((null tbodies) dom) - ((= (length tbodies) 1) + ((null (cdr tbodies)) (car tbodies)) (t ;; Table with multiple tbodies. Convert into a single tbody. - `(tbody nil ,@(cl-reduce 'append - (mapcar 'dom-non-text-children tbodies))))))) + `(tbody nil ,@(mapcan #'dom-non-text-children tbodies)))))) (defun shr--fix-tbody (tbody) (nconc (list 'tbody (dom-attributes tbody)) @@ -2311,8 +2299,8 @@ shr-table-widths (dolist (column row) (aset natural-widths i (max (aref natural-widths i) column)) (setq i (1+ i))))) - (let ((extra (- (apply '+ (append suggested-widths nil)) - (apply '+ (append widths nil)) + (let ((extra (- (apply #'+ (append suggested-widths nil)) + (apply #'+ (append widths nil)) (* shr-table-separator-pixel-width (1+ (length widths))))) (expanded-columns 0)) ;; We have extra, unused space, so divide this space amongst the -- 2.26.2 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 09 09:32:39 2020 Received: (at 41133) by debbugs.gnu.org; 9 May 2020 13:32:39 +0000 Received: from localhost ([127.0.0.1]:46962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXPao-0007jZ-Q3 for submit@debbugs.gnu.org; Sat, 09 May 2020 09:32:39 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:42363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXPan-0007jH-AA for 41133@debbugs.gnu.org; Sat, 09 May 2020 09:32:37 -0400 Received: by mail-wr1-f41.google.com with SMTP id s8so5168648wrt.9 for <41133@debbugs.gnu.org>; Sat, 09 May 2020 06:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=bibYVyGj6j4c2xfyVWQc+LdLmZ9VWibZIlcC7+tqArk=; b=hWjMQmFsX8TDcyndsKvEz7C9lJBi6u/NagCfH0H+JuHN9/q5s2LHHR4XEJe354BSok EXU9Ht7T/W4iC23v0oLzaIiRLkkWWGvd5aNmU+eDD4kt0QNRywnlzu8L6Btxy5H1alRk eBMr/973NvwsS6iUUUWn8TLWv0DWvRRwmWz0SEpDfwG0jovAPfGstwnJY5p96XdqhPcq b7FHyci0vJHc9h0zWL0b5VypbdkrA4vF/SVGwmtMAE+w+tbYm3xkRttbJpzxeUI9o6jX HmxSvesyPNyhqv/Hm2TVuhfOr7YixCDDfgvScwIDTPt0gFyeqMrARfkqarJn4I8XZ3eF MhDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=bibYVyGj6j4c2xfyVWQc+LdLmZ9VWibZIlcC7+tqArk=; b=BPZsnSPYAckH2jdPDV4A3PJqqSQTJbA6JUEyNbwnO+kNBWPy8PDmsD6JQECRC15Mgc TWB3DR/aGCI3KVuGoh9z+T+9NWLzlDqJvj5TqQ21m3Xh+D5wAF3lglVMzxTwIewGC//H ZE+D0yJKyAiz+d0vUbZ1CiZz00ddUMSxkkY1r6wb4LdgmHaazM/VC5YIiTn37MlNt8hY sXfj+H+QNq0GIPUa/YNiOIwZzdnJRYQzos3lSd+U9cmMuHC/OHZiRno1vPcvmIx70SCF gZ659CEyCIPMJYJ5VnUxeAYcYWGfEu3phughVMaxoWplr5iLkyc0xU8mVKpml9MRpTmt /v7A== X-Gm-Message-State: AGi0PuYpZUpM/FOPBZKiLKOebUfO8n+AC5Q9b7bF0/WSMwpq+OhLAXb0 aFQJX05UAiPIJWoJWXmSK80MSA== X-Google-Smtp-Source: APiQypJN9CR+QKivSWib6VrDffY7HYiZ7q2HH9Fv8kUryG/exEApSGSUQiddh0quoOj24EKVaHUlCw== X-Received: by 2002:a5d:54c4:: with SMTP id x4mr9075793wrv.73.1589031151438; Sat, 09 May 2020 06:32:31 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id b22sm25893949wmj.1.2020.05.09.06.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2020 06:32:30 -0700 (PDT) From: "Basil L. Contovounesios" To: Tassilo Horn Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <87h7wqlwrw.fsf@gnu.org> Date: Sat, 09 May 2020 14:32:29 +0100 In-Reply-To: <87h7wqlwrw.fsf@gnu.org> (Tassilo Horn's message of "Fri, 08 May 2020 09:18:43 +0200") Message-ID: <87sgg9tes2.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41133 Cc: lars ingebrigtsen , 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Tassilo Horn writes: > "Basil L. Contovounesios" writes: > >> X-Debbugs-Cc: Lars Ingebrigtsen , Tassilo Horn >> Severity: wishlist >> Tags: patch >> >> The commands shr-browse-url and eww-follow-link currently pass mailto >> URLs directly to browse-url-mail, which doesn't respect the user options >> browse-url-handlers and browse-url-mailto-function. >> >> Can't/shouldn't the commands call browse-url instead? >> WDYT of the attached patch that does this? > > Looks good to me (I just looked at the parts calling browse-url), and I > think it won't change any behavior unless the user customizes > browse-url-handlers to catch mailto links with his own function instead > of the default one in browse-url-default-handlers (which in turn just > calls browse-url-mailto-function). Thanks. > BTW: I didn't know about function-put. Should that be preferred to put? > I've tested that put/get also work with #'function, so where's the > difference? function-put is currently identical to put, but this may change in the future. Quoth (info "(elisp) Symbol Plists"): -- Function: function-put function property value This function sets PROPERTY of FUNCTION to VALUE. FUNCTION should be a symbol. This function is preferred to calling =E2=80=98put=E2=80= =99 for setting properties of a function, because it will allow us some day to implement remapping of old properties to new ones. See also the commentary in its definition: (defalias 'function-put ;; We don't want people to just use `put' because we can't conveniently ;; hook into `put' to remap old properties to new ones. But for now, t= here's ;; no such remapping, so we just call `put'. #'(lambda (function prop value) "Set FUNCTION's property PROP to VALUE. The namespace for PROP is shared with symbols. So far, FUNCTION can only be a symbol, not a lambda expression." (put function prop value))) --=20 Basil From debbugs-submit-bounces@debbugs.gnu.org Sat May 09 09:42:23 2020 Received: (at 41133) by debbugs.gnu.org; 9 May 2020 13:42:23 +0000 Received: from localhost ([127.0.0.1]:46972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXPkF-000816-2o for submit@debbugs.gnu.org; Sat, 09 May 2020 09:42:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXPkD-00080r-9t for 41133@debbugs.gnu.org; Sat, 09 May 2020 09:42:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52156) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXPk7-0000pw-LV; Sat, 09 May 2020 09:42:15 -0400 Received: from [176.228.60.248] (port=3464 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jXPk6-0000PP-F1; Sat, 09 May 2020 09:42:14 -0400 Date: Sat, 09 May 2020 16:42:04 +0300 Message-Id: <83a72hfcnn.fsf@gnu.org> From: Eli Zaretskii To: "Basil L. Contovounesios" In-Reply-To: <873689utkw.fsf@tcd.ie> (contovob@tcd.ie) Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <83368bj5jl.fsf@gnu.org> <873689utkw.fsf@tcd.ie> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41133 Cc: larsi@gnus.org, tsdh@gnu.org, 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "Basil L. Contovounesios" > Cc: 41133@debbugs.gnu.org, larsi@gnus.org, tsdh@gnu.org > Date: Sat, 09 May 2020 14:27:27 +0100 > > > This would need a NEWS entry. > > Right. How's the following? Thanks. > ++++ > +*** The command 'shr-browse-url' now supports custom mailto handlers. > +Clicking on or otherwise following a 'mailto:' link in a HTML buffer > +rendered by SHR previously invoked the command 'browse-url-mailto'. > +This is still the case by default, but which function is invoked can > +now be customized via the user options 'browse-url-mailto-function' > +and 'browse-url-handlers'. I'd rephrase the last sentence like this: This is still the case by default, but if you customized 'browse-url-mailto-function' to call some other function, it will now be called instead of the default. Also, the "+++" means the change is documented in some manual, but no changes for the manual are part of the patch, so I guess you meant "---" instead. > +** EWW > + > ++++ > +*** The command 'eww-follow-link' now supports custom mailto handlers. > +Clicking on or otherwise following a 'mailto:' link in an EWW buffer > +previously invoked the command 'browse-url-mailto'. This is still the > +case by default, but which function is invoked can now be customized > +via the user options 'browse-url-mailto-function' and > +'browse-url-handlers'. Maybe we should point to the SHR entry instead of repeating almost the same text. From debbugs-submit-bounces@debbugs.gnu.org Sat May 09 20:06:06 2020 Received: (at 41133) by debbugs.gnu.org; 10 May 2020 00:06:06 +0000 Received: from localhost ([127.0.0.1]:48596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXZTp-000647-UW for submit@debbugs.gnu.org; Sat, 09 May 2020 20:06:06 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:45475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXZTo-00063b-3L for 41133@debbugs.gnu.org; Sat, 09 May 2020 20:06:04 -0400 Received: by mail-wr1-f41.google.com with SMTP id v12so6301326wrp.12 for <41133@debbugs.gnu.org>; Sat, 09 May 2020 17:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=MSDXPUEcYTZXzRAhmGSu+w592MK2MrhZ2Zku9oK0xoE=; b=0ar2ZkQs+rIzeqd37ygROCwWOCJXQV/cGa1g0u21BQ0zkDJWNrEd3jzHqRO4mrjHXa oM1FGwRL0CILTgt05gqYkcbH0Im48CIKNxiqohtQvVlPF04Ys9NH8NMsReSXO9m6x5jU aFhOs3qXeuU6yXcpk6ND+NL8P0yI85Wb+mM561XqoCGiENwIxevWQrnErOln6BAbouMN JO0OYtt/ZwZw0tVPbo7bivzTNXydBt24gmqiKWDqbcDfffgNkveazaqxcG1DTQQsk7Mm FLE7noz80OeeCjKJhze49hdDLZ8EzVJoQv7UwmZoWgXHQdzXjcfkQB/an7yIyD4ossm9 zLxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=MSDXPUEcYTZXzRAhmGSu+w592MK2MrhZ2Zku9oK0xoE=; b=RiMF14VBb3Mnj6HWNz0OrvKTqGg/R8DTmtEcZvy3/4ZywjzchWMqJeNxE5oBiW83D2 AgEYfuXO748qaSbG6zh3U2NaEncDFs64UpKL/a+mk2vJIouRDHwEvp3TB45ifgARZd7O dYEKD7q+S27FWx/Z29CvYJ8sUi4Htc8j5A4nFatOFHuq/JHKpPkCQfOjqbgjSnteyW8I +DqYrqFPR7kFxNPPxE6ptmaKvCODGc5llvqlCJUFELM9cQyUMti2YPA4Q9UTk4lA+26f jC2xfbbwvVSNv6Ncyfa4j6dQSeKuE+ltbptE7MsRv3pzPGp1pxgrEEU5Mslz3gMCdQfq NT4g== X-Gm-Message-State: AGi0PubYszpUtxxVFBzt+QruhvA2bcmDvTKEE/AWtiwKIwMHNsWJTL3s HHPeS55aSDPaddSf3jH0QPmk5w== X-Google-Smtp-Source: APiQypLdnM4oqs2zGSnN3pOLIDfrFQ09DamX2vyo2V2IfKIJJlN5EiU4PDiOIEUKB/d3yfZvykf6zA== X-Received: by 2002:a5d:4f10:: with SMTP id c16mr10095492wru.243.1589069158165; Sat, 09 May 2020 17:05:58 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id z7sm10413407wrl.88.2020.05.09.17.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2020 17:05:57 -0700 (PDT) From: "Basil L. Contovounesios" To: Eli Zaretskii Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <83368bj5jl.fsf@gnu.org> <873689utkw.fsf@tcd.ie> <83a72hfcnn.fsf@gnu.org> Date: Sun, 10 May 2020 01:05:55 +0100 In-Reply-To: <83a72hfcnn.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 May 2020 16:42:04 +0300") Message-ID: <87y2q08xi4.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41133 Cc: larsi@gnus.org, tsdh@gnu.org, 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> ++++ >> +*** The command 'shr-browse-url' now supports custom mailto handlers. >> +Clicking on or otherwise following a 'mailto:' link in a HTML buffer >> +rendered by SHR previously invoked the command 'browse-url-mailto'. >> +This is still the case by default, but which function is invoked can >> +now be customized via the user options 'browse-url-mailto-function' >> +and 'browse-url-handlers'. > > I'd rephrase the last sentence like this: > > This is still the case by default, but if you customized > 'browse-url-mailto-function' to call some other function, it will > now be called instead of the default. Should it not also mention browse-url-handlers as per the attached? > Also, the "+++" means the change is documented in some manual, but no > changes for the manual are part of the patch, so I guess you meant > "---" instead. Oops, I misremembered "+++" as meaning "all necessary doc changes made" instead of just "doc changes made". >> +** EWW >> + >> ++++ >> +*** The command 'eww-follow-link' now supports custom mailto handlers. >> +Clicking on or otherwise following a 'mailto:' link in an EWW buffer >> +previously invoked the command 'browse-url-mailto'. This is still the >> +case by default, but which function is invoked can now be customized >> +via the user options 'browse-url-mailto-function' and >> +'browse-url-handlers'. > > Maybe we should point to the SHR entry instead of repeating almost the > same text. Sure, how's this? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Improve-shr-eww-handling-of-mailto-URLs.patch >From 6ab52e1f5c13a231199045acac8f42fca40cb4d5 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 6 May 2020 18:02:32 +0100 Subject: [PATCH] Improve shr/eww handling of mailto URLs * lisp/net/eww.el (eww): Use function-put in place of put, as recommended in "(elisp) Symbol Plists". (eww-follow-link): * lisp/net/shr.el (shr-browse-url): Rather than call browse-url-mail directly, call browse-url which respects the user options browse-url-handlers and browse-url-mailto-function. (Bug#41133) (shr--current-link-region): Return nil if there is no link at point. (shr--blink-link): Adapt accordingly. (shr-fill-line, shr-indent, shr-table-body): Refactor to avoid some unnecessary allocations. * etc/NEWS: Announce that eww-follow-link and shr-browse-url support custom URL handlers. --- etc/NEWS | 18 +++++++++++ lisp/net/eww.el | 30 +++++++++--------- lisp/net/shr.el | 84 +++++++++++++++++++++---------------------------- 3 files changed, 70 insertions(+), 62 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index ae676a9bf8..f4c0890663 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -348,6 +348,24 @@ symbol property to the browsing functions. With a new command 'browse-url-with-browser-kind', an URL can explicitly be browsed with either an internal or external browser. +** SHR + +--- +*** The command 'shr-browse-url' now supports custom mailto handlers. +Clicking on or otherwise following a 'mailto:' link in a HTML buffer +rendered by SHR previously invoked the command 'browse-url-mailto'. +This is still the case by default, but if you customize +'browse-url-mailto-function' or 'browse-url-handlers' to call some +other function, it will now be called instead of the default. + +** EWW + +--- +*** The command 'eww-follow-link' now supports custom mailto handlers. +The function that is invoked when clicking on or otherwise following a +'mailto:' link in an EWW buffer can now be customized. For more +information, see the related entry about 'shr-browse-url' above. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/net/eww.el b/lisp/net/eww.el index a6c1abdbb1..2a70560ca7 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -307,10 +307,10 @@ eww (insert (format "Loading %s..." url)) (goto-char (point-min))) (let ((url-mime-accept-string eww-accept-content-types)) - (url-retrieve url 'eww-render + (url-retrieve url #'eww-render (list url nil (current-buffer))))) -(put 'eww 'browse-url-browser-kind 'internal) +(function-put 'eww 'browse-url-browser-kind 'internal) (defun eww--dwim-expand-url (url) (setq url (string-trim url)) @@ -375,8 +375,8 @@ eww-search-words (let ((region-string (buffer-substring (region-beginning) (region-end)))) (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string)) (eww region-string) - (call-interactively 'eww))) - (call-interactively 'eww))) + (call-interactively #'eww))) + (call-interactively #'eww))) (defun eww-open-in-new-buffer () "Fetch link at point in a new EWW buffer." @@ -1013,7 +1013,7 @@ eww-reload (eww-display-html 'utf-8 url (plist-get eww-data :dom) (point) (current-buffer))) (let ((url-mime-accept-string eww-accept-content-types)) - (url-retrieve url 'eww-render + (url-retrieve url #'eww-render (list url (point) (current-buffer) encode)))))) ;; Form support. @@ -1576,8 +1576,10 @@ eww-follow-link (cond ((not url) (message "No link under point")) - ((string-match "^mailto:" url) - (browse-url-mail url)) + ((string-match-p "\\`mailto:" url) + ;; This respects the user options `browse-url-handlers' + ;; and `browse-url-mailto-function'. + (browse-url url)) ((and (consp external) (<= (car external) 4)) (funcall browse-url-secondary-browser-function url) (shr--blink-link)) @@ -1615,7 +1617,7 @@ eww-download (eww-current-url)))) (if (not url) (message "No URL under point") - (url-retrieve url 'eww-download-callback (list url))))) + (url-retrieve url #'eww-download-callback (list url))))) (defun eww-download-callback (status url) (unless (plist-get status :error) @@ -2128,12 +2130,12 @@ eww-desktop-misc-data Only the properties listed in `eww-desktop-data-save' are included. Generally, the list should not include the (usually overly large) :dom, :source and :text properties." - (let ((history (mapcar 'eww-desktop-data-1 - (cons eww-data eww-history)))) - (list :history (if eww-desktop-remove-duplicates - (cl-remove-duplicates - history :test 'eww-desktop-history-duplicate) - history)))) + (let ((history (mapcar #'eww-desktop-data-1 + (cons eww-data eww-history)))) + (list :history (if eww-desktop-remove-duplicates + (cl-remove-duplicates + history :test #'eww-desktop-history-duplicate) + history)))) (defun eww-restore-desktop (file-name buffer-name misc-data) "Restore an eww buffer from its desktop file record. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 1f80ab74db..03260c9e70 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -135,7 +135,7 @@ shr-content-function This is used for cid: URLs, and the function is called with the cid: URL as the argument.") -(defvar shr-put-image-function 'shr-put-image +(defvar shr-put-image-function #'shr-put-image "Function called to put image and alt string.") (defface shr-strike-through '((t :strike-through t)) @@ -365,25 +365,20 @@ shr-maybe-probe-and-copy-url (shr-copy-url url))) (defun shr--current-link-region () - (let ((current (get-text-property (point) 'shr-url)) - start) - (save-excursion - ;; Go to the beginning. - (while (and (not (bobp)) - (equal (get-text-property (point) 'shr-url) current)) - (forward-char -1)) - (unless (equal (get-text-property (point) 'shr-url) current) - (forward-char 1)) - (setq start (point)) - ;; Go to the end. - (while (and (not (eobp)) - (equal (get-text-property (point) 'shr-url) current)) - (forward-char 1)) - (list start (point))))) + "Return the start and end positions of the URL at point, if any. +Value is a pair of positions (START . END) if there is a non-nil +`shr-url' text property at point; otherwise nil." + (when (get-text-property (point) 'shr-url) + (let* ((end (or (next-single-property-change (point) 'shr-url) + (point-max))) + (beg (or (previous-single-property-change end 'shr-url) + (point-min)))) + (cons beg end)))) (defun shr--blink-link () - (let* ((region (shr--current-link-region)) - (overlay (make-overlay (car region) (cadr region)))) + "Briefly fontify URL at point with the face `shr-selected-link'." + (when-let* ((region (shr--current-link-region)) + (overlay (make-overlay (car region) (cdr region)))) (overlay-put overlay 'face 'shr-selected-link) (run-at-time 1 nil (lambda () (delete-overlay overlay))))) @@ -437,7 +432,7 @@ shr-insert-image (if (not url) (message "No image under point") (message "Inserting %s..." url) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) (1- (point)) (point-marker)) t)))) @@ -463,7 +458,7 @@ shr-zoom-image (when (> (- (point) start) 2) (delete-region start (1- (point))))) (message "Inserting %s..." url) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) (1- (point)) (point-marker) (list (cons 'size (cond ((or (eq size 'default) @@ -493,7 +488,7 @@ shr-indirect-call ((fboundp function) (apply function dom args)) (t - (apply 'shr-generic dom args))))) + (apply #'shr-generic dom args))))) (defun shr-descend (dom) (let ((function @@ -730,9 +725,10 @@ shr-fill-line (let ((gap-start (point)) (face (get-text-property (point) 'face))) ;; Extend the background to the end of the line. - (if face - (insert (propertize "\n" 'face (shr-face-background face))) - (insert "\n")) + (insert ?\n) + (when face + (put-text-property (1- (point)) (point) + 'face (shr-face-background face))) (shr-indent) (when (and (> (1- gap-start) (point-min)) (get-text-property (point) 'shr-url) @@ -935,12 +931,11 @@ shr-ensure-paragraph (defun shr-indent () (when (> shr-indentation 0) - (insert - (if (not shr-use-fonts) - (make-string shr-indentation ?\s) - (propertize " " - 'display - `(space :width (,shr-indentation))))))) + (if (not shr-use-fonts) + (insert-char ?\s shr-indentation) + (insert ?\s) + (put-text-property (1- (point)) (point) + 'display `(space :width (,shr-indentation)))))) (defun shr-fontize-dom (dom &rest types) (let ((start (point))) @@ -987,16 +982,11 @@ shr-browse-url (cond ((not url) (message "No link under point")) - ((string-match "^mailto:" url) - (browse-url-mail url)) + (external + (funcall browse-url-secondary-browser-function url) + (shr--blink-link)) (t - (if external - (progn - (funcall browse-url-secondary-browser-function url) - (shr--blink-link)) - (browse-url url (if new-window - (not browse-url-new-window-flag) - browse-url-new-window-flag))))))) + (browse-url url (xor new-window browse-url-new-window-flag)))))) (defun shr-save-contents (directory) "Save the contents from URL in a file." @@ -1005,7 +995,7 @@ shr-save-contents (if (not url) (message "No link under point") (url-retrieve (shr-encode-url url) - 'shr-store-contents (list url directory))))) + #'shr-store-contents (list url directory))))) (defun shr-store-contents (status url directory) (unless (plist-get status :error) @@ -1156,7 +1146,6 @@ shr-rescale-image ;; url-cache-extract autoloads url-cache. (declare-function url-cache-create-filename "url-cache" (url)) -(autoload 'browse-url-mail "browse-url") (defun shr-get-image-data (url) "Get image data for URL. @@ -1230,7 +1219,7 @@ shr-image-displayer (funcall shr-put-image-function image (buffer-substring start end)) (delete-region (point) end)))) - (url-retrieve url 'shr-image-fetched + (url-retrieve url #'shr-image-fetched (list (current-buffer) start end) t t))))) @@ -1679,7 +1668,7 @@ shr-tag-img (or alt ""))) (insert " ") (url-queue-retrieve - (shr-encode-url url) 'shr-image-fetched + (shr-encode-url url) #'shr-image-fetched (list (current-buffer) start (set-marker (make-marker) (point)) (list :width width :height height)) t @@ -2006,12 +1995,11 @@ shr-table-body (cond ((null tbodies) dom) - ((= (length tbodies) 1) + ((null (cdr tbodies)) (car tbodies)) (t ;; Table with multiple tbodies. Convert into a single tbody. - `(tbody nil ,@(cl-reduce 'append - (mapcar 'dom-non-text-children tbodies))))))) + `(tbody nil ,@(mapcan #'dom-non-text-children tbodies)))))) (defun shr--fix-tbody (tbody) (nconc (list 'tbody (dom-attributes tbody)) @@ -2311,8 +2299,8 @@ shr-table-widths (dolist (column row) (aset natural-widths i (max (aref natural-widths i) column)) (setq i (1+ i))))) - (let ((extra (- (apply '+ (append suggested-widths nil)) - (apply '+ (append widths nil)) + (let ((extra (- (apply #'+ (append suggested-widths nil)) + (apply #'+ (append widths nil)) (* shr-table-separator-pixel-width (1+ (length widths))))) (expanded-columns 0)) ;; We have extra, unused space, so divide this space amongst the -- 2.26.2 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 10 09:52:56 2020 Received: (at 41133) by debbugs.gnu.org; 10 May 2020 13:52:56 +0000 Received: from localhost ([127.0.0.1]:49233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXmO0-00087C-1i for submit@debbugs.gnu.org; Sun, 10 May 2020 09:52:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXmNn-00086Z-Oh for 41133@debbugs.gnu.org; Sun, 10 May 2020 09:52:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43346) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXmNi-00023P-4V; Sun, 10 May 2020 09:52:38 -0400 Received: from [176.228.60.248] (port=3891 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jXmNX-0001GT-UT; Sun, 10 May 2020 09:52:34 -0400 Date: Sun, 10 May 2020 16:52:18 +0300 Message-Id: <837dxjew31.fsf@gnu.org> From: Eli Zaretskii To: "Basil L. Contovounesios" In-Reply-To: <87y2q08xi4.fsf@tcd.ie> (contovob@tcd.ie) Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <83368bj5jl.fsf@gnu.org> <873689utkw.fsf@tcd.ie> <83a72hfcnn.fsf@gnu.org> <87y2q08xi4.fsf@tcd.ie> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41133 Cc: larsi@gnus.org, tsdh@gnu.org, 41133@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "Basil L. Contovounesios" > Cc: 41133@debbugs.gnu.org, larsi@gnus.org, tsdh@gnu.org > Date: Sun, 10 May 2020 01:05:55 +0100 > > Sure, how's this? LGTM, thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri May 22 11:43:54 2020 Received: (at control) by debbugs.gnu.org; 22 May 2020 15:43:54 +0000 Received: from localhost ([127.0.0.1]:60059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jc9py-0005Yh-Js for submit@debbugs.gnu.org; Fri, 22 May 2020 11:43:54 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jc9px-0005YU-Ht for control@debbugs.gnu.org; Fri, 22 May 2020 11:43:54 -0400 Received: by mail-wm1-f68.google.com with SMTP id u188so10266441wmu.1 for ; Fri, 22 May 2020 08:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=T+Qmf3/61yQVvzEOq/W1vWwQ1sbRY0fNTugLgm5qCKE=; b=mKMn8WHeScregy5llbxhnSmUuzl3pR52RDFFNfX52AByaFpjHpWR2ZUThUKQqYLL4G kU3dXY6mtPTiGlGcxCEpoN2UnIxvvyxzvRDbHXPKDTcRCKiiQHXxCOGVmAwO9vMuavuj pAsOGc55AClxr+jrkK+Dpn1CqqzKF7J96hnBxBpax8Skf3DKXA6N/aacX0S7XUMV0cy7 UeTyKVa63JgsiRBAAy8A4rcTlJVRjyH6QXt/D/E7/DVbtawsIJKdPnpKRrvtqa5ILEXe R+L1901s2Rm2ZhmPekgEipRAz6QfAda9crvrVsfsTV24Ru7dGEP8fzceUVjjlEM4rJCk mzIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=T+Qmf3/61yQVvzEOq/W1vWwQ1sbRY0fNTugLgm5qCKE=; b=ZGJjiGQ+V20zIdAR8pWhAxDBrBSmPOGM+nXfQ/3KYHyxJfdCiA2mgUoQA3JIIEbYRh 2MTG8VI6m084HxuMh4pUudtvTooktitg+Z6nSNgHKbwI13/WOj4k4Pp6ttFLcUyKFQZG DVNzVv5FX6w0lBztPY3yfMLbQLWbjqTcGJSaCSQpi6Np6IvZXDg3hnFETmd/3Em5tIFa +fMUbKve3fTdMoYs0ONKLlPyfTTiuq37dUbQNgcn/d1X68xoRd6cPxSTYcFgGX/d86bF Ranm9kno4mkhxOhEZKtxajv9gbkr8i1EB0kqVATPDxdrERL1qpNVWvdI2g9/faQiarqR wMWQ== X-Gm-Message-State: AOAM530ux8VqcQeoWa8JQ8gD+bHyqJQeHsS+qUoxM1/yerRgia7CsR5z g96Y91P0AYZJ0e9tRme2btH2oA== X-Google-Smtp-Source: ABdhPJw1CoW1rDJL5OnFRXGsHBURl/GO5Afcwmo/4qaWy5x6EPQRcVoRgrEbfWeZfUetX+tDtgk0WA== X-Received: by 2002:a1c:740e:: with SMTP id p14mr14382715wmc.102.1590162227682; Fri, 22 May 2020 08:43:47 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id n7sm8738819wrj.39.2020.05.22.08.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 08:43:46 -0700 (PDT) From: "Basil L. Contovounesios" To: Eli Zaretskii Subject: Re: bug#41133: 28.0.50; Respect browse-url user options in shr/eww References: <87wo5njkbq.fsf@tcd.ie> <83368bj5jl.fsf@gnu.org> <873689utkw.fsf@tcd.ie> <83a72hfcnn.fsf@gnu.org> <87y2q08xi4.fsf@tcd.ie> <837dxjew31.fsf@gnu.org> Date: Fri, 22 May 2020 16:43:45 +0100 In-Reply-To: <837dxjew31.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 10 May 2020 16:52:18 +0300") Message-ID: <87h7w87z66.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control Cc: 41133-done@debbugs.gnu.org, larsi@gnus.org, tsdh@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 41133 fixed close 41133 28.1 quit Eli Zaretskii writes: > LGTM, thanks. Thanks, pushed to master. Improve shr/eww handling of mailto URLs 3a7894ecd1 2020-05-22 16:28:20 +0100 https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3a7894ecd11c66337e7aea8ade8f47673d290a24 -- Basil From unknown Fri Sep 19 16:05:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 20 Jun 2020 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator