aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorPo Lu2022-07-11 19:36:01 +0800
committerPo Lu2022-07-11 19:36:12 +0800
commit6f57fb71a50a8b2ac8163828a2cecb394bb52d06 (patch)
tree02cbe006bbd8ec919f6bf3ed32a1fbd1d23048ac /src/keyboard.c
parent2f823ffd28d064fc8c1a3947e74c512b577863c6 (diff)
downloademacs-6f57fb71a50a8b2ac8163828a2cecb394bb52d06.tar.gz
emacs-6f57fb71a50a8b2ac8163828a2cecb394bb52d06.zip
Improve behavior of `lost-selection-mode' with multiple buffers
* etc/NEWS: Announce new hook `post-select-region-hook'. * lisp/select.el (lost-selection-last-region-buffer): New variable. (lost-selection-post-select-region-function): New function. Deactivate the mark if the buffer changed. (lost-selection-mode): Add new hook. * src/keyboard.c (command_loop_1): Run that hook when appropriate. (syms_of_keyboard): New hook `post-select-region-hook'.
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 7c13ac96114..1d505c13be3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1590,9 +1590,12 @@ command_loop_1 (void)
1590 { 1590 {
1591 Lisp_Object txt 1591 Lisp_Object txt
1592 = call1 (Vregion_extract_function, Qnil); 1592 = call1 (Vregion_extract_function, Qnil);
1593
1593 if (XFIXNUM (Flength (txt)) > 0) 1594 if (XFIXNUM (Flength (txt)) > 0)
1594 /* Don't set empty selections. */ 1595 /* Don't set empty selections. */
1595 call2 (Qgui_set_selection, QPRIMARY, txt); 1596 call2 (Qgui_set_selection, QPRIMARY, txt);
1597
1598 CALLN (Frun_hook_with_args, Qpost_select_region_hook, txt);
1596 } 1599 }
1597 1600
1598 if (current_buffer != prev_buffer || MODIFF != prev_modiff) 1601 if (current_buffer != prev_buffer || MODIFF != prev_modiff)
@@ -12080,6 +12083,9 @@ syms_of_keyboard (void)
12080 DEFSYM (Qpre_command_hook, "pre-command-hook"); 12083 DEFSYM (Qpre_command_hook, "pre-command-hook");
12081 DEFSYM (Qpost_command_hook, "post-command-hook"); 12084 DEFSYM (Qpost_command_hook, "post-command-hook");
12082 12085
12086 /* Hook run after the region is selected. */
12087 DEFSYM (Qpost_select_region_hook, "post-select-region-hook");
12088
12083 DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary"); 12089 DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary");
12084 DEFSYM (Qundo_auto__undoably_changed_buffers, 12090 DEFSYM (Qundo_auto__undoably_changed_buffers,
12085 "undo-auto--undoably-changed-buffers"); 12091 "undo-auto--undoably-changed-buffers");
@@ -13028,6 +13034,12 @@ not recorded. The non-nil value countermands `inhibit--record-char',
13028which see. */); 13034which see. */);
13029 record_all_keys = false; 13035 record_all_keys = false;
13030 13036
13037 DEFVAR_LISP ("post-select-region-hook", Vpost_select_region_hook,
13038 doc: /* Abnormal hook run after the region is selected.
13039This usually happens as a result of `select-active-regions'. The hook
13040is called with one argument, the string that was selected. */);;
13041 Vpost_select_region_hook = Qnil;
13042
13031 pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); 13043 pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper);
13032} 13044}
13033 13045