aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-02-18 14:48:08 +0800
committerPo Lu2023-02-18 14:48:08 +0800
commitfa1b27930ea5f61d92880c3c252774f2f97f529d (patch)
tree2966911903fbbd5cf767c9bcae58100b34391b55 /src
parent3a0b3cd086ecf502e35a043401037fb4959d875c (diff)
downloademacs-fa1b27930ea5f61d92880c3c252774f2f97f529d.tar.gz
emacs-fa1b27930ea5f61d92880c3c252774f2f97f529d.zip
Notify input methods when editing fails
* INSTALL.android: Clarify build instructions. * src/textconv.c (struct complete_edit_check_context): New structure. (complete_edit_check): New function. (handle_pending_conversion_events_1): If the window is known, then ensure that any editing failures are reported to the input method.
Diffstat (limited to 'src')
-rw-r--r--src/textconv.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/textconv.c b/src/textconv.c
index 7704f1b62a6..50146820dce 100644
--- a/src/textconv.c
+++ b/src/textconv.c
@@ -978,6 +978,52 @@ complete_edit (void *token)
978 text_interface->notify_conversion (*(unsigned long *) token); 978 text_interface->notify_conversion (*(unsigned long *) token);
979} 979}
980 980
981/* Context for complete_edit_check. */
982
983struct complete_edit_check_context
984{
985 /* The window. */
986 struct window *w;
987
988 /* Whether or not editing was successful. */
989 bool check;
990};
991
992/* If CONTEXT->check is false, then update W's ephemeral last point
993 and give it to the input method, the assumption being that an
994 editing operation signalled. */
995
996static void
997complete_edit_check (void *ptr)
998{
999 struct complete_edit_check_context *context;
1000 struct frame *f;
1001
1002 context = ptr;
1003
1004 if (!context->check)
1005 {
1006 /* Figure out the new position of point. */
1007 context->w->ephemeral_last_point
1008 = window_point (context->w);
1009
1010 /* See if the frame is still alive. */
1011
1012 f = WINDOW_XFRAME (context->w);
1013
1014 if (!FRAME_LIVE_P (f))
1015 return;
1016
1017 if (text_interface && text_interface->point_changed)
1018 {
1019 if (f->conversion.batch_edit_count > 0)
1020 f->conversion.batch_edit_flags |= PENDING_POINT_CHANGE;
1021 else
1022 text_interface->point_changed (f, context->w, NULL);
1023 }
1024 }
1025}
1026
981/* Process and free the text conversion ACTION. F must be the frame 1027/* Process and free the text conversion ACTION. F must be the frame
982 on which ACTION will be performed. 1028 on which ACTION will be performed.
983 1029
@@ -993,6 +1039,7 @@ handle_pending_conversion_events_1 (struct frame *f,
993 struct window *w; 1039 struct window *w;
994 specpdl_ref count; 1040 specpdl_ref count;
995 unsigned long token; 1041 unsigned long token;
1042 struct complete_edit_check_context context;
996 1043
997 /* Next, process this action and free it. */ 1044 /* Next, process this action and free it. */
998 1045
@@ -1008,6 +1055,10 @@ handle_pending_conversion_events_1 (struct frame *f,
1008 if (conversion_disabled_p ()) 1055 if (conversion_disabled_p ())
1009 return NULL; 1056 return NULL;
1010 1057
1058 /* check is a flag used by complete_edit_check to determine whether
1059 or not the editing operation completed successfully. */
1060 context.check = false;
1061
1011 /* Make sure completion is signalled. */ 1062 /* Make sure completion is signalled. */
1012 count = SPECPDL_INDEX (); 1063 count = SPECPDL_INDEX ();
1013 record_unwind_protect_ptr (complete_edit, &token); 1064 record_unwind_protect_ptr (complete_edit, &token);
@@ -1017,6 +1068,10 @@ handle_pending_conversion_events_1 (struct frame *f,
1017 { 1068 {
1018 w = XWINDOW (f->old_selected_window); 1069 w = XWINDOW (f->old_selected_window);
1019 buffer = XBUFFER (WINDOW_BUFFER (w)); 1070 buffer = XBUFFER (WINDOW_BUFFER (w));
1071 context.w = w;
1072
1073 /* Notify the input method of any editing failures. */
1074 record_unwind_protect_ptr (complete_edit_check, &context);
1020 } 1075 }
1021 1076
1022 switch (operation) 1077 switch (operation)
@@ -1070,6 +1125,8 @@ handle_pending_conversion_events_1 (struct frame *f,
1070 break; 1125 break;
1071 } 1126 }
1072 1127
1128 /* Signal success. */
1129 context.check = true;
1073 unbind_to (count, Qnil); 1130 unbind_to (count, Qnil);
1074 1131
1075 return w; 1132 return w;