Subject: Re: bug#51176: eww switch buffer by title

From: Protesilaos Stavrou <[email-masked]>
Date: Mon, 18 Oct 2021 10:15:11 +0300

On 2021-10-18, 08:43 +0200, Lars Ingebrigtsen <[email-masked]> wrote:

> Protesilaos Stavrou <[email-masked]> writes:
>
>> How about we add a sample function in the doc string?  That would give
>> users all the information they need to get started, no?
>
> Makes sense to me.

Patch attached.  I only updated the doc string, thinking that this
addition does not need to be added to the NEWS.

-- 
Protesilaos Stavrou
https://protesilaos.com
>From 85762fa3b88410675cbf89854f3a1c29bbac7a9d Mon Sep 17 00:00:00 2001
Message-Id: <[email-masked]>
From: Protesilaos Stavrou <[email-masked]>
Date: Mon, 18 Oct 2021 10:07:03 +0300
Subject: [PATCH] Add sample user function in eww-auto-rename-buffer

* eww.el (eww-auto-rename-buffer): Update doc string.

Fix bug#51176.

Co-authored-by: Abhiseck Paira <[email-masked]>
Co-authored-by: Protesilaos Stavrou <[email-masked]>
---
 lisp/net/eww.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index bed458ed8a..178a25e4be 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -187,7 +187,14 @@ (defcustom eww-auto-rename-buffer nil
 - `title': Use the web page's title.
 - `url': Use the web page's URL.
 - a function's symbol: Run a user-defined function that returns a
-  string with which to rename the buffer.
+  string with which to rename the buffer.  Sample of a
+  user-defined function:
+
+  (defun my-eww-rename-buffer ()
+    (when (eq major-mode 'eww-mode)
+      (when-let ((string (or (plist-get eww-data :title)
+                             (plist-get eww-data :url))))
+        (format \"*%s*\" string))))
 
 The string of `title' and `url' is always truncated to the value
 of `eww-buffer-name-length'."
-- 
2.33.1