From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?iso-8859-1?Q?Sebasti=E1n_Mon=EDa?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer Date: Fri, 20 Sep 2024 22:14:49 -0400 Message-ID: References: <86jzgg5pgv.fsf@gnu.org> <86frqunwgu.fsf@gnu.org> <8d5956f2-545d-470d-8f61-59670570b868@app.fastmail.com> <86ikuyitc1.fsf@gnu.org> <86v7yq7sq9.fsf@gnu.org> <30fbc38f-2b86-55c2-a4f3-6c924d82aed8@gmail.com> 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="31897"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 21 04:15:38 2024 Return-path: Envelope-to: ged-emacs-devel@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 1srper-00088e-Bj for ged-emacs-devel@m.gmane-mx.org; Sat, 21 Sep 2024 04:15:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1srpeF-0000W4-Ht; Fri, 20 Sep 2024 22:14:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1srpeC-0000Vl-Rz for emacs-devel@gnu.org; Fri, 20 Sep 2024 22:14:57 -0400 Original-Received: from fout1-smtp.messagingengine.com ([103.168.172.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1srpeA-0007oq-KA; Fri, 20 Sep 2024 22:14:56 -0400 Original-Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 459851380265; Fri, 20 Sep 2024 22:14:51 -0400 (EDT) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 20 Sep 2024 22:14:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sebasmonia.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1726884891; x= 1726971291; bh=9javAkzKKyltxpXtCBZj5k24Z4Dug24ZgGdqi/WLuz4=; b=c zh8AzoL8qaJvOzW8LjD0ntTnFk9N9/Wa6z2HOo1eWlK1oRibuU5E/ul71UPb3U5y wp9cvvCng/924egDWyIjRJ8tNqZh9mAqgwj7zDUSIu1whwnxYOPC+E/9VWW0kYFH dhyXgpRZIePT4VrFtaF6YQfXVYHn7m1Z9bp70WDOIviG/LcozlL+PLE42US1eOkc wB0BheEfVeBJRIRJmxVtSqSnx4cbbQzOWTOex+LUGlG3OiTppMcSei8srcnuacaC EtJxpuNCf5hoNASd60qrBx6oRYdH/dsStz91SxUCptSp3x6FXkxR3ZbK0H1UHGVN bv/hEL7YWh3K2K5ZLtn1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1726884891; x=1726971291; bh=9javAkzKKyltxpXtCBZj5k24Z4Du g24ZgGdqi/WLuz4=; b=FhinUfGxn3cHEhMs/W6nQ9JqJ7n2lJN5eYjawH7ngO+i GrYM14Cxq741Qw1cqMsA6EVu4t8PeEiPA++4+S/hokKgxm30TmqLA+z2wJ7NN6p8 CSrgRy/19zyjQAiLW3+wNyIgeUp89/GZXQIrJSX2duhQrZv2sq6YVNJDoDdl1wrt s9wguB4lZtU4fhTx/69YQM476licE4wI0QC+qthCQtqGFBG3tKu0YJpQ6BjkXxTF i/Hh/5RS6T0WqyV34rIbWvbu99zggDqN2DRq529INn5iHQ+V42qwrSre+hkJNpH0 AwHCfwXu33ymjhFGposPpPGc1ovl9m399In+VL7mbA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudelgedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefujghffffkfgggtgesmhdtreertderuden ucfhrhhomhepufgvsggrshhtihojnhcuofhonhovrgcuoehsvggsrghsthhirghnsehsvg gsrghsmhhonhhirgdrtghomheqnecuggftrfgrthhtvghrnhephfffueekjedtgeelvdeh tdfggefgtdefhfetkeejffeutdegieeggedtkeeiveeunecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepshgvsggrshhtihgrnhesshgvsggrshhm ohhnihgrrdgtohhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprh gtphhtthhopegvmhgrtghsqdguvghvvghlsehgnhhurdhorhhgpdhrtghpthhtohepvghl ihiisehgnhhurdhorhhgpdhrtghpthhtohepjhhpohhrthgvrhgsuhhgshesghhmrghilh drtghomh X-ME-Proxy: Feedback-ID: iab2c46da:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Sep 2024 22:14:50 -0400 (EDT) In-Reply-To: <30fbc38f-2b86-55c2-a4f3-6c924d82aed8@gmail.com> (Jim Porter's message of "Fri, 20 Sep 2024 10:43:03 -0700") Received-SPF: pass client-ip=103.168.172.144; envelope-from=sebastian@sebasmonia.com; helo=fout1-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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:323874 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Jim Porter writes: > On 9/20/2024 8:06 AM, Sebasti=E1n Mon=EDa wrote: >> If not, I will convert it to tabulated-list (or vtable), only >> disadvantage I see, is that it would change the internals of the buffer >> list quite a bit. I don't expect anyone to rely on them, though. > > I think a tabulated list would be fine. I included below a patch that does this > Your other earlier suggestion of splitting 'eww-list-buffers' in three > also makes sense to me though. Then one of the functions could be > 'eww-buffer-list' (which returns a list of EWW buffers), just like how > we have 'buffer-list' and 'list-buffers' in Emacs. I read this just now :( I can add it in a subsequent patch. BTW, 'eww-bookmark-mode' could also use a tabulated list. I use the eww specific bookmarks or some pages (and "general" bookmarks for others, everyone has their workflows I guess). If you all think it is worth it, I can make a similar change to this one for bookmarks. And add 'eww-list-buffers' too. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Derive-eww-buffers-mode-from-tabulated-list-adjust-c.patch Content-Description: 0001-Derive-eww-buffers-mode-from-tabulated-list-adjust-c.patch >From 5fc0308ea6569ab5bc06db45ac1e7f7590c90c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Mon=C3=ADa?= Date: Fri, 20 Sep 2024 21:52:05 -0400 Subject: [PATCH] Derive eww-buffers-mode from tabulated-list, adjust command eww-list-buffers to use it --- lisp/net/eww.el | 95 +++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 63 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index b5d2f20781a..a651d9d5020 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2605,57 +2605,31 @@ see)." ;;; eww buffers list (defun eww-list-buffers () - "Enlist eww buffers." + "Pop a buffer with a list of eww buffers." (interactive) - (let (buffers-info - (current (current-buffer))) - (dolist (buffer (buffer-list)) - (with-current-buffer buffer - (when (derived-mode-p 'eww-mode) - (push (vector buffer (plist-get eww-data :title) - (plist-get eww-data :url)) - buffers-info)))) - (unless buffers-info - (error "No eww buffers")) - (setq buffers-info (nreverse buffers-info)) ;more recent on top - (set-buffer (get-buffer-create "*eww buffers*")) - (eww-buffers-mode) - (let ((inhibit-read-only t) - (domain-length 0) - (title-length 0) - url title format start) - (erase-buffer) - (dolist (buffer-info buffers-info) - (setq title-length (max title-length - (length (elt buffer-info 1))) - domain-length (max domain-length - (length (elt buffer-info 2))))) - (setq format (format "%%-%ds %%-%ds" title-length domain-length) - header-line-format - (concat " " (format format "Title" "URL"))) - (let ((line 0) - (current-buffer-line 1)) - (dolist (buffer-info buffers-info) - (setq start (point) - title (elt buffer-info 1) - url (elt buffer-info 2) - line (1+ line)) - (insert (format format title url)) - (insert "\n") - (let ((buffer (elt buffer-info 0))) - (put-text-property start (1+ start) 'eww-buffer - buffer) - (when (eq current buffer) - (setq current-buffer-line line)))) - (goto-char (point-min)) - (forward-line (1- current-buffer-line))))) + (with-current-buffer (get-buffer-create "*eww buffers*") + (eww-buffers-mode)) (pop-to-buffer "*eww buffers*")) +(defun eww--list-buffers-get-eww-data (buf) + "Return the eww-data of BUF, if its major mode is eww. +The format (buffer [title url]) is for use in of `eww-buffers-mode'. +If BUF has another mode, return nil." + (with-current-buffer buf + (when (derived-mode-p 'eww-mode) + (list buf + (vector + (plist-get eww-data :title) + (plist-get eww-data :url)))))) + +(defun eww--list-buffers-collect () + "Update the eww buffers list displayed in this buffer." + (delq nil (mapcar #'eww--list-buffers-get-eww-data (buffer-list)))) + (defun eww-buffer-select () "Switch to eww buffer." (interactive nil eww-buffers-mode) - (let ((buffer (get-text-property (line-beginning-position) - 'eww-buffer))) + (let ((buffer (tabulated-list-get-id))) (unless buffer (error "No buffer on current line")) (quit-window) @@ -2663,8 +2637,7 @@ see)." (defun eww-buffer-show () "Display buffer under point in eww buffer list." - (let ((buffer (get-text-property (line-beginning-position) - 'eww-buffer))) + (let ((buffer (tabulated-list-get-id))) (unless buffer (error "No buffer on current line")) (other-window -1) @@ -2691,17 +2664,11 @@ see)." (defun eww-buffer-kill () "Kill buffer from eww list." (interactive nil eww-buffers-mode) - (let* ((start (line-beginning-position)) - (buffer (get-text-property start 'eww-buffer)) - (inhibit-read-only t)) + (let ((buffer (tabulated-list-get-id))) (unless buffer (user-error "No buffer on the current line")) (kill-buffer buffer) - (forward-line 1) - (delete-region start (point))) - (when (eobp) - (forward-line -1)) - (eww-buffer-show)) + (revert-buffer))) (defvar-keymap eww-buffers-mode-map "C-k" #'eww-buffer-kill @@ -2709,20 +2676,22 @@ see)." "n" #'eww-buffer-show-next "p" #'eww-buffer-show-previous :menu '("Eww Buffers" - ["Exit" quit-window t] ["Select" eww-buffer-select - :active (get-text-property (line-beginning-position) 'eww-buffer)] + :active (tabulated-list-get-id)] ["Kill" eww-buffer-kill - :active (get-text-property (line-beginning-position) - 'eww-buffer)])) + :active (tabulated-list-get-id)] + ["Exit" quit-window])) -(define-derived-mode eww-buffers-mode special-mode "eww buffers" +(define-derived-mode eww-buffers-mode tabulated-list-mode "eww buffers" "Mode for listing buffers. - \\{eww-buffers-mode-map}" :interactive nil - (buffer-disable-undo) - (setq truncate-lines t)) + (setq tabulated-list-format [("Title" 30 t) + ("URL" 0 t)]) + (setq tabulated-list-padding 1 + tabulated-list-entries #'eww--list-buffers-collect) + (tabulated-list-init-header) + (tabulated-list-print)) ;;; Desktop support -- 2.45.2.windows.1 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable --=20 Sebasti=E1n Mon=EDa https://site.sebasmonia.com/ --=-=-=--