From f69a808ddcf7b2fd8cc2eacf99dd98248b9c455a Mon Sep 17 00:00:00 2001 From: Feng Shu Date: Thu, 11 Nov 2021 18:24:49 +0800 Subject: [PATCH] xwidget: Add xwidget-webkit-buffer-name-format. * 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 | 5 +++-- lisp/xwidget.el | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index e0b1c35d81f..2ce76769fe8 100644 --- 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'. diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 2c7b4dd83da..8078f1d01b0 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 @@ 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) -- 2.39.2