Subject: bug#5235: 23.1; Unibyte keyboard input problem

From: Eli Zaretskii <[email-masked]>
Date: Fri, 18 Dec 2009 11:46:09 +0200

> From: Tomasz Zbrożek <[email-masked]>
> Date: Thu, 17 Dec 2009 20:25:58 +0100
> Cc: [email-masked], [email-masked]
> 
> I'll try to explain why I need unibyte mode. I'm maintener of a C/C++ source 
> code which has comments coded in cp1250 (polish language) but strings in code 
> are coded in cp852. So I have two different code pages in source code file. 
> This is old source code and it was developed in Windows (that's why comments 
> are in cp1250) but is compiled to work on MS-DOS (that's why strings are 
> coded in cp852).

So when you visit this file in "emacs --unibyte", the cp852 strings
look like gibberish, right?  Only the cp1250 comments are displayed
correctly, right?

> Of course in multibyte mode I am able to write in these code 
> pages (for example reloading file with C-x RET r) but when I select cp1250 to 
> save the buffer emacs often tells me that some cp852 coded chars are not able 
> to be saved in cp1250 and it wants me to select between raw-text, 
> no-conversion and emacs-mule. In this situation I have to enter "cp1250" and 
> force Emacs to save buffer in cp1250. So I do not want to write "cp1250" 
> again and again when saving buffer to file..

You can put a coding: cookie in the file that forces Emacs to use
cp1250 without asking any questions.  In the first line of the file
(in a comment) put this:

                  -*-coding: cp1250 -*-

Alternatively, add "coding: cp1250" to the file's Local Variables
section at the end.

> And additionaly I'm not sure 
> when I force to save my buffer in cp1250 what's going on exactly with cp852 
> coded chars (I noticed both cp1250 and 852 chars are coded ok). 

So saving in cp1250 doesn't do anything bad with cp852-encoded
characters, right?  It shouldn't, IMO.

> That's why I decided to use unibyte mode.

Is that only because of those annoying questions in what encoding to
save?  Of are there other problems in multibyte mode that forced you
to use --unibyte?

> In fact I what to change mode when Emacs works, I mean not with --unibyte but 
> with set-buffer-multibyte to nil when cpp file is being loaded but it seems 
> this function does not work correctly or I do not undestand something.

Try visiting file with raw-text encoding:

   C-x RET c raw-text RET C-x C-f YOUR-CPP-FILE RET