Subject: bug#41385: [PATCH] Show eww bookmarks buffer only if it's not empty

From: Stefan Kangas <[email-masked]>
Date: Mon, 18 May 2020 17:51:06 -0700

Severity: minor
X-Debbugs-CC: [email-masked]

Please see the attached patch which fixes a minor annoyance with
eww-list-bookmarks.

Best regards,
Stefan Kangas
From ff5c8120955a8c0a23cafe5e0cb6821dc154f72a Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Tue, 19 May 2020 02:43:16 +0200
Subject: [PATCH] Show eww bookmarks buffer only if it's not empty

* lisp/net/eww.el (eww-list-bookmarks): Don't show buffer if there
are no bookmarks.
---
 lisp/net/eww.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index a6c1abdbb1..f24ada6287 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1754,8 +1754,13 @@ eww-read-bookmarks
 (defun eww-list-bookmarks ()
   "Display the bookmarks."
   (interactive)
-  (pop-to-buffer "*eww bookmarks*")
-  (eww-bookmark-prepare))
+  (let ((buf (get-buffer-create "*eww bookmarks*")) no-error)
+    (unwind-protect
+        (progn
+          (pop-to-buffer buf)
+          (eww-bookmark-prepare)
+          (setq no-error t))
+      (when (not no-error) (kill-buffer buf)))))
 
 (defun eww-bookmark-prepare ()
   (eww-read-bookmarks)
-- 
2.26.2