From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vasilij Schneidermann Newsgroups: gmane.emacs.bugs Subject: bug#28402: 25.2; shr.el uses shr-tag-img despite set shr-external-rendering-functions Date: Sun, 24 Sep 2017 15:10:50 +0200 Message-ID: <20170924131050.6erv6sshvz23dlbu@odonien.localdomain> References: <83poaxrzl1.fsf@gnu.org> <20170913172232.7jwwomyfmy567nrx@odonien.localdomain> <83lglio36q.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="b4l355ypf6qri5xh" X-Trace: blaine.gmane.org 1506258680 3657 195.159.176.226 (24 Sep 2017 13:11:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 24 Sep 2017 13:11:20 +0000 (UTC) User-Agent: NeoMutt/20170714-155-820ab5 (1.8.3) Cc: larsi@gnus.org, 28402@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 24 15:11:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw6gk-0000VI-0u for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Sep 2017 15:11:14 +0200 Original-Received: from localhost ([::1]:38127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw6gr-0005Qv-6K for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Sep 2017 09:11:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw6gd-0005OC-4c for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 09:11:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dw6gY-0006sV-Jb for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 09:11:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dw6gY-0006sI-EW for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 09:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dw6gY-0000lr-8z for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 09:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Sep 2017 13:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28402 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28402-submit@debbugs.gnu.org id=B28402.15062586612946 (code B ref 28402); Sun, 24 Sep 2017 13:11:02 +0000 Original-Received: (at 28402) by debbugs.gnu.org; 24 Sep 2017 13:11:01 +0000 Original-Received: from localhost ([127.0.0.1]:55300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw6gW-0000lP-Oa for submit@debbugs.gnu.org; Sun, 24 Sep 2017 09:11:01 -0400 Original-Received: from mail-wm0-f68.google.com ([74.125.82.68]:34206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw6gU-0000lB-SX for 28402@debbugs.gnu.org; Sun, 24 Sep 2017 09:10:59 -0400 Original-Received: by mail-wm0-f68.google.com with SMTP id i131so4986383wma.1 for <28402@debbugs.gnu.org>; Sun, 24 Sep 2017 06:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9+ZytphHuLNKlI6ObqhcMq0y3W1KN4QBFfEOLDRBd7o=; b=KBILgB/7sZpOEyKB7jLfgQ46X5dqpDLQF9xIEhmncHGGoRmfvPULvGkNcjEwtoGnzu 8VSiAHFGE8WK2RFwXlUqvpylIIFp/Z1W7+OZv+tC2mCG11BMdMu038AXxMy1Bg2XdAQB Ic9rkQKmE/5UR7Yq+Z3PcoKnBYT63dIU3DzQr9rq8k7I3pD5gzuVYtpu+bWPE3JBpZF7 upq4X/wZYBanhzwoIMQfoOiXQcJfZdedhrgMG3mQhplA7uRm9JBwCyzq7ZDzS9fu7Tfn MjlU6wp4Re8rPViHVNlwlBXf+Nx08c37frcdcJifOYdZUFKyMn4CUrgbiSgx6YOnvW/N 62mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9+ZytphHuLNKlI6ObqhcMq0y3W1KN4QBFfEOLDRBd7o=; b=VN4OtU/xnKhan04x6/TdunyjNxJsw0d7CIbLmcjOI+5Tfu8RkbHy1tq4Z1at/Lim+3 vearx7uCd/njqqIij5MpHgzo27/6YoIdXe6AFFlE+Cxw2PbUCDXsKYB1C3f8oAB+YDYl TZHBim2mbIaS+lLTbhSZAjzCCS1h2AlCHmxYVb2RNnKO9Lf68pszzT94NaFQwW7kBNcB kT16rDilsRUk3p9RCASUeTj6rb+lcyX2BWTCEgzMYCORf/7PFw50+UjjAyX0Y6msQYto ewQQpjXIiMmh4mjm81HEWLuprwt6aawPm8jACGPd362DL3lOYgBIEx1gfpNzhThlS47Y BF7w== X-Gm-Message-State: AHPjjUg4Crx24Fm9aHvP++QTdBm15mM2dih2WM/RjCM6Ae9x35sz343L OH6etq7av/mZIs6yt6Ml8xY= X-Google-Smtp-Source: AOwi7QBKdxIYVU1Cu1xOLslLUEKMAz57EgmCYvAZBYnj1uRkoXaFUe/mmly4LNm6MK/xE0n/hpOVWg== X-Received: by 10.80.149.75 with SMTP id v11mr11107658eda.284.1506258653074; Sun, 24 Sep 2017 06:10:53 -0700 (PDT) Original-Received: from localhost (dslb-094-220-201-116.094.220.pools.vodafone-ip.de. [94.220.201.116]) by smtp.gmail.com with ESMTPSA id w10sm2725528eda.73.2017.09.24.06.10.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 06:10:51 -0700 (PDT) Content-Disposition: inline In-Reply-To: <83lglio36q.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137338 Archived-At: --b4l355ypf6qri5xh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline > Fair enough. Fortunately, it sounds like Lars have just agreed to > that. Alright, I finally got to creating a patch for this. --b4l355ypf6qri5xh Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Add-indirection-to-all-shr-tag-calls.patch" >From abe3f5702999b3b11645d924c7d05f48f4a265c4 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Sun, 24 Sep 2017 14:59:10 +0200 Subject: [PATCH] Add indirection to all shr-tag-* calls The 'shr-external-rendering-functions' variable was previously only honored in the shr-descend function, now all direct calls to the shr-tag-* functions have been replaced by a call to 'shr-indirect-call' which tries using an alternative rendering function first. * lisp/net/shr.el (shr-indirect-call): New helper function. (shr-descend, shr-tag-object, shr-tag-video): (shr-collect-extra-strings-in-table): Fix callers --- lisp/net/shr.el | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 7af6148e47..fe5197b35f 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -470,12 +470,20 @@ shr-generic (shr-insert sub) (shr-descend sub)))) +(defun shr-indirect-call (tag-name dom &rest args) + (let ((function (intern (concat "shr-tag-" (symbol-name tag-name)) obarray)) + ;; Allow other packages to override (or provide) rendering + ;; of elements. + (external (cdr (assq tag-name shr-external-rendering-functions)))) + (cond (external + (apply external dom args)) + ((fboundp function) + (apply function dom args)) + (t + (apply 'shr-generic dom args))))) + (defun shr-descend (dom) - (let ((function - (intern (concat "shr-tag-" (symbol-name (dom-tag dom))) obarray)) - ;; Allow other packages to override (or provide) rendering - ;; of elements. - (external (cdr (assq (dom-tag dom) shr-external-rendering-functions))) + (let ((tag-name (dom-tag dom)) (style (dom-attr dom 'style)) (shr-stylesheet shr-stylesheet) (shr-depth (1+ shr-depth)) @@ -490,12 +498,7 @@ shr-descend (setq style nil))) ;; If we have a display:none, then just ignore this part of the DOM. (unless (equal (cdr (assq 'display shr-stylesheet)) "none") - (cond (external - (funcall external dom)) - ((fboundp function) - (funcall function dom)) - (t - (shr-generic dom))) + (shr-indirect-call tag-name dom) (when (and shr-target-id (equal (dom-attr dom 'id) shr-target-id)) ;; If the element was empty, we don't have anything to put the @@ -1404,7 +1407,7 @@ shr-tag-object (when url (cond (image - (shr-tag-img dom url) + (shr-indirect-call 'img dom url) (setq dom nil)) (multimedia (shr-insert " [multimedia] ") @@ -1469,7 +1472,7 @@ shr-tag-video (unless url (setq url (car (shr--extract-best-source dom)))) (if (> (length image) 0) - (shr-tag-img nil image) + (shr-indirect-call 'img nil image) (shr-insert " [video] ")) (shr-urlify start (shr-expand-url url)))) @@ -1964,9 +1967,9 @@ shr-collect-extra-strings-in-table do (setq tag (dom-tag child)) and unless (memq tag '(comment style)) if (eq tag 'img) - do (shr-tag-img child) + do (shr-indirect-call 'img child) else if (eq tag 'object) - do (shr-tag-object child) + do (shr-indirect-call 'object child) else do (setq recurse t) and if (eq tag 'tr) @@ -1980,7 +1983,7 @@ shr-collect-extra-strings-in-table do (setq flags nil) else if (car flags) do (setq recurse nil) - (shr-tag-table child) + (shr-indirect-call 'table child) end end end end end end end end end end when recurse append (shr-collect-extra-strings-in-table child flags))) -- 2.14.1 --b4l355ypf6qri5xh--