From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuchen Pei Newsgroups: gmane.emacs.bugs Subject: bug#50497: [PATCH] Adding eww-{next,previous,up,top}-path. Date: Fri, 10 Sep 2021 13:05:45 +1000 Message-ID: <87lf45xh86.fsf@ypei.me> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="======-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7737"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.4.13; emacs 27.2 To: 50497@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 10 05:06:12 2021 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 1mOWrj-0001ln-WA for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Sep 2021 05:06:12 +0200 Original-Received: from localhost ([::1]:40562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOWri-00024x-6R for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Sep 2021 23:06:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOWrb-00024a-6w for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 23:06:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOWra-0003rD-W7 for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 23:06:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOWra-0004ZZ-MU for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 23:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuchen Pei Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Sep 2021 03:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.163124315717563 (code B ref -1); Fri, 10 Sep 2021 03:06:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Sep 2021 03:05:57 +0000 Original-Received: from localhost ([127.0.0.1]:36566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOWrU-0004ZC-JR for submit@debbugs.gnu.org; Thu, 09 Sep 2021 23:05:56 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOWrT-0004Z4-48 for submit@debbugs.gnu.org; Thu, 09 Sep 2021 23:05:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOWrS-00024T-VT for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 23:05:54 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:38495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOWrR-0003jN-4B for bug-gnu-emacs@gnu.org; Thu, 09 Sep 2021 23:05:54 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 372175C010A for ; Thu, 9 Sep 2021 23:05:52 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 09 Sep 2021 23:05:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ypei.me; h=from :to:subject:date:message-id:mime-version:content-type; s=fm2; bh=Zv4VJI6RUB8gj1sN4/7WXdqiFkp7Zu3f9YLwE3jsT2g=; b=cHR1wq9/XewQ zadIZtIBHaaJ8qRpUVZ59eO+O0kbQEsS3mYR2HwPMuKzCn9RffMzKBZ6h1r+aWDm Vkyhz9m6sgmv9+YwQdwrUxdsFW+0v9ZWw2Elaexumscuyt9XZkv/GoFr21nBf1VD F6ajYvGgO849i+hadswOkmzMHn2AdajtAcONS9xZhNZLdH+Nt1fFCEpCOq98NYkc //ZdWINJ+IlOkhXY1H7170sSN/fylEkZGS+Oj6nxiyFD9effKWRp6IMUyeTx1Hzq SxBMJVHCCrYgJLqg+NxBJLC0uXxqhIAhxwVzt44wWxLvdVR9JdbzCqGujCYWocAR cVVXwHf3Ug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=Zv4VJI6RUB8gj1sN4/7WXdqiFkp7Z u3f9YLwE3jsT2g=; b=DYO0RQRGoGYWBj+anq8N0RRMKOo+CqGyIreHlm1YZgU1k QGpanCtut/nmYJrrx+eA9Wnb7Rii3EQgwHzNOfQ6SkwlhJcuvxlBZn/nZIHCp20b CTt62cO2hwcXgIqQJJPLH73IL3kez9GtbOuH1O5x6VnaHUStYkpg+pA9kX+vQaff s2qit6U5FwXwMTOudXV9/rPr60qSjsBXuRfwzSwUa8JS0ubOk/+vezr5hWnRO6co Wnnn+jU8XgXzlFTtkAGwzFID+oqdlAJFzBUOEqwjWVi8U/fYTf2cqHvjv5LxADBy +LS3XM4JT4HbRmcjhTJygyNDxgsyzi5hmlcVgX3+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegtddgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegfhffvufffkfggtgesghdtreertd ertdenucfhrhhomhepjghutghhvghnucfrvghiuceohhhiseihphgvihdrmhgvqeenucgg tffrrghtthgvrhhnpeetvdfgieefheekheekkeduieeflefhtdfhveeiieevleeviefhve ejteeuffetieenucffohhmrghinheplhhisghrvghplhgrnhgvthdrohhrghenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhiheshihpvghird hmvg X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 9 Sep 2021 23:05:50 -0400 (EDT) Received-SPF: pass client-ip=66.111.4.27; envelope-from=hi@ypei.me; helo=out3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:213956 Archived-At: --======-=-= Content-Type: multipart/mixed; boundary="=====-=-=" --=====-=-= Content-Type: text/plain; format=flowed I often find myself wanting to navigate paginated web pages (e.g. ), or to go up or all the way up when visiting a web page, which is why I added these functions to my eww. Does this change make sense? If so I will amend the patch to include tests, doc and bug number. Note that there seem to be currently no tests for eww, so I will need to create a new file. BTW a newbie question: CONTRIBUTE mentions the commit message should include bug number, but when I send a patch like this a bug number is only generated afterwards. Does this mean I should report a bug, wait for the item to be created in debbugs, before sending a patch for the bug? Thanks. --=====-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-eww-next-previous-up-top-path.patch Content-Transfer-Encoding: quoted-printable From=208abc291f6fb9bd85c51fd1b0b7f6dce044b231a5 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 10 Sep 2021 12:41:49 +1000 Subject: [PATCH] Add eww-{next,previous,up,top}-path. Similar to eww-{next,previous,up,top}-url, but working based on the url path rather than the rel attribute. * lisp/net/eww.el (eww-next-path, eww-previous-path, eww-up-path, eww-top-path). * doc/misc/eww.texi TODO. * test/lisp/net/eww-tests.el TODO. =2D-- lisp/net/eww.el | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 90301e92ac..ded01f97e8 100644 =2D-- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -974,6 +974,10 @@ eww-mode-map (define-key map "p" 'eww-previous-url) (define-key map "u" 'eww-up-url) (define-key map "t" 'eww-top-url) + (define-key map "N" 'eww-next-path) + (define-key map "P" 'eww-previous-path) + (define-key map "U" 'eww-up-path) + (define-key map "T" 'eww-top-path) (define-key map "&" 'eww-browse-with-external-browser) (define-key map "d" 'eww-download) (define-key map "w" 'eww-copy-page-url) @@ -1194,6 +1198,50 @@ eww-top-url (eww-browse-url (shr-expand-url best-url (plist-get eww-data :url))) (user-error "No `top' for this page")))) =20 +(defun eww-next-path () + "Go to the `next' page according to the url path. +The url of the `next' page is generated by incrementing the last +number in the path." + (interactive) + (let ((url (plist-get eww-data :url))) + (when (string-match "^\\(.*?\\)\\([0-9]+\\)\\(.*\\)$" url) + (eww (concat + (match-string 1 url) + (number-to-string + (1+ (string-to-number (match-string 2 url)))) + (match-string 3 url)))))) + +(defun eww-previous-path () + "Go to the `previous' page according to the url path. +The url of the `previous' page is generated by decrementing the +last integer in the path." + (interactive) + (let ((url (plist-get eww-data :url))) + (when (string-match "^\\(.*\\)\\([0-9]+\\)\\(.*\\)$" url) + (eww (concat + (match-string 1 url) + (number-to-string + (1- (string-to-number (match-string 2 url)))) + (match-string 3 url)))))) + +(defun eww-up-path () + "Go to the `parent' page according to the url path. +The url of the `parent' page is generated by removing the last +segment delimited by a forward slash." + (interactive) + (let ((url (plist-get eww-data :url))) + (when (and (string-match "^\\(.*//.*/\\)[^/]+\\(/\\)?$" url) + (match-string 1 url)) + (eww (match-string 1 url))))) + +(defun eww-top-path () + "Go to the domain." + (interactive) + (let ((url (plist-get eww-data :url))) + (when (and (string-match "^\\(.*//.*?/\\).*$" url) + (match-string 1 url)) + (eww (match-string 1 url))))) + (defun eww-reload (&optional local encode) "Reload the current page. If LOCAL is non-nil (interactively, the command was invoked with =2D-=20 2.33.0 --=====-=-= Content-Type: text/plain; format=flowed -- Best, Yuchen PGP Key: 47F9 D050 1E11 8879 9040 4941 2126 7E93 EF86 DFD0 --=====-=-=-- --======-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIEEARYIACkWIQRH+dBQHhGIeZBASUEhJn6T74bf0AUCYTrLigscaGlAeXBlaS5t ZQAKCRAhJn6T74bf0BH1AP9+ptTX5WZpHdBwirY1rKZwl2Hp3EqhuECiNUeLdXe0 egD+Joi7xds0+gWEKWClwEjxAGKyWIlrE4UMrFoNxf2pcQs= =j3LK -----END PGP SIGNATURE----- --======-=-=--