unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: tumashu  <tumashu@163.com>
To: "Eli Zaretskii" <eliz@gnu.org>
Cc: Po Lu <luangruo@yahoo.com>, "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re:Re: [PATCH] xwidget: Add xwidget-webkit-buffer-name-format (Re:Re: About rename xwidget-webkit-buffer-name-prefix)
Date: Thu, 11 Nov 2021 08:15:21 +0800 (CST)	[thread overview]
Message-ID: <663d4cc6.279.17d0c595700.Coremail.tumashu@163.com> (raw)
In-Reply-To: <831r3o3ylu.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]


















At 2021-11-10 21:54:21, "Eli Zaretskii" <eliz@gnu.org> wrote:
>> Date: Wed, 10 Nov 2021 17:49:04 +0800 (CST)
>> From: tumashu  <tumashu@163.com>
>> Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
>> 
>> -*** New user option 'xwidget-webkit-buffer-name-prefix'.
>> +*** New user option 'xwidget-webkit-buffer-name-format'.
>>  This allows the user to change the webkit buffer names.
>
>  Using this option you can control how the xwidget-webkit buffers are
>  named.

changed.

>
>> +(defcustom xwidget-webkit-buffer-name-format "*xwidget-webkit: %T*"
>> +  "Buffer name format used by `xwidget-webkit' buffers.
>
>    Template for naming `xwidget-webkit' buffers.
>  It can use the following special constructs:
>
>    %T -- the title of the Web page loaded by the xwidget.

changed.

>
>> +                 (rename-buffer
>> +                  (format-spec
>> +                   xwidget-webkit-buffer-name-format
>> +                   `((?T . ,title)))
>> +                  t)))))
>
>Hmmm... does this mean that the format spec _must_ contain %T?
>Because otherwise all the buffers will have the same name, no?
>Which would mean this change introduces a regression wrt how this
>worked previously, right?

I have tested without %T, it will like  *xwidget-webkit:*<2> ,*xwidget-webkit:*<3> ...
so I think some user will like this and set without %T.



[-- Attachment #2: 0001-xwidget-Add-xwidget-webkit-buffer-name-format.patch --]
[-- Type: application/octet-stream, Size: 2650 bytes --]

From efc593fc70f61879556a0a05469b162800eebb2e Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@163.com>
Date: Wed, 10 Nov 2021 16:10:37 +0800
Subject: [PATCH] xwidget: Add xwidget-webkit-buffer-name-format.

* lisp/xwidget.el (xwidget-webkit-buffer-name-prefix): Rename from ...
(xwidget-webkit-buffer-name-format):  to this.
(xwidget-webkit-callback): Use xwidget-webkit-buffer-name-format instead.
(format-spec): required.

* etc/NEWS: Note xwidget-webkit-buffer-name-format.
---
 etc/NEWS        |  5 +++--
 lisp/xwidget.el | 16 +++++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index b403be65da..d53869e245 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -443,8 +443,9 @@ This is a convenience function to extract the field data from
 ** Xwidgets
 
 ---
-*** New user option 'xwidget-webkit-buffer-name-prefix'.
-This allows the user to change the webkit buffer names.
+*** New user option 'xwidget-webkit-buffer-name-format'.
+Using this option you can control how the xwidget-webkit buffers are
+named.
 
 +++
 *** New minor mode 'xwidget-webkit-edit-mode'.
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index cc149cf197..1b3fb932ba 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -33,6 +33,7 @@
 
 (require 'cl-lib)
 (require 'bookmark)
+(require 'format-spec)
 
 (declare-function make-xwidget "xwidget.c"
                   (type title width height arguments &optional buffer related))
@@ -95,8 +96,11 @@ xwidget-webkit
   :group 'web
   :prefix "xwidget-webkit-")
 
-(defcustom xwidget-webkit-buffer-name-prefix "*xwidget-webkit: "
-  "Buffer name prefix used by `xwidget-webkit' buffers."
+(defcustom xwidget-webkit-buffer-name-format "*xwidget-webkit: %T*"
+  "Template for naming `xwidget-webkit' buffers.
+It can use the following special constructs:
+
+   %T -- the title of the Web page loaded by the xwidget."
   :type 'string
   :version "29.1")
 
@@ -372,9 +376,11 @@ xwidget-webkit-callback
                  ;; Do not adjust webkit size to window here, the
                  ;; selected window can be the mini-buffer window
                  ;; unwantedly.
-                 (rename-buffer (concat xwidget-webkit-buffer-name-prefix
-                                        title "*")
-                                t)))))
+                 (rename-buffer
+                  (format-spec
+                   xwidget-webkit-buffer-name-format
+                   `((?T . ,title)))
+                  t)))))
           ((eq xwidget-event-type 'decide-policy)
            (let ((strarg  (nth 3 last-input-event)))
              (if (string-match ".*#\\(.*\\)" strarg)
-- 
2.30.2


  parent reply	other threads:[~2021-11-11  0:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 12:31 About rename xwidget-webkit-buffer-name-prefix tumashu
2021-11-09 12:34 ` Po Lu
2021-11-10  6:33 ` Po Lu
2021-11-10  6:46   ` tumashu
2021-11-10  6:52     ` Po Lu
2021-11-10  6:54       ` Lars Ingebrigtsen
2021-11-10  8:16   ` [PATCH] xwidget: Add xwidget-webkit-buffer-name-format (Re:Re: About rename xwidget-webkit-buffer-name-prefix) tumashu
2021-11-10  9:32     ` Po Lu
2021-11-10  9:49       ` tumashu
2021-11-10  9:50         ` Po Lu
2021-11-10 13:54         ` Eli Zaretskii
2021-11-10 22:41           ` tumashu
2021-11-11  0:15           ` tumashu [this message]
2021-11-11  0:30           ` Po Lu
2021-11-11  6:54             ` Eli Zaretskii
2021-11-11 10:26         ` Po Lu

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=663d4cc6.279.17d0c595700.Coremail.tumashu@163.com \
    --to=tumashu@163.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /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).