unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Protesilaos Stavrou <info@protesilaos.com>
To: Jose Antonio Ortega Ruiz <jao@gnu.org>,
	Lars Ingebrigtsen <larsi@gnus.org>
Cc: 51176@debbugs.gnu.org, Yuchen Pei <hi@ypei.me>,
	Abhiseck Paira <abhiseckpaira@disroot.org>,
	Juri Linkov <juri@linkov.net>
Subject: bug#51176: eww switch buffer by title
Date: Sat, 16 Oct 2021 07:20:43 +0300	[thread overview]
Message-ID: <87bl3ptxb8.fsf@protesilaos.com> (raw)
In-Reply-To: <87ee8ltxi8.fsf@protesilaos.com>

On 2021-10-16, 07:16 +0300, Protesilaos Stavrou <info@protesilaos.com> wrote:

> 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?

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





  reply	other threads:[~2021-10-16  4:20 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  4:56 bug#51176: eww switch buffer by title Yuchen Pei
2021-10-13 11:52 ` Lars Ingebrigtsen
2021-10-13 12:15   ` Yuchen Pei
2021-10-13 12:54     ` Lars Ingebrigtsen
2021-10-13 16:28       ` Juri Linkov
2021-10-13 16:47         ` Lars Ingebrigtsen
2021-10-13 17:31           ` Juri Linkov
2021-10-13 18:14             ` Lars Ingebrigtsen
2021-10-13 20:31               ` Protesilaos Stavrou
2021-10-13 20:33                 ` Lars Ingebrigtsen
2021-10-15  6:31                   ` Protesilaos Stavrou
2021-10-15  8:32                     ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-15 10:35                     ` Lars Ingebrigtsen
2021-10-15 11:22                       ` Protesilaos Stavrou
2021-10-15 12:13                         ` Lars Ingebrigtsen
2021-10-15 13:25                           ` Jose Antonio Ortega Ruiz
2021-10-15 14:00                             ` Lars Ingebrigtsen
2021-10-15 19:59                               ` Jose Antonio Ortega Ruiz
2021-10-16  4:16                                 ` Protesilaos Stavrou
2021-10-16  4:20                                   ` Protesilaos Stavrou [this message]
2021-10-16 14:31                                   ` Jose Antonio Ortega Ruiz
2021-10-18  6:43                                   ` Lars Ingebrigtsen
2021-10-18  7:15                                     ` Protesilaos Stavrou
2021-10-18  7:16                                       ` Lars Ingebrigtsen
2021-10-13 21:26                 ` Yuchen Pei
2021-10-14  0:16                 ` bug#51176: [External] : " Drew Adams
2021-10-13 23:48             ` Yuchen Pei
2021-10-14 11:06               ` Lars Ingebrigtsen
2021-10-14 16:05               ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bl3ptxb8.fsf@protesilaos.com \
    --to=info@protesilaos.com \
    --cc=51176@debbugs.gnu.org \
    --cc=abhiseckpaira@disroot.org \
    --cc=hi@ypei.me \
    --cc=jao@gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).