From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Sebasti=C3=A1n_Mon=C3=ADa?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer Date: Sun, 13 Oct 2024 21:06:46 -0400 Message-ID: <87v7xvh4rd.fsf@sebasmonia.com> References: <86y12tycdy.fsf@gnu.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="21714"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: adam@alphapapa.net, jporterbugs@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 14 03:07:39 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 1t09Yf-0005V8-Re for ged-emacs-devel@m.gmane-mx.org; Mon, 14 Oct 2024 03:07:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t09Xz-00078v-Fw; Sun, 13 Oct 2024 21:06:55 -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 1t09Xw-00078c-83 for emacs-devel@gnu.org; Sun, 13 Oct 2024 21:06:52 -0400 Original-Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t09Xu-0008MY-3i; Sun, 13 Oct 2024 21:06:51 -0400 Original-Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 9187911400BC; Sun, 13 Oct 2024 21:06:47 -0400 (EDT) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 13 Oct 2024 21:06:47 -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=1728868007; x= 1728954407; bh=hWiybGCULeyNc4g6QrDTRjeyHJh+dFoyak0xqeMEN1I=; b=L ZvOeRSvi3bPlH4ueYAoO1x952kJYtnRUfi+7RgNJsTqxseAqfWJPohzkRIt9tan0 TlJGaPcte+lttM1dotXHAHcLBW0OP3EjWVYnsOpG0pg7Z3ash7RmaI/CJkxv1uRn eLsJCF0utb3IHLD+0IwYqyULanvCLs560NQYp2e4shGypjGyOy4xCq7qoeVHhL5g 87KyqARQeLXZuUPrF8Kze15BkhStPD1OJpZ7BiZ8YhGS0po59d8InySiTkXSEZQA dgiP6kMJmi6c5hkrlO/cPU8flOixmkCfaZm/AHoMZ2xK+ysA0gUS48dXpsRz9/yy 5btkfIe9T4uJHIFypWWXA== 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=1728868007; x=1728954407; bh=hWiybGCULeyNc4g6QrDTRjeyHJh+ dFoyak0xqeMEN1I=; b=FD9bStuHgiP+NbVjEGGJaUWGybYV2EYZ7eyj7eeA0Ql+ z0/sS2etkzFifMro+Fh62kz+fLVCm4JFQ5tQXzyREXUmkyrqUOPAaJjIewQuIW9c 1RLNmR170OxcDZrk5N6xU8fCtSVdCOzebBLln4HPnz3Gg2TBAVmup/i1tWhBVefT tvoMlq3cB71D5AqewfnP2remiDI1HPmRkGleV5wtVUmWbFW9yA0fYwMgMoQNnJJS KWAReiBzUIg4xwR9vXsl8+zSeSXMOnhqG4922gdC/cfhuOZWUj9JyVdEd2dlb1bM b+7sjQuPwC1jkdsCG/MZVvtJWpc+8bVRFAlFm/0N+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdeggedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefujghffffkfgggtgesmhdtreertderjeen ucfhrhhomhepufgvsggrshhtihojnhcuofhonhovrgcuoehsvggsrghsthhirghnsehsvg gsrghsmhhonhhirgdrtghomheqnecuggftrfgrthhtvghrnhepheekvdeufffgleeuvdeu tefhjeettedufeffleehjeeguefggfetteefvddvkeetnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepshgvsggrshhtihgrnhesshgvsggrshhm ohhnihgrrdgtohhmpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprh gtphhtthhopegvmhgrtghsqdguvghvvghlsehgnhhurdhorhhgpdhrtghpthhtohepjhhp ohhrthgvrhgsuhhgshesghhmrghilhdrtghomhdprhgtphhtthhopegruggrmhesrghlph hhrghprghprgdrnhgvthdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: iab2c46da:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 13 Oct 2024 21:06:46 -0400 (EDT) In-Reply-To: <86y12tycdy.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 12 Oct 2024 11:05:29 +0300") Received-SPF: pass client-ip=103.168.172.152; envelope-from=sebastian@sebasmonia.com; helo=fhigh-a1-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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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:324551 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > I didn't yet have time to read your discussion and make up my mind. I > was waiting for you to reach some agreement, but it seems you are > still discussing the various aspects? I was wondering if there was an official project stance on using vtable or tabulated-list. Like there's a preference for seq vs cl-lib (where both apply) for example. > Are there any downsides to using vtable? None that I know of, and as Adam suggested, vtables are sometimes easier to handle. It doesn't make much of a difference in this case, though, the table is pretty simple. Attached a new patch that used vtable, and also adds the (eww-buffer-list) function that Jim mentioned before. Once this one is merged (after review & corrections :) etc.) I can take the same vtable approach for eww-bookmarks. Thank you, Seb --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-vtable-in-eww-list-buffers-add-function-eww-buff.patch Content-Description: eww-list-buffers and eww-buffer-list >From bb090996db7eb7d819b7d28e3dd1a97d6bccc959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Mon=C3=ADa?= Date: Sun, 13 Oct 2024 21:00:03 -0400 Subject: [PATCH] Use vtable in eww-list-buffers, add function eww-buffer-list --- lisp/net/eww.el | 96 +++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index b5d2f20781a..b0467500ef3 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -33,6 +33,7 @@ (require 'url) (require 'url-queue) (require 'url-file) +(require 'vtable) (require 'xdg) (eval-when-compile (require 'subr-x)) @@ -2604,58 +2605,50 @@ eww-history-mode ;;; eww buffers list +(defun eww-buffer-list () + "Return a list of all live eww buffers." + (seq-filter (lambda (buf) + (with-current-buffer buf + (derived-mode-p 'eww-mode))) + (buffer-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*")) + (with-current-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))))) + (eww--list-buffers-display-table)) (pop-to-buffer "*eww buffers*")) +(defun eww--list-buffers-display-table (&optional ignore-auto noconfirm) + "Display a table with the list of eww buffers. +Will remove all buffer contents first. The parameters IGNORE-AUTO and +NOCONFIRM are ignored, they are for compatibility with +`revert-buffer-function'." + (let ((inhibit-read-only t)) + (erase-buffer) + (make-vtable + :columns '((:name "Title" :width 30) + (:name "URL")) + :objects-function #'eww--list-buffers-get-data + ;; use fixed-font face + :face 'default))) + +(defun eww--list-buffers-get-data () + "Return the eww-data of BUF, assumed to be a eww buffer. +The format of the data is (title url buffer), for use in of +`eww-buffers-mode'." + (mapcar (lambda (buf) + (with-current-buffer buf + (list (plist-get eww-data :title) + (plist-get eww-data :url) + buf))) + (eww-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 (nth 2 (vtable-current-object)))) (unless buffer (error "No buffer on current line")) (quit-window) @@ -2663,8 +2656,7 @@ eww-buffer-select (defun eww-buffer-show () "Display buffer under point in eww buffer list." - (let ((buffer (get-text-property (line-beginning-position) - 'eww-buffer))) + (let ((buffer (nth 2 (vtable-current-object)))) (unless buffer (error "No buffer on current line")) (other-window -1) @@ -2692,7 +2684,7 @@ 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)) + (buffer (nth 2 (vtable-current-object))) (inhibit-read-only t)) (unless buffer (user-error "No buffer on the current line")) @@ -2711,10 +2703,9 @@ eww-buffers-mode-map :menu '("Eww Buffers" ["Exit" quit-window t] ["Select" eww-buffer-select - :active (get-text-property (line-beginning-position) 'eww-buffer)] + :active (nth 2 (vtable-current-object))] ["Kill" eww-buffer-kill - :active (get-text-property (line-beginning-position) - 'eww-buffer)])) + :active (nth 2 (vtable-current-object))])) (define-derived-mode eww-buffers-mode special-mode "eww buffers" "Mode for listing buffers. @@ -2722,7 +2713,10 @@ eww-buffers-mode \\{eww-buffers-mode-map}" :interactive nil (buffer-disable-undo) - (setq truncate-lines t)) + (setq truncate-lines t + ;; this is set so that pressing "g" with point just below the + ;; table will still update the listing + revert-buffer-function #'eww--list-buffers-display-table)) ;;; Desktop support -- 2.43.0 --=-=-=--