all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, Kenichi Handa <handa@gnu.org>
Cc: 23009@debbugs.gnu.org
Subject: bug#23009: 25.0.92; xterm-mouse-mode should not assume UTF-8 coordinates
Date: Sat, 02 Apr 2016 19:10:45 +0000	[thread overview]
Message-ID: <CAArVCkSucfLc6NR3jXNhO2USVirbcXUprCNqyJC=fkA3+muhVg@mail.gmail.com> (raw)
In-Reply-To: <83lh4ws5vy.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1823 bytes --]

Eli Zaretskii <eliz@gnu.org> schrieb am Sa., 2. Apr. 2016 um 11:43 Uhr:

> > Date: Sun, 27 Mar 2016 18:21:10 +0300
> > From: Eli Zaretskii <eliz@gnu.org>
> > Cc: 23009@debbugs.gnu.org
> >
> > > From: Philipp Stephani <p.stephani2@gmail.com>
> > > Date: Sat, 26 Mar 2016 22:26:17 +0000
> > > Cc: 23009@debbugs.gnu.org
> > >
> > >  Hmm... what does current-input-mode return on HTerm in "emacs -Q"?
> > >
> > > (t nil 0 7)
> > >
> > >  I
> > >  expect to see a non-nil, non-t value in the 3rd element of its return
> > >  value. If that's so, then testing that value for identity with the
> > >  one we want to pass to set-input-meta-mode, and avoiding the latter
> > >  call if the mode is already what we want, might avoid the flickering.
> > >
> > > Yes, that's already the case (set-input-meta-mode doesn't reinitialize
> the terminal if the meta mode doesn't
> > > change), and it's why I use latin-1 instead of no-conversion. With
> latin-1, a single mouse click results in 8
> > > invocations of (set-input-meta-mode 8) (two mouse events with two
> coordinates each, and a set and reset
> > > per coordinate). With no-conversion, the same click results in four
> sequences of (set-input-meta-mode t)
> > > (set-input-meta-mode 8), which causes the flicker.
> >
> > Then I guess I'm confused about the reason for (set-input-meta-mode t)
> > in the case of no-conversion -- don't we want Emacs to pass the 8th
> > bit through without interpreting it?  Perhaps Handa-san could comment
> > on this, as I'm otherwise inclined to add raw-text to the list of the
> > coding-system types that want a non-nil, non-t value to be passed to
> > set-input-meta-mode.
>
> Ping!
>
> Philipp, can you try adding raw-text to that list, and see if the
> result works correctly?
>

Yes, it works (unsurprisingly), I've attached a patch.

[-- Attachment #1.2: Type: text/html, Size: 2624 bytes --]

[-- Attachment #2: 0002-Simplify-8-bit-character-handling-for-raw-text.patch --]
[-- Type: application/octet-stream, Size: 4799 bytes --]

From 3ded3ff4d38e66bd69d219c0a00edad02feedac6 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sat, 2 Apr 2016 21:07:00 +0200
Subject: [PATCH 2/2] Simplify 8-bit character handling for 'raw-text.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

'raw-text shouldn’t incur any conversion, so it should pass through the
high bit without interpreting it.

* lisp/xt-mouse.el (xterm-mouse--read-coordinate): Use 'no-conversion
instead of 'latin-1.
* lisp/international/mule.el (set-keyboard-coding-system): Treat
‘raw-text’ as another coding type that requires 8-bit characters.
---
 lisp/international/mule.el | 65 +++++++++++++++++++++-------------------------
 lisp/xt-mouse.el           |  5 +---
 2 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 60a90ae..21ab7e1 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1445,42 +1445,35 @@ set-keyboard-coding-system
   (let ((coding-type (coding-system-type coding-system))
 	(saved-meta-mode
 	 (terminal-parameter terminal 'keyboard-coding-saved-meta-mode)))
-    (if (not (eq coding-type 'raw-text))
-	(let (accept-8-bit)
-	  (if (not (or (coding-system-get coding-system :suitable-for-keyboard)
-		       (coding-system-get coding-system :ascii-compatible-p)))
-	      (error "Unsuitable coding system for keyboard: %s" coding-system))
-	  (cond ((memq coding-type '(charset utf-8 shift-jis big5 ccl))
-		 (setq accept-8-bit t))
-		((eq coding-type 'iso-2022)
-		 (let ((flags (coding-system-get coding-system :flags)))
-		   (or (memq '7-bit flags)
-		       (setq accept-8-bit t))))
-		(t
-		 (error "Unsupported coding system for keyboard: %s"
-			coding-system)))
-	  (if accept-8-bit
-	      (progn
-		(or saved-meta-mode
-		    (set-terminal-parameter terminal
-					    'keyboard-coding-saved-meta-mode
-					    (cons (nth 2 (current-input-mode))
-						  nil)))
-		(set-input-meta-mode 8 terminal))
-	    (when saved-meta-mode
-	      (set-input-meta-mode (car saved-meta-mode) terminal)
-	      (set-terminal-parameter terminal
-				      'keyboard-coding-saved-meta-mode
-				      nil)))
-	  ;; Avoid end-of-line conversion.
-	  (setq coding-system
-		(coding-system-change-eol-conversion coding-system 'unix)))
-
-      (when saved-meta-mode
-	(set-input-meta-mode (car saved-meta-mode) terminal)
-	(set-terminal-parameter terminal
-				'keyboard-coding-saved-meta-mode
-				nil))))
+    (let (accept-8-bit)
+      (if (not (or (coding-system-get coding-system :suitable-for-keyboard)
+                   (coding-system-get coding-system :ascii-compatible-p)))
+          (error "Unsuitable coding system for keyboard: %s" coding-system))
+      (cond ((memq coding-type '(raw-text charset utf-8 shift-jis big5 ccl))
+             (setq accept-8-bit t))
+            ((eq coding-type 'iso-2022)
+             (let ((flags (coding-system-get coding-system :flags)))
+               (or (memq '7-bit flags)
+                   (setq accept-8-bit t))))
+            (t
+             (error "Unsupported coding system for keyboard: %s"
+                    coding-system)))
+      (if accept-8-bit
+          (progn
+            (or saved-meta-mode
+                (set-terminal-parameter terminal
+                                        'keyboard-coding-saved-meta-mode
+                                        (cons (nth 2 (current-input-mode))
+                                              nil)))
+            (set-input-meta-mode 8 terminal))
+        (when saved-meta-mode
+          (set-input-meta-mode (car saved-meta-mode) terminal)
+          (set-terminal-parameter terminal
+                                  'keyboard-coding-saved-meta-mode
+                                  nil)))
+      ;; Avoid end-of-line conversion.
+      (setq coding-system
+            (coding-system-change-eol-conversion coding-system 'unix))))
   (set-keyboard-coding-system-internal coding-system terminal)
   (setq keyboard-coding-system coding-system))
 
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index e520957..a2b6401 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -155,10 +155,7 @@ xterm-mouse--read-coordinate
           (set-keyboard-coding-system
            (if (terminal-parameter nil 'xterm-mouse-utf-8)
                'utf-8-unix
-             ;; Use Latin-1 instead of no-conversion to avoid flicker
-             ;; due to `set-keyboard-coding-system' changing the meta
-             ;; mode.
-             'latin-1))
+             'no-conversion))
           ;; Wait only a little; we assume that the entire escape sequence
           ;; has already been sent when this function is called.
           (read-char nil nil 0.1))
-- 
2.7.4


  reply	other threads:[~2016-04-02 19:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 12:56 bug#23009: 25.0.92; xterm-mouse-mode should not assume UTF-8 coordinates Philipp Stephani
2016-03-14 16:43 ` Eli Zaretskii
2016-03-14 17:24   ` Philipp Stephani
2016-03-14 23:03     ` Philipp Stephani
2016-03-15 17:57       ` Eli Zaretskii
2016-03-19 17:15         ` Philipp Stephani
2016-03-19 17:16           ` Philipp Stephani
2016-03-25 10:18             ` Eli Zaretskii
2016-03-26 17:31               ` Philipp Stephani
2016-03-26 18:07                 ` Eli Zaretskii
2016-03-26 22:26                   ` Philipp Stephani
2016-03-27 15:21                     ` Eli Zaretskii
2016-04-02  9:43                       ` Eli Zaretskii
2016-04-02 19:10                         ` Philipp Stephani [this message]
2016-04-02 19:53                           ` Eli Zaretskii
2016-04-08  8:24                             ` Eli Zaretskii
2016-04-16  9:57                             ` 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

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

  git send-email \
    --in-reply-to='CAArVCkSucfLc6NR3jXNhO2USVirbcXUprCNqyJC=fkA3+muhVg@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=23009@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=handa@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.