summaryrefslogtreecommitdiff
path: root/src/xselect.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-07-12 10:47:23 +0800
committerPo Lu <luangruo@yahoo.com>2022-07-12 10:47:51 +0800
commit86d128c6c3acca1665addc65aa43ff80572f46e8 (patch)
treeef1dd26be80acf43384c8146e3c784a09ab0cb0d /src/xselect.c
parent7ac313ea87b4761baf975718e4fa3200f61a0ad9 (diff)
downloademacs-86d128c6c3acca1665addc65aa43ff80572f46e8.tar.gz
Try to save selections from being disowned during frame deletion
* lisp/cus-start.el (standard): Add `x-auto-preserve-selections'. * src/xselect.c (x_clear_frame_selections): Collect deleted selections into a variable and preserve them. * src/xterm.c (x_preserve_selections): New function. (syms_of_xterm): New variable `x-auto-preserve-selections'. * src/xterm.h: Update prototypes.
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 25a75aec917..baab2c5c18f 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1091,20 +1091,23 @@ x_handle_selection_event (struct selection_input_event *event)
void
x_clear_frame_selections (struct frame *f)
{
- Lisp_Object frame;
- Lisp_Object rest;
+ Lisp_Object frame, rest, lost;
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
struct terminal *t = dpyinfo->terminal;
XSETFRAME (frame, f);
+ lost = Qnil;
/* Delete elements from the beginning of Vselection_alist. */
while (CONSP (t->Vselection_alist)
&& EQ (frame, XCAR (XCDR (XCDR (XCDR (XCAR (t->Vselection_alist)))))))
{
- /* Run the `x-lost-selection-functions' abnormal hook. */
- CALLN (Frun_hook_with_args, Qx_lost_selection_functions,
- Fcar (Fcar (t->Vselection_alist)));
+ if (!x_auto_preserve_selections)
+ /* Run the `x-lost-selection-functions' abnormal hook. */
+ CALLN (Frun_hook_with_args, Qx_lost_selection_functions,
+ Fcar (Fcar (t->Vselection_alist)));
+ else
+ lost = Fcons (Fcar (t->Vselection_alist), lost);
tset_selection_alist (t, XCDR (t->Vselection_alist));
}
@@ -1114,11 +1117,18 @@ x_clear_frame_selections (struct frame *f)
if (CONSP (XCDR (rest))
&& EQ (frame, XCAR (XCDR (XCDR (XCDR (XCAR (XCDR (rest))))))))
{
- CALLN (Frun_hook_with_args, Qx_lost_selection_functions,
- XCAR (XCAR (XCDR (rest))));
+ if (!x_auto_preserve_selections)
+ CALLN (Frun_hook_with_args, Qx_lost_selection_functions,
+ XCAR (XCAR (XCDR (rest))));
+ else
+ lost = Fcons (XCAR (XCDR (rest)), lost);
+
XSETCDR (rest, XCDR (XCDR (rest)));
break;
}
+
+ if (x_auto_preserve_selections)
+ x_preserve_selections (dpyinfo, lost);
}
/* True if any properties for DISPLAY and WINDOW