From b849935e98818a36b2561332514b1f7b6ea356bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Jadi?= Date: Tue, 16 Jul 2013 19:39:20 +0200 Subject: [PATCH] * src/xwidget.c: Add a `query-on-exit' flag to determine whether we can kill xwidget when the buffer is killed without confirmation. (Fset_xwidget_query_on_exit_flag): New function to set the `query-on-exit' flag. (Fxwidget_query_on_exit_flag): New function to retrieve the value of the `query-on-exit' flag. (Fmake_xwidget): Set the `query-on-exit' flag to t by default. * src/xwidget.h (xwidget): Add new field `kill_without_query'. * lisp/xwidget.el (xwidget-kill-buffer-query-function): Ask for confirmation before killing the buffer if a xwidget is present only if its `query-on-exit' flag is enabled. --- lisp/xwidget.el | 1 + src/xwidget.c | 27 +++++++++++++++++++++++++++ src/xwidget.h | 2 ++ 3 files changed, 30 insertions(+) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 4d2453e9d2d..5d04618209c 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -458,6 +458,7 @@ It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." "Ask beforek illing a buffer that has xwidgets." (let ((xwidgets (get-buffer-xwidgets (current-buffer)))) (or (not xwidgets) + (not (memq t (mapcar 'xwidget-query-on-exit-flag xwidgets))) (yes-or-no-p (format "Buffer %S has xwidgets; kill it? " (buffer-name (current-buffer))))))) diff --git a/src/xwidget.c b/src/xwidget.c index 7834e5b0bea..9a039d9a745 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -209,6 +209,7 @@ TYPE is a symbol which can take one of the following values: xw->height = XFASTINT(height); xw->width = XFASTINT(width); + xw->kill_without_query = 1; XSETXWIDGET (val, xw); // set the vectorlike_header of VAL with the correct value Vxwidget_list = Fcons (val, Vxwidget_list); xw->widgetwindow_osr = NULL; @@ -1598,6 +1599,30 @@ DEFUN ("set-xwidget-plist", Fset_xwidget_plist, Sset_xwidget_plist, return plist; } +DEFUN ("set-xwidget-query-on-exit-flag", + Fset_xwidget_query_on_exit_flag, Sset_xwidget_query_on_exit_flag, + 2, 2, 0, + doc: /* Specify if query is needed for XWIDGET when Emacs is +exited. If the second argument FLAG is non-nil, Emacs will query the +user before exiting or killing a buffer if XWIDGET is running. This +function returns FLAG. */) + (Lisp_Object xwidget, Lisp_Object flag) +{ + CHECK_XWIDGET (xwidget); + XXWIDGET (xwidget)->kill_without_query = NILP (flag); + return flag; +} + +DEFUN ("xwidget-query-on-exit-flag", + Fxwidget_query_on_exit_flag, Sxwidget_query_on_exit_flag, + 1, 1, 0, + doc: /* Return the current value of query-on-exit flag for XWIDGET. */) + (Lisp_Object xwidget) +{ + CHECK_XWIDGET (xwidget); + return (XXWIDGET (xwidget)->kill_without_query ? Qnil : Qt); +} + void syms_of_xwidget (void) { @@ -1615,6 +1640,8 @@ syms_of_xwidget (void) defsubr (&Sxwidget_view_model); defsubr (&Sxwidget_view_window); defsubr (&Sxwidget_view_lookup); + defsubr (&Sxwidget_query_on_exit_flag); + defsubr (&Sset_xwidget_query_on_exit_flag); #ifdef HAVE_WEBKIT_OSR defsubr (&Sxwidget_webkit_goto_uri); diff --git a/src/xwidget.h b/src/xwidget.h index 01be2b29281..1495c5bef5a 100644 --- a/src/xwidget.h +++ b/src/xwidget.h @@ -34,6 +34,8 @@ struct xwidget{ //for offscreen widgets, unused if not osr GtkWidget* widget_osr; GtkContainer* widgetwindow_osr; + /* Non-nil means kill silently if Emacs is exited. */ + unsigned int kill_without_query : 1; //TODO these are WIP -- 2.39.2