]> git.eshelyaron.com Git - emacs.git/commitdiff
xwidget: Add xwidget-webkit-buffer-name-format.
authorFeng Shu <tumashu@163.com>
Thu, 11 Nov 2021 10:24:49 +0000 (18:24 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 11 Nov 2021 10:26:05 +0000 (18:26 +0800)
* lisp/xwidget.el (xwidget-webkit-buffer-name-prefix):
Remove variable.
(xwidget-webkit-buffer-name-format): New variable.
(xwidget-webkit-callback): Use
xwidget-webkit-buffer-name-format instead.
(format-spec): required.

* etc/NEWS: Note xwidget-webkit-buffer-name-format.

etc/NEWS
lisp/xwidget.el

index e0b1c35d81f94f058ff0368ea367f69b128ebaa0..2ce76769fe859771e0bfeb8d5fe95e7169bbda75 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -454,8 +454,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'.
index 2c7b4dd83dabfd95e87bbac3e430924cb3891d5a..8078f1d01b05d73ff412eda1d95ce226a72cfcf0 100644 (file)
@@ -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 @@ This returns the result of `make-xwidget'."
   :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 instance, XWIDGET-EVENT-TYPE depends on the originating xwidget."
                  ;; 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)