From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Mazieres expires 2013-11-25 PST Newsgroups: gmane.emacs.help Subject: Any way to make Alt key like X-windows in UTF-8 terminal? Date: Tue, 27 Aug 2013 14:57:35 -0700 Message-ID: <87ppsyyey8.wl@ta.scs.stanford.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1377662642 25610 80.91.229.3 (28 Aug 2013 04:04:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Aug 2013 04:04:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 28 06:04:05 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VEWzE-0002es-AL for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Aug 2013 06:04:04 +0200 Original-Received: from localhost ([::1]:60206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEWzD-0007cP-Tw for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Aug 2013 00:04:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEVwa-0001oK-3Z for help-gnu-emacs@gnu.org; Tue, 27 Aug 2013 22:57:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEVwU-0001jL-2o for help-gnu-emacs@gnu.org; Tue, 27 Aug 2013 22:57:16 -0400 Original-Received: from market.scs.stanford.edu ([171.66.3.10]:45763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEVwT-0001gK-QW for help-gnu-emacs@gnu.org; Tue, 27 Aug 2013 22:57:10 -0400 Original-Received: from market.scs.stanford.edu (localhost.scs.stanford.edu [127.0.0.1]) by market.scs.stanford.edu (8.14.6/8.14.6) with ESMTP id r7RLxDRr016137 for ; Tue, 27 Aug 2013 14:59:13 -0700 (PDT) Original-Received: from lumen.scs.stanford.edu.scs.stanford.edu (dm@localhost) by market.scs.stanford.edu (8.14.6/8.14.3/Submit) with ESMTP id r7RLxCFm007321 for ; Tue, 27 Aug 2013 14:59:12 -0700 (PDT) X-Authentication-Warning: market.scs.stanford.edu: dm owned process doing -bs User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.3 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-operating-system: by eggs.gnu.org: OpenBSD 4.x-5.x X-Received-From: 171.66.3.10 X-Mailman-Approved-At: Wed, 28 Aug 2013 00:03:55 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93130 Archived-At: I've been trying to find a way to get the Alt key to work the same in UTF-8 terminals as it does in X windows. By UTF-8 terminal, I mean one in which the alt key works, adds 128 to the value of whatever key was typed, and then translates the corresponding unicode code point (which lies between 128 and 255) into a two byte UTF-8 sequence. In particular, this behavior is what you get from xterm if you set the following X resources: XTerm*eightBitInput: true XTerm*utf8: true Now the behavior I get in X windows, which I like, is that Alt behaves like meta. In other words, when I type Alt-x, it gets interpreted as M-x, which is bound to execute-extended-command. On the other hand, if I type Control-q followed by Alt-x, I get unicode code point 0xf8, "LATIN SMALL LETTER O WITH STROKE". Unfortunately, I can't figure out any easy way to make this happen in "emacs -nw". Basically unicode character 0xf8 is always interpreted as LATIN SMALL LETTER O WITH STROKE, and never as M-x. In the particular case of xterm, I can set the xterm resource altSendsEscape to true, but this does not work very well with viper, which interprets the ESC character differently. Moreover, for other applications I run in the terminal, I don't want Alt sending the escape key. Hence, I would very much like to make Alt work with the exact X resources that I listed above in this message. The best I've been able to come up with so far is: XTerm*eightBitInput: true XTerm*utf8: false Then if I run emacs -nw with LC_TYPE=C, I get the appropriate behavior. However, now xterm and emacs don't display unicode characters properly, which I live with okay for years, but now other applications in my xterm really want to send unicode. Effectively what I want is to use different locales for input and output, which is not possible. However, I could get something equivalent if emacs compensated by mapping code points 128-255 to meta keys. It's also possible that I'm thinking about the problem in entirely the wrong way, so higher-level advice would be welcome, too. At a high level, the problem is just getting viper in "emacs -nw" to work the way it does in X windows. Oh, and I guess I have one more constraint, which is that if I don't hard-code: (defun viper-translate-all-ESC-keysequences () nil) then I get horrible behavior over slow ssh connections and the like or when I type commands quickly after ESC. Given my typing, there just doesn't seem to be any timing heuristic that reliably differentiates ESC from Meta, and this drove me nuts for years until I enabled a proper meta key. Thanks for any help.