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:20:43 +0300 Message-ID: <87bl3ptxb8.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> <87ee8ltxi8.fsf@protesilaos.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14893"; 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:21: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 1mbbC3-0003gD-PI for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Oct 2021 06:21:11 +0200 Original-Received: from localhost ([::1]:37318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbbC1-0000iB-Tz for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Oct 2021 00:21:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbbBu-0000hn-6R for bug-gnu-emacs@gnu.org; Sat, 16 Oct 2021 00:21:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbbBt-0005As-Tz for bug-gnu-emacs@gnu.org; Sat, 16 Oct 2021 00:21:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mbbBt-0007qu-P1 for bug-gnu-emacs@gnu.org; Sat, 16 Oct 2021 00:21: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:21: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.163435805730164 (code B ref 51176); Sat, 16 Oct 2021 04:21:01 +0000 Original-Received: (at 51176) by debbugs.gnu.org; 16 Oct 2021 04:20:57 +0000 Original-Received: from localhost ([127.0.0.1]:40744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mbbBo-0007qS-Mr for submit@debbugs.gnu.org; Sat, 16 Oct 2021 00:20:56 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:52161) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mbbBl-0007qC-FN for 51176@debbugs.gnu.org; Sat, 16 Oct 2021 00:20:55 -0400 Original-Received: (Authenticated sender: public@protesilaos.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 4E9201C0002; Sat, 16 Oct 2021 04:20:44 +0000 (UTC) In-Reply-To: <87ee8ltxi8.fsf@protesilaos.com> 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:217339 Archived-At: On 2021-10-16, 07:16 +0300, Protesilaos Stavrou wrote: > 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? 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