unofficial mirror of emacs-devel@gnu.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; 8+ 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] 8+ messages in thread

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

Thread overview: 8+ 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).