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.
This commit is contained in:
Feng Shu 2021-11-11 18:24:49 +08:00 committed by Po Lu
parent 12a638d845
commit f69a808ddc
2 changed files with 14 additions and 7 deletions

View file

@ -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'.

View 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)