From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#58118: 29.0.50; Follow #target links in eww without re-rendering page Date: Wed, 28 Sep 2022 08:12:51 +0530 Message-ID: <87v8p8z0b8.fsf@gmail.com> References: <87leq4rfno.fsf@gmail.com> <87v8p823c7.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29555"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 58118@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 28 04:44:10 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odN3S-0007YX-FS for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Sep 2022 04:44:10 +0200 Original-Received: from localhost ([::1]:55580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odN3Q-0001OQ-WB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 27 Sep 2022 22:44:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odN3K-0001OF-Ff for bug-gnu-emacs@gnu.org; Tue, 27 Sep 2022 22:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odN3K-0006kl-81 for bug-gnu-emacs@gnu.org; Tue, 27 Sep 2022 22:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odN3K-0000iF-2K for bug-gnu-emacs@gnu.org; Tue, 27 Sep 2022 22:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Sep 2022 02:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58118 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58118-submit@debbugs.gnu.org id=B58118.16643329962677 (code B ref 58118); Wed, 28 Sep 2022 02:44:02 +0000 Original-Received: (at 58118) by debbugs.gnu.org; 28 Sep 2022 02:43:16 +0000 Original-Received: from localhost ([127.0.0.1]:57150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odN2Z-0000h7-Nr for submit@debbugs.gnu.org; Tue, 27 Sep 2022 22:43:16 -0400 Original-Received: from mail-pg1-f195.google.com ([209.85.215.195]:46035) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odN2W-0000gt-RP for 58118@debbugs.gnu.org; Tue, 27 Sep 2022 22:43:13 -0400 Original-Received: by mail-pg1-f195.google.com with SMTP id r62so7202348pgr.12 for <58118@debbugs.gnu.org>; Tue, 27 Sep 2022 19:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date; bh=Z8S7uwACd9zN1za3YLs7+75M5fRG1KqmE/B/N0qwXfg=; b=Smhpgbsrq0heT6XnsLBpPRKuvB9Sk144rQEgDlaOMWwXisvHAf3HTzaySFCbk3mF9P EoGrayQeCALohHX2DvloKR7DoRNPbjrVTg8Ae5trEXW+smaBfvFD+lEih3mW0z1MGPpS o37Ldb9JvFd2mzjGpi8zlBd2riCgyx+oECv2wVXU1RL3T4CZh91OhopTlqxsBrK0Qlev Y6Yr85BsiVZNSLf1NWjydMIINJdCC+6npDz2FB+2eM/DhqwvvwvWH8wzuuqJOazzrSxx DLOLOY8FDHZI5hR5It1rQzGscdhWdG3Ban0riPYg6HC+oBO+b5OsAayV/9RCpOAdK0Uf 2N0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date; bh=Z8S7uwACd9zN1za3YLs7+75M5fRG1KqmE/B/N0qwXfg=; b=Ge6kAEshM+NAf/NrhA867xMb/8KnAMULkl3QjKIZGYI2kuEdG9oB56JtrS3hS6QSjY 5sxdkgzuviEviEBJM+eKclTwiFZYdih+i4W65qSpbA9yRu6GwHB/EeXN/KzlKLaW44Xq WiWiMfuV2MZ7ly+G3CkCZplDiE6KyXoinD+zvgCDJ5HhrGVoIkBKzwfEU/BRLOKjdppX BRzefuG3SHzCMtsi9Uxu2DHp0ObL98hb0Sshx5aAhQW21nyHgNMi48bIrsIvfhHESZY7 p2/PknBlMQbVDgCZBpicC+x0Q6aSZfoso0QVlhC2DYyTIDS56z0juSl+C4vzLhsvQQ4k FWCg== X-Gm-Message-State: ACrzQf0uptKkrpZRskiMr8BL69zlVHgTUl8iqKkvY5UA8Y4+c8wuGMt2 LBAT+YWUaa9E9ogQnewFdmY= X-Google-Smtp-Source: AMsMyM4PGaSFjOUh2ifLuSpjw4ZLX41pqjV+13U8sWcFMkgY7jfsu29guUlzU5A4Mnwd6Mqdsc3EGQ== X-Received: by 2002:a05:6a00:190d:b0:550:6db3:b9be with SMTP id y13-20020a056a00190d00b005506db3b9bemr32571609pfi.1.1664332986866; Tue, 27 Sep 2022 19:43:06 -0700 (PDT) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a348100b001fabcd994c1sm270332pjb.9.2022.09.27.19.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 19:43:05 -0700 (PDT) In-Reply-To: <87v8p823c7.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 27 Sep 2022 18:23:52 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:243779 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=9A=E0=AF=86=E0=AE=B5=E0=AF=8D=E0=AE=B5=E0=AE=BE=E0=AE=AF=E0=AF=8D = =E0=AE=9A=E0=AF=86=E0=AE=AA=E0=AF=8D=E0=AE=9F=E0=AE=AE=E0=AF=8D=E0=AE=AA=E0= =AE=B0=E0=AF=8D 27, 2022] Lars Ingebrigtsen wrote: > Visuwesh writes: > >> eww-follow-link currently follows #target links in the same URL by >> re-rendering the page. Whilst this is fine for small HTML files, the >> 1.9M HTML file that I'm currently visiting takes a couple seconds to >> render. > > That's a regression, I think -- following #target links used to work > without re-rendering. (At least it did at one point.) That's what I seem to remember as well. >> I see that eww-display-html follows #target links by a text property >> search, why don't we do the same in eww-follow-link as well? I have one >> question though: what do we about non-existent #targets? Chrome and >> Firefox seem to not scroll when I add a non-existent #target to the >> current URL and say RET, and it seems to specially handle #top to mean >> to go to the top even if the HTML has no hits for "#top". Should we >> handle the special #top target? > > Sure, makes sense. Now done. >> + (setq match (text-property-search-forward 'shr-target-id target= #'member)) >> + (if match >> + (goto-char (prop-match-beginning match)) > > This is more conveniently expressed as > > (when-let ((text-property-search-forward 'shr-target-id target #'member)) > (goto-char (prop-match-beginning match))) Thanks. Revised patch attached, --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Follow-target-links-in-eww-without-re-rendering.patch >From 4b7280340de897137e1f4272219dddde292e5a4b Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Wed, 28 Sep 2022 08:11:42 +0530 Subject: [PATCH] Follow #target links in eww without re-rendering * lisp/net/eww.el (eww-follow-link): Do a text property search instead of re-rendering to follow #target links in the same page. (bug#58118) (eww-link-keymap): Bind to eww-follow-link as well. --- lisp/net/eww.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 61b1b75068..624958915a 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -315,7 +315,8 @@ eww-accept-content-types (defvar-keymap eww-link-keymap :parent shr-map - "RET" #'eww-follow-link) + "RET" #'eww-follow-link + "" #'eww-follow-link) (defvar-keymap eww-image-link-keymap :parent shr-map @@ -1901,7 +1902,8 @@ eww-follow-link eww-mode) (mouse-set-point mouse-event) (let* ((orig-url (get-text-property (point) 'shr-url)) - (url (eww--transform-url orig-url))) + (url (eww--transform-url orig-url)) + target) (cond ((not url) (message "No link under point")) @@ -1913,12 +1915,17 @@ eww-follow-link (funcall browse-url-secondary-browser-function url) (shr--blink-link)) ;; This is a #target url in the same page as the current one. - ((and (url-target (url-generic-parse-url url)) + ((and (setq target (url-target (url-generic-parse-url url))) (eww-same-page-p url (plist-get eww-data :url))) - (let ((dom (plist-get eww-data :dom))) + (let ((point (point))) (eww-save-history) (plist-put eww-data :url url) - (eww-display-html 'utf-8 url dom nil (current-buffer)))) + (goto-char (point-min)) + (if-let ((match (text-property-search-forward 'shr-target-id target #'member))) + (goto-char (prop-match-beginning match)) + (goto-char (if (equal target "top") + (point-min) + point))))) (t (eww-browse-url orig-url external))))) -- 2.35.1 --=-=-=--