[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8122: 23.2.94; (prefer-coding-system 'utf-8) changes indentation beh

From: Eli Zaretskii
Subject: bug#8122: 23.2.94; (prefer-coding-system 'utf-8) changes indentation behavior for emacsclient
Date: Sat, 26 Feb 2011 18:40:32 +0200

> Date: Sat, 26 Feb 2011 09:31:16 -0500
> From: Steve Revilak <address@hidden>
> Cc: 
> (1) Start emacs in daemon mode, as follows:
>      env TMPDIR=$HOME/tmp emacs  -Q --eval "(prefer-coding-system 'utf-8)" 
> --daemon
> (2) Use emacsclient to connect to the server started in step (1),
>      editing a new text file.
>      rm -f a.txt
>      env TMPDIR=$HOME/tmp emacsclient a.txt
> (3) In the buffer for a.txt, type the lines that appear below.  Do not
>      press return after typing "ccc"
> aaa
> bbb
>    ccc
> (4) With point at the end of line "ccc", press RETURN.  If "ccc"
>      appeared in line 5 of the buffer, then the cursor will appear at
>      line 6, column 2.  
> Expected behavior: after pressing RETURN, the cursor should have
> appeared line line 6, column 0.

I found the reason for this: when keyboard-coding-system is utf-8,
typing RET is decoded as C-j.  If you start the Emacs daemon like

 emacs  -Q --eval "(prefer-coding-system 'utf-8-unix)" --daemon
the problem goes away.

This happens because, unlike set-keyboard-coding-system, which adds
"-unix" to its argument, we don't do the same when we set up

(This problem is quite old; I guess no one used
default-keyboard-coding-system until the change I made in terminal.c
exposed this bug.)

I propose the following change to fix this:

--- lisp/international/mule-cmds.el~0   2011-01-08 12:45:14.000000000 -0500
+++ lisp/international/mule-cmds.el     2011-02-26 11:32:22.483284753 -0500
@@ -368,7 +368,8 @@
                 (coding-system-get coding-system 'ascii-compatible-p)))
        (setq default-file-name-coding-system coding-system)))
   (setq default-terminal-coding-system coding-system)
-  (setq default-keyboard-coding-system coding-system)
+  (setq default-keyboard-coding-system
+       (coding-system-change-eol-conversion coding-system 'unix))
   ;; Preserve eol-type from existing default-process-coding-systems.
   ;; On non-unix-like systems in particular, these may have been set
   ;; carefully by the user, or by the startup code, to deal with the

reply via email to

[Prev in Thread] Current Thread [Next in Thread]