From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Protesilaos Stavrou Newsgroups: gmane.emacs.bugs Subject: bug#51176: eww switch buffer by title Date: Sat, 16 Oct 2021 07:16:31 +0300 Message-ID: <87ee8ltxi8.fsf@protesilaos.com> References: <87v9214j6g.fsf@ypei.me> <87lf2x6t11.fsf@gnus.org> <87fst53ytg.fsf@ypei.me> <871r4p6q5n.fsf@gnus.org> <871r4oyjm1.fsf@mail.linkov.net> <875yu050sz.fsf@gnus.org> <875yu0x256.fsf@mail.linkov.net> <87wnmg3i8f.fsf@gnus.org> <87pms8psyt.fsf@protesilaos.com> <87r1co1x8f.fsf@gnus.org> <87bl3qiysk.fsf@protesilaos.com> <87sfx24lua.fsf@gnus.org> <87ee8my1l8.fsf@protesilaos.com> <87a6ja4hb3.fsf@gnus.org> <8735p2qv1w.fsf@gnus.jao.io> <87ilxy2xrb.fsf@gnus.org> <87r1cmoy8g.fsf@gnus.jao.io> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38268"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.33.2 (https://notmuchmail.org) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 51176@debbugs.gnu.org, Yuchen Pei , Abhiseck Paira , Juri Linkov To: Jose Antonio Ortega Ruiz , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 16 06:17:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbb8B-0009lS-ES for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Oct 2021 06:17:11 +0200 Original-Received: from localhost ([::1]:36352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbb89-00083C-RM for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Oct 2021 00:17:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbb82-000833-8b for bug-gnu-emacs@gnu.org; Sat, 16 Oct 2021 00:17:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbb82-0001jx-0g for bug-gnu-emacs@gnu.org; Sat, 16 Oct 2021 00:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mbb81-0007kh-SU for bug-gnu-emacs@gnu.org; Sat, 16 Oct 2021 00:17:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Protesilaos Stavrou Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Oct 2021 04:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51176 X-GNU-PR-Package: emacs Original-Received: via spool by 51176-submit@debbugs.gnu.org id=B51176.163435780429769 (code B ref 51176); Sat, 16 Oct 2021 04:17:01 +0000 Original-Received: (at 51176) by debbugs.gnu.org; 16 Oct 2021 04:16:44 +0000 Original-Received: from localhost ([127.0.0.1]:40739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mbb7k-0007k5-0c for submit@debbugs.gnu.org; Sat, 16 Oct 2021 00:16:44 -0400 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:50139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mbb7g-0007jo-FU for 51176@debbugs.gnu.org; Sat, 16 Oct 2021 00:16:43 -0400 Original-Received: (Authenticated sender: public@protesilaos.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id EA451100003; Sat, 16 Oct 2021 04:16:32 +0000 (UTC) In-Reply-To: <87r1cmoy8g.fsf@gnus.jao.io> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:217338 Archived-At: On 2021-10-15, 20:59 +0100, Jose Antonio Ortega Ruiz wrote: > On Fri, Oct 15 2021, Lars Ingebrigtsen wrote: > >> Jose Antonio Ortega Ruiz 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