unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: tsuucat via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Third <alan@idiocy.org>
Cc: 38851@debbugs.gnu.org
Subject: bug#38851: 27.0.50; Recent my patch breaks isearch with macOS native input method
Date: Fri, 14 Feb 2020 04:17:29 +0900	[thread overview]
Message-ID: <0929D5CF-1E2C-4CBD-8EBA-36C3194450D3@icloud.com> (raw)
In-Reply-To: <20200211172234.GA59144@breton.holly.idiocy.org>

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]


> Please squash your three new patches together and have a look at the
> instructions in CONTRIBUTE regarding commit messages.

OK. I squashed patches and attach the patch. Please tell me if there’s 
something wrong.

[-- Attachment #2: 0001-Fix-working-text-related-issues-on-NS-Bug-38851.patch --]
[-- Type: application/octet-stream, Size: 3316 bytes --]

From 01250b154fc19c7dc22d70907f3089ad4b43244d Mon Sep 17 00:00:00 2001
From: Masahiro Nakamura <tsuucat@icloud.com>
Date: Fri, 14 Feb 2020 03:21:15 +0900
Subject: [PATCH] Fix working text related issues on NS (Bug#38851)

* src/keyboard.c (read_char): Prevent redsiplay right after
ns-unput-working-text event.
* src/nsterm.m ([EmacsView insertText:]): Partially revert commit
ba04217.
([EmacsView firstRectForCharacterRange:]): Fix candidate window
position when cursor is on echoarea.
([EmacsView mouseDown:])
([EmacsView windowDidResignKey:]): Don't delete working text.
---
 src/keyboard.c |  6 ++++++
 src/nsterm.m   | 18 ++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index bf1f5da..9dd7e00 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2901,6 +2901,12 @@ read_char (int commandflag, Lisp_Object map,
 	   example banishing the mouse under mouse-avoidance-mode.  */
 	timer_resume_idle ();
 
+#ifdef HAVE_NS
+      if (CONSP (c)
+          && (EQ (XCAR (c), intern ("ns-unput-working-text"))))
+        input_was_pending = input_pending;
+#endif
+
       if (current_buffer != prev_buffer)
 	{
 	  /* The command may have changed the keymaps.  Pretend there
diff --git a/src/nsterm.m b/src/nsterm.m
index 9d427b9..fddd4b0 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6473,6 +6473,10 @@ - (void)insertText: (id)aString
   if (!emacs_event)
     return;
 
+  /* First, clear any working text.  */
+  if (workingText != nil)
+    [self deleteWorkingText];
+
   /* It might be preferable to use getCharacters:range: below,
      cf. https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CocoaPerformance/Articles/StringDrawing.html#//apple_ref/doc/uid/TP40001445-112378.
      However, we probably can't use SAFE_NALLOCA here because it might
@@ -6501,10 +6505,6 @@ - (void)insertText: (id)aString
       emacs_event->code = code;
       EV_TRAILER ((id)nil);
     }
-
-  /* Last, clear any working text.  */
-  if (workingText != nil)
-    [self deleteWorkingText];
 }
 
 
@@ -6600,13 +6600,18 @@ - (NSRect)firstRectForCharacterRange: (NSRange)theRange
 {
   NSRect rect;
   NSPoint pt;
-  struct window *win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
+  struct window *win;
 
   NSTRACE ("[EmacsView firstRectForCharacterRange:]");
 
   if (NS_KEYLOG)
     NSLog (@"firstRectForCharRange request");
 
+  if (WINDOWP (echo_area_window) && ! NILP (call0 (intern ("ns-in-echo-area"))))
+    win = XWINDOW (echo_area_window);
+  else
+    win = XWINDOW (FRAME_SELECTED_WINDOW (emacsframe));
+
   rect.size.width = theRange.length * FRAME_COLUMN_WIDTH (emacsframe);
   rect.size.height = FRAME_LINE_HEIGHT (emacsframe);
   pt.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (win, win->phys_cursor.x);
@@ -6713,8 +6718,6 @@ - (void)mouseDown: (NSEvent *)theEvent
 
   NSTRACE ("[EmacsView mouseDown:]");
 
-  [self deleteWorkingText];
-
   if (!emacs_event)
     return;
 
@@ -7341,7 +7344,6 @@ - (void)windowDidResignKey: (NSNotification *)notification
 
   if (emacs_event && is_focus_frame)
     {
-      [self deleteWorkingText];
       emacs_event->kind = FOCUS_OUT_EVENT;
       EV_TRAILER ((id)nil);
     }
-- 
2.21.0


[-- Attachment #3: Type: text/plain, Size: 88 bytes --]


> Thanks for working on this and sorry again for the delay.

Thank you too!

--
tsuucat

  reply	other threads:[~2020-02-13 19:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-01 18:25 bug#38851: 27.0.50; Recent my patch breaks isearch with macOS native input method tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-01-03 20:29 ` Alan Third
2020-02-10 17:08   ` tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-02-10 21:44     ` Alan Third
2020-02-10 22:21       ` tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-02-11 15:56         ` Eli Zaretskii
2020-02-11 17:22         ` Alan Third
2020-02-13 19:17           ` tsuucat via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2020-02-19 11:14             ` Alan Third
2020-02-11 17:05       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0929D5CF-1E2C-4CBD-8EBA-36C3194450D3@icloud.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=38851@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=tsuucat@icloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).