GNU bug report logs -
#51176
eww switch buffer by title
Previous Next
Reported by: Yuchen Pei <hi <at> ypei.me>
Date: Wed, 13 Oct 2021 04:57:02 UTC
Severity: normal
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 2021-10-16, 07:16 +0300, Protesilaos Stavrou <info <at> protesilaos.com> wrote:
> On 2021-10-15, 20:59 +0100, Jose Antonio Ortega Ruiz <jao <at> gnu.org> wrote:
>
>> On Fri, Oct 15 2021, Lars Ingebrigtsen wrote:
>>
>>> Jose Antonio Ortega Ruiz <jao <at> gnu.org> writes:
>>>
>>>> Since you went for the complex config, and additional option i'd find
>>>> useful for the ewww rename "flag" would be a string that specifies the
>>>> format to use once the title/url part has been computed. So one can set
>>>> it to, say, "eww: %s", or whatever. I know that that use case is already
>>>> covered by the possibility of specifying a function, but having to
>>>> duplicate the default function just to change the final format string
>>>> feels a bit overkill (and i suspect changing the format is going to be a
>>>> very common reason to opt for a function call).
>>>
>>> I think it's best to leave that sort of flexibility to the function
>>> option -- there's too many ways users may want to customise this.
>>
>> but, 43.45% of users will simply want to change the format and get rid
>> of "# eww" at the end to see more of the title! :)
>>
>> specifying a format string is extremely common in many packages out
>> there for things like this, and is, in my opinion, much more
>> user-friendly: to change that format with a function, one has to study
>> eww's api for obtaining title and url, and write a non-trivial piece of
>> elisp, probably (although admittedly not necessarily) outside the
>> customization interface.
>>
>> in other words, i find the format string option as natural and common as
>> the nil and t ones (which, in a way, are also redundant and could be
>> removed, since it's trivial to write a function for them).
>>
>> but i'm probably exaggerating: people will simply copy and paste the
>> relevant piece of elisp in their init files and call it a day. so i'll
>> stop the bike-shedding now :)
>
> How about we add a sample function in the doc string? That would give
> users all the information they need to get started, no?
Sorry, I sent the wrong version... I meant this 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))))
And we edit this doc string:
(defcustom eww-auto-rename-buffer nil
"Automatically rename EWW buffers once the page is rendered.
When nil, do not rename the buffer. With a non-nil value
determine the renaming scheme, as follows:
- `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. 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'."
:version "29.1"
:type '(choice
(const :tag "Do not rename buffers (default)" nil)
(const :tag "Rename buffer to web page title" title)
(const :tag "Rename buffer to web page URL" url)
(function :tag "A user-defined function to rename the buffer"))
:group 'eww)
--
Protesilaos Stavrou
https://protesilaos.com
This bug report was last modified 3 years and 309 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.