[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#51176: eww switch buffer by title
From: |
Protesilaos Stavrou |
Subject: |
bug#51176: eww switch buffer by title |
Date: |
Sat, 16 Oct 2021 07:16:31 +0300 |
User-agent: |
Notmuch/0.33.2 (https://notmuchmail.org) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
On 2021-10-15, 20:59 +0100, Jose Antonio Ortega Ruiz <jao@gnu.org> wrote:
> On Fri, Oct 15 2021, Lars Ingebrigtsen wrote:
>
>> Jose Antonio Ortega Ruiz <jao@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?
Like 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))))
(rename-buffer (format "*%s*" string) t))))
And we add it here:
(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))))
(rename-buffer (format \"*%s*\" string) t))))
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)
I can prepare a patch if you think this is worth it.
--
Protesilaos Stavrou
https://protesilaos.com
- bug#51176: eww switch buffer by title, (continued)
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/13
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/13
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/15
- bug#51176: eww switch buffer by title, miha, 2021/10/15
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/15
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/15
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/15
- bug#51176: eww switch buffer by title, Jose Antonio Ortega Ruiz, 2021/10/15
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/15
- bug#51176: eww switch buffer by title, Jose Antonio Ortega Ruiz, 2021/10/15
- bug#51176: eww switch buffer by title,
Protesilaos Stavrou <=
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/16
- bug#51176: eww switch buffer by title, Jose Antonio Ortega Ruiz, 2021/10/16
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/18
- bug#51176: eww switch buffer by title, Protesilaos Stavrou, 2021/10/18
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/18
- bug#51176: eww switch buffer by title, Yuchen Pei, 2021/10/13
- bug#51176: [External] : bug#51176: eww switch buffer by title, Drew Adams, 2021/10/13
- bug#51176: eww switch buffer by title, Yuchen Pei, 2021/10/13
- bug#51176: eww switch buffer by title, Lars Ingebrigtsen, 2021/10/14
- bug#51176: eww switch buffer by title, Juri Linkov, 2021/10/14