all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
@ 2024-08-16 17:28 Sebastián Monía
  2024-08-16 17:48 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastián Monía @ 2024-08-16 17:28 UTC (permalink / raw)
  To: emacs-devel

---
Small quality of life change in EWW. I was interested in reverting the
buffer list, then I found the "FIXME" note about reverting in
eww-mode, and figured, why not :)

I didn't want to alter eww-reload (since it is part of the public API)
hence the new function for reverting that just calls it.

Thank you,
Seb

 lisp/net/eww.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index b2e1c5a72e5..c0ab8761997 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1193,7 +1193,6 @@ This consults the entries in `eww-readable-urls' (which see)."
           (throw 'found result))))))
 
 (defvar-keymap eww-mode-map
-  "g" #'eww-reload             ;FIXME: revert-buffer-function instead!
   "G" #'eww
   "M-RET" #'eww-open-in-new-buffer
   "TAB" #'shr-next-link
@@ -1331,6 +1330,7 @@ within text input fields."
   (add-hook 'context-menu-functions 'eww-context-menu 5 t)
   (setq-local eww-history nil)
   (setq-local eww-history-position 0)
+  (setq-local revert-buffer-function #'eww--revert-function)
   (when (boundp 'tool-bar-map)
     (setq-local tool-bar-map eww-tool-bar-map))
   ;; desktop support
@@ -1529,6 +1529,13 @@ just re-display the HTML already fetched."
             (eww-retrieve url #'eww-render
 		          (list url (point) (current-buffer) encode))))))))
 
+(defun eww--revert-function (local _noconfirm)
+  "Revert function for EWW buffers.
+LOCAL works like in `eww-reload': when non-nil, reload the page from the
+network instead of the HTML already retrieved. It is the prefix arg."
+  (eww-reload local)
+  (message "Page reloaded."))
+
 ;; Form support.
 
 (defvar eww-form nil)
@@ -2601,8 +2608,10 @@ see)."
 
 ;;; eww buffers list
 
-(defun eww-list-buffers ()
-  "Enlist eww buffers."
+(defun eww-list-buffers (&optional _ignore-auto _noconfirm)
+  "Pop a buffer with a list of eww buffers.
+Optional arguments make this function compatible with the
+`revert-buffer-function' interface."
   (interactive)
   (let (buffers-info
         (current (current-buffer)))
@@ -2621,6 +2630,7 @@ see)."
           (domain-length 0)
           (title-length 0)
           url title format start)
+      (setq-local revert-buffer-function #'eww-list-buffers)
       (erase-buffer)
       (dolist (buffer-info buffers-info)
         (setq title-length (max title-length
-- 
2.45.2.windows.1
-- 
Sebastián Monía
https://site.sebasmonia.com/



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-16 17:28 [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer Sebastián Monía
@ 2024-08-16 17:48 ` Eli Zaretskii
  2024-08-16 18:55   ` Sebastián Monía
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2024-08-16 17:48 UTC (permalink / raw)
  To: Sebastián Monía; +Cc: emacs-devel

> From: Sebastián Monía <sebastian@sebasmonia.com>
> Date: Fri, 16 Aug 2024 13:28:54 -0400
> 
> Small quality of life change in EWW. I was interested in reverting the
> buffer list, then I found the "FIXME" note about reverting in
> eww-mode, and figured, why not :)
> 
> I didn't want to alter eww-reload (since it is part of the public API)
> hence the new function for reverting that just calls it.

Is it really TRT to call eww-reload?  The FIXME says we need a real
revert-buffer-function, so I presume just calling eww-reload is
somehow not the best solution?

In any case, what is the improvement provided by this change?

Thanks.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-16 17:48 ` Eli Zaretskii
@ 2024-08-16 18:55   ` Sebastián Monía
  2024-08-17 12:35     ` Sebastián Monía
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastián Monía @ 2024-08-16 18:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

For reloading EWW buffers, I guess not much, except for using the
"standard" machinery to revert buffers. My first version changed
eww-reload instead, but then I realized someone might be already be
using that command.

The revert/reload for EWW buffer list is convenient. Without it, you get
a message that the buffer is not backed by a file.

I am fine keeping only buffer list change :)


>> From: Sebastián Monía <sebastian@sebasmonia.com>
>> Date: Fri, 16 Aug 2024 13:28:54 -0400
>> 
>> Small quality of life change in EWW. I was interested in reverting the
>> buffer list, then I found the "FIXME" note about reverting in
>> eww-mode, and figured, why not :)
>> 
>> I didn't want to alter eww-reload (since it is part of the public API)
>> hence the new function for reverting that just calls it.
>
> Is it really TRT to call eww-reload?  The FIXME says we need a real
> revert-buffer-function, so I presume just calling eww-reload is
> somehow not the best solution?
>
> In any case, what is the improvement provided by this change?
>
> Thanks.

-- 
Sebastián Monía
https://site.sebasmonia.com/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-16 18:55   ` Sebastián Monía
@ 2024-08-17 12:35     ` Sebastián Monía
  2024-08-24  8:42       ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastián Monía @ 2024-08-17 12:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Sebastián Monía <sebastian@sebasmonia.com> writes:

---
This smaller patch does only the eww buffer list portion, and we leave
EWW buffer reloads as they are now.

 lisp/net/eww.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index b2e1c5a72e5..660731faa30 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -2601,8 +2601,10 @@ see)."
 
 ;;; eww buffers list
 
-(defun eww-list-buffers ()
-  "Enlist eww buffers."
+(defun eww-list-buffers (&optional _ignore-auto _noconfirm)
+  "Pop a buffer with a list of eww buffers.
+Optional arguments make this function compatible with the
+`revert-buffer-function' interface."
   (interactive)
   (let (buffers-info
         (current (current-buffer)))
@@ -2719,6 +2721,7 @@ see)."
 \\{eww-buffers-mode-map}"
   :interactive nil
   (buffer-disable-undo)
+  (setq-local revert-buffer-function #'eww-list-buffers)
   (setq truncate-lines t))
 
 ;;; Desktop support
-- 
2.45.2.windows.1





-- 
Sebastián Monía
https://site.sebasmonia.com/



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-17 12:35     ` Sebastián Monía
@ 2024-08-24  8:42       ` Eli Zaretskii
  2024-08-24 17:27         ` Jim Porter
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2024-08-24  8:42 UTC (permalink / raw)
  To: Sebastián Monía, Jim Porter; +Cc: emacs-devel

> From: Sebastián Monía <sebastian@sebasmonia.com>
> Cc: emacs-devel@gnu.org
> Date: Sat, 17 Aug 2024 08:35:36 -0400
> 
> Sebastián Monía <sebastian@sebasmonia.com> writes:
> 
> ---
> This smaller patch does only the eww buffer list portion, and we leave
> EWW buffer reloads as they are now.
> 
>  lisp/net/eww.el | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lisp/net/eww.el b/lisp/net/eww.el
> index b2e1c5a72e5..660731faa30 100644
> --- a/lisp/net/eww.el
> +++ b/lisp/net/eww.el
> @@ -2601,8 +2601,10 @@ see)."
>  
>  ;;; eww buffers list
>  
> -(defun eww-list-buffers ()
> -  "Enlist eww buffers."
> +(defun eww-list-buffers (&optional _ignore-auto _noconfirm)
> +  "Pop a buffer with a list of eww buffers.
> +Optional arguments make this function compatible with the
> +`revert-buffer-function' interface."
>    (interactive)
>    (let (buffers-info
>          (current (current-buffer)))
> @@ -2719,6 +2721,7 @@ see)."
>  \\{eww-buffers-mode-map}"
>    :interactive nil
>    (buffer-disable-undo)
> +  (setq-local revert-buffer-function #'eww-list-buffers)
>    (setq truncate-lines t))
>  
>  ;;; Desktop support
> -- 
> 2.45.2.windows.1

Jim, would you please review this and provide comments, if any?

Thanks.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-24  8:42       ` Eli Zaretskii
@ 2024-08-24 17:27         ` Jim Porter
  2024-08-30 20:01           ` Sebastián Monía
  0 siblings, 1 reply; 12+ messages in thread
From: Jim Porter @ 2024-08-24 17:27 UTC (permalink / raw)
  To: Eli Zaretskii, Sebastián Monía; +Cc: emacs-devel

On 8/24/2024 1:42 AM, Eli Zaretskii wrote:
> Jim, would you please review this and provide comments, if any?

Hmm, it seems strange to me that this patch makes 'eww-list-buffers' be 
the 'revert-buffer-function'. That function contains some additional 
logic that I don't think belongs for reverting the buffer. For example, 
if I opened the EWW buffer list and then renamed the buffer, I'd expect 
'revert-buffer' to update the contents of that (now-renamed) buffer. 
 From reading the code, I think what would happen is that it pops to a 
*new* buffer with the original "*eww buffers*" name.

So I think we'd want some new function like 'eww--do-list-buffers' that 
takes the code from 'eww-list-buffers' that actually writes out the text 
(i.e. the 'let' form starting with '(inhibit-read-only t)'). Then have 
'eww-list-buffers' call that, and set 'revert-buffer-function' to 
'eww--do-list-buffers'. Or something like that anyway...



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-24 17:27         ` Jim Porter
@ 2024-08-30 20:01           ` Sebastián Monía
  2024-09-14  7:32             ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastián Monía @ 2024-08-30 20:01 UTC (permalink / raw)
  To: Jim Porter, Eli Zaretskii; +Cc: emacs-devel

Hi Jim,

Thanks for your review.

On Sat, Aug 24, 2024, at 1:27 PM, Jim Porter wrote:
> So I think we'd want some new function like 'eww--do-list-buffers' that 
> takes the code from 'eww-list-buffers' that actually writes out the text 
> (i.e. the 'let' form starting with '(inhibit-read-only t)'). Then have 
> 'eww-list-buffers' call that, and set 'revert-buffer-function' to 
> 'eww--do-list-buffers'. Or something like that anyway...

You are entirely correct, will provide an updated patch whenever I get a chance.
Thank you,
Seb



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-08-30 20:01           ` Sebastián Monía
@ 2024-09-14  7:32             ` Eli Zaretskii
       [not found]               ` <thqnjzf7s74l.fsf@sebasmonia.com>
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2024-09-14  7:32 UTC (permalink / raw)
  To: Sebastián Monía; +Cc: jporterbugs, emacs-devel

> Date: Fri, 30 Aug 2024 16:01:00 -0400
> From: Sebastián Monía <sebastian@sebasmonia.com>
> Cc: emacs-devel@gnu.org
> 
> Hi Jim,
> 
> Thanks for your review.
> 
> On Sat, Aug 24, 2024, at 1:27 PM, Jim Porter wrote:
> > So I think we'd want some new function like 'eww--do-list-buffers' that 
> > takes the code from 'eww-list-buffers' that actually writes out the text 
> > (i.e. the 'let' form starting with '(inhibit-read-only t)'). Then have 
> > 'eww-list-buffers' call that, and set 'revert-buffer-function' to 
> > 'eww--do-list-buffers'. Or something like that anyway...
> 
> You are entirely correct, will provide an updated patch whenever I get a chance.

Any progress there?



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
       [not found]               ` <thqnjzf7s74l.fsf@sebasmonia.com>
@ 2024-09-20  6:18                 ` Eli Zaretskii
  2024-09-20 15:06                   ` Sebastián Monía
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2024-09-20  6:18 UTC (permalink / raw)
  To: Sebastián Monía; +Cc: jporterbugs, emacs-devel

[Please use Reply All to reply, to CC everyone else and the list.]

Resending to the list:

> From: Sebastián Monía <sebastian@sebasmonia.com>
> Date: Thu, 19 Sep 2024 16:47:38 -0400
> 
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Any progress there?
> 
> Not really, but was looking at this for a bit now.
> 
> The way we collect the buffer list first, then print "No buffers"
> doesn't help in splitting the function.
> 
> There are many (hacky) ways to work around that, but I am thinking that
> maybe it would it be better to use tabulated-list-mode or vtable to
> display this?
> 
> I know, the change is more involved. But seems like a better path
> forward.
> 
> If you think that's overkill, then one possible hacky solution is:
> 
> 1. split the function in three: eww-list-buffers (command)
> eww--print-list-buffers (writes the buffer), eww--collect-list-buffers
> (gets the list of buffers and vectors with eww-data)
> 
> 2. setting a buffer-local variable with the EWW buffers info in
> eww-list-buffers.
> 
> 3. in eww--print-list-buffers, use the variable if present, discard the
> value after using it. Calls for reverting won't find a value and will
> call eww--collect-list-buffer. So the first time it re-uses data, and
> subsequent calls get it fresh.
> 
> Honestly, seems hacky and convoluted. That's why I thought, hey
> maybe this should be a tabulated-list instead. Or vtable.
> 
> -- 
> Sebastián Monía
> https://site.sebasmonia.com/
> 



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-09-20  6:18                 ` Eli Zaretskii
@ 2024-09-20 15:06                   ` Sebastián Monía
  2024-09-20 17:43                     ` Jim Porter
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastián Monía @ 2024-09-20 15:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jporterbugs, emacs-devel



Eli Zaretskii <eliz@gnu.org> writes:
> [Please use Reply All to reply, to CC everyone else and the list.]

This was a very silly mistake, thanks for resending.

> Resending to the list:

>> > Any progress there?
>> 
>> Not really, but was looking at this for a bit now.
>> 
>> The way we collect the buffer list first, then print "No buffers"
>> doesn't help in splitting the function.
>> 
>> There are many (hacky) ways to work around that, but I am thinking that
>> maybe it would it be better to use tabulated-list-mode or vtable to
>> display this?
>> 
>> I know, the change is more involved. But seems like a better path
>> forward.

@Jim

A simpler hacky solution that I thought of this morning. And it doesn't
modify the original code as much:

On top of my last patch, check if the current buffer is in
`eww-buffers-mode` then use it, if not, get-create "*eww buffers list*".
That would work even if the user renamed the buffer. And it is a very
simple change.

Do you think it is an acceptable solution?

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.

-- 
Sebastián Monía
https://site.sebasmonia.com/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-09-20 15:06                   ` Sebastián Monía
@ 2024-09-20 17:43                     ` Jim Porter
  2024-09-21  2:14                       ` Sebastián Monía
  0 siblings, 1 reply; 12+ messages in thread
From: Jim Porter @ 2024-09-20 17:43 UTC (permalink / raw)
  To: Sebastián Monía, Eli Zaretskii; +Cc: emacs-devel

On 9/20/2024 8:06 AM, Sebastián Monía 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.

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.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer
  2024-09-20 17:43                     ` Jim Porter
@ 2024-09-21  2:14                       ` Sebastián Monía
  0 siblings, 0 replies; 12+ messages in thread
From: Sebastián Monía @ 2024-09-21  2:14 UTC (permalink / raw)
  To: Jim Porter; +Cc: Eli Zaretskii, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

Jim Porter <jporterbugs@gmail.com> writes:

> On 9/20/2024 8:06 AM, Sebastián Monía 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Derive-eww-buffers-mode-from-tabulated-list-adjust-c.patch --]
[-- Type: text/x-patch, Size: 5558 bytes --]

From 5fc0308ea6569ab5bc06db45ac1e7f7590c90c42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Mon=C3=ADa?= <sebastian@sebasmonia.com>
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


[-- Attachment #3: Type: text/plain, Size: 54 bytes --]


-- 
Sebastián Monía
https://site.sebasmonia.com/

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-09-21  2:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-16 17:28 [PATCH] EWW - use revert--buffer-function to reload, and allow reload in eww-list-buffer Sebastián Monía
2024-08-16 17:48 ` Eli Zaretskii
2024-08-16 18:55   ` Sebastián Monía
2024-08-17 12:35     ` Sebastián Monía
2024-08-24  8:42       ` Eli Zaretskii
2024-08-24 17:27         ` Jim Porter
2024-08-30 20:01           ` Sebastián Monía
2024-09-14  7:32             ` Eli Zaretskii
     [not found]               ` <thqnjzf7s74l.fsf@sebasmonia.com>
2024-09-20  6:18                 ` Eli Zaretskii
2024-09-20 15:06                   ` Sebastián Monía
2024-09-20 17:43                     ` Jim Porter
2024-09-21  2:14                       ` Sebastián Monía

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.