encoding issues with emacs - beginner

Hello all!

I don't know, how to resolve the following problem (I am an emacs beginner): I am using tcsh - Shell, my "Windows settings" of my Terminal are set to unicode (utf-8). But I am unable to enter German Umlauts with my keyboard, when using emacs (MBP, 17 inch, one year old, 10.4.11) - instead of inserting the special letters for example "ö ä ü" emacs is jumping on a different place of the file and inserting nothing! It is not depending of the file which I am "visiting". Whether it is saved in utf-8 or in Latin 1. Probably I have to set the encodings in the ~/.emacs starting file, but the two books for emacs (both O'Reilly) don't help, to set up the encoding!!! One book is very fat, and no chapter about encoding!!!

Meanwhile I found: making C-h C <ENTER> I may guess what is missing: I have to enter the order of my still undefined encodings. emacs is saying this:

Default coding system (for new files):
nil
Coding system for keyboard input:
nil
Coding system for terminal output:
nil # But here I am sure it is set to utf-8!
Defaults for subprocess I/O:
decoding: - -- undecided (alias: unix dos mac)
encoding: 1 -- iso-latin-1 (alias: iso-8859-1 latin-1)

Priority order for recognizing coding systems when reading files:
1. iso-latin-1 (alias: iso-8859-1 latin-1)
2. iso-2022-jp (alias: junet)
3. iso-2022-7bit
4. iso-2022-7bit-lock (alias: iso-2022-int-1)
5. iso-2022-8bit-ss2
6. emacs-mule
7. raw-text
8. japanese-shift-jis (alias: shift_jis sjis)
9. chinese-big5 (alias: big5 cn-big5)
10. no-conversion (alias: binary)
11. mule-utf-8 (alias: utf-8)

Please, could somebody be so kind, to help me with this?

One other question again: I am unable to find in my two emacs-books an answer: is it possible to have a syntax-highlighting with different colours in emacs for xml/html, Perl, LaTeX ... ???

Thank you all and best greetings from Munich

marek

MBP 17

Posted on Jan 10, 2008 11:34 AM

Reply
11 replies
Sort By: 

Jan 10, 2008 8:32 PM in response to Marek Stepanek

The first question is, which emacs are you using?

If it the one that comes with the computer, and you're running it in Terminal.app (i.e., without any gui), that one may be crippled. I'd suggest downloading and installing Aquamacs Emacs, or one of the other ones that uses Apple's Aqua/Finder etc.
Reply

Jan 10, 2008 9:19 PM in response to Don MacQueen1

Thank you Don MacQueen1 for your prompt answer!

marekste% which emacs
which emacs
/usr/bin/emacs
marekste% emacs --version
emacs --version
GNU Emacs 21.2.1

Probably this is an old version? But could somebody tell me nevertheless, how to set the default encoding to utf-8 in my ~/.emacs start file?


thank you



marek


ps: and my second question: syntax-colouring possible with emacs! please! 🙂
Reply

Jan 12, 2008 12:37 AM in response to Don MacQueen1

Thank you Don MacQueen1


I know Aquamacs. I will explain you, why I want the "original" emacs: to learn emacs in the shell, I don't want to have a rescue to Apple short cuts. I will not learn emacs like that, because I am too lazy. I will use Apple + S to save the file, and when I am on a Unix machine - which will probably never happen! - I will be lost. Later having all real emacs short cuts in the fingers, I may switch to Aquamacs, just for the syntax colouring.

So my two questions are still open:

1. How to set the default encodings in the ~/.emacs start file?
2. Is syntax colouring possible with emacs?

Which books you would recommend, to learn emacs? "Learning emacs" from O'Reilly has 500 pages and does not cover these questions 😟



greetings from Munich



marek
Reply

Jan 12, 2008 9:18 AM in response to Marek Stepanek

Ok! I made some progress my the Encoding troubles:

I insert some Umlauts in my file with BBEdit. I open this file with emacs and see some funny letters instead of my entered German Umlauts. Than I am doing the following command:

C-x <RET> r utf-8 <RET>

That means "revisit" the file, or reopen it using the encoding utf-8. Now the Umlauts are displayed fine.

But now comes the catastrophe: to choose an Input Method I discovered in the extensive help of Aquamacs - yes yes I downloaded it, and it was useful! - I have to enter the following command:

C-h C-\ METHOD <RET>

And here it comes: *I am unable to write an backslash with Control Key*

First: my System language is English, but my keyboard layout is normally German. But sometimes I am using French, Russian keyboard layout too. Ok! I am opening the Keyboard Viewer. But nevertheless which keyboard layout I have chosen, the \ Backslash is disappearing, when pushing the control key!

the backslash I get:
On German keyboard: Shift + Alt + 7 (Shift + Alt + Ctrl there is nothing!)
on US Keyboard : just over the right Shift and the <enter> (but pushing the Ctrl the backslash is disappearing!)
On Cyrillic Keyoard there seems to be a backslash, just were is the American, whith ALT + Ctrl but Aquamacs is reading the underlying ё and Aquamacs complains the C-h C-M-ё is not defined.

So if I see well I will never be able to work with emacs, being unable to put the escape (=\) in front of special characters in a regex

Hi, Mac-people out there, are some of you really working with emacs??? Or do I have to buy an Unix-Machine ?



Thank you again


ps: Aquamacs has nice syntax colouring 🙂
Reply

Jan 12, 2008 9:19 PM in response to Marek Stepanek

OK, sorry to be so pesky about the Aquamacs version. I am actually like you, in that I prefer the unix-style emacs to the mac-style emacs.

I normally use emacs in a version that understands X windows, and that version also comes with syntax coloring. I use it a lot, every day at work.

In it I am able to enter
C-h C-

at which point the entry thing at the bottom of the window says:
Describe input method (default current choice):


So I suppose it is a more "true" version of emacs.


macq[1]% which emacs
/sw/bin/emacs


This I obtained from the Fink project. Which is supposed to be found at
http://fink.sourceforge.net/www.finkproject.org/index.php
but there is some sort of problem, and that website is not coming up.

I believe there are other places to obtain an X windows enabled version of emacs, other than fink, that is. However, I'm not up to date on that. Perhaps the GNU Emacs website itself, at http://www.gnu.org/software/emacs/
Reply

Jan 13, 2008 2:16 AM in response to Don MacQueen1

I obtained gnu emacs from there:

http://www.gnu.org/software/emacs/
http://ftp.gnu.org/pub/gnu/emacs/

and I installed it into my /usr/ tree not into the /sw

Now I have the actual GNU Emacs 22.1.1

First surprise: the "Shell"-emacs is showing syntax-colouring 🙂 The Carbon Application accepts Backslashes (Aquamacs not!).

Making my first tries with regex searches I discover, that apparently the \s for any white space is not implemented in emacs? What's that? So to search : beginning of line, some white spaces followed by one or more digits, I do the search:

C-M-s <ret>
^ [0-9]

(how do I repeat the search, to find the next occurrence??? please???) in the search pattern the \d+ for one ore more digits is not working either. Why?

Don't know, whether I really will continue with emacs. It is hard to understand, what is going on here. And the implemented regex-machine uses only the half of the vocabulary I have learned with Perl and BBEdit ??? Please correct me! (Probably this is still an issue with the encoding and the backslash???)



greetings to all


marek

Message was edited by: Marek Stepanek
Reply

Jan 13, 2008 9:04 PM in response to Marek Stepanek

"(how do I repeat the search, to find the next occurrence??? please???)"

Repeat the keystrokes that started the search, i.e. M C-s

(I found that I needed to use rectangular brackets, i.e.
[0-9]
)

Yes, emacs is a challenge to learn. I have a book that I have found useful. I think it's called "Learning GNU Emacs", but unfortunately I have it at work, not here at home, so I can't verify. Regardless, there is in fact a book by that title: http://www.oreilly.com/catalog/gnu3/

It's my understanding that there are at least two variants of regular expression syntax out there, which of course makes it difficult if you've already learned one, and then start using software that uses the other. I don't have a solution for that problem!

Message was edited by: Don MacQueen1

Message was edited by: Don MacQueen1
Reply

Jan 13, 2008 9:08 PM in response to Marek Stepanek

"(how do I repeat the search, to find the next occurrence??? please???)"

Actually, you can repeat the search with simply C-s, leaving off the meta. And, once the search is underway, you can also use C-r to search backwards (i.e., reverse or return to a previously found instance of the pattern)
Reply

Jan 16, 2008 5:18 AM in response to Don MacQueen1

Thank you Don MacQueen1 for your helpful hints. I am wondering, whether you are the only emacs user in this group.

To answer myself the question, how to set the default encoding for emacs:

Two possibilities: the Init file name is here

~/.emacs.d/init.el

or there

~/.emacs

I have chosen the first name and put the following in it:

(set-language-environment "utf-8")

(if (fboundp 'blink-cursor-mode)
(blink-cursor-mode 0))

obviously the first statement is setting Unicode utf-8 as default encoding. The second is switching of the silly blinking of the cursor.

Just for the archives: you may find further information in the online help of emacs: search the help files for "init file" ...

thank you again for your answers



marek
Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

encoding issues with emacs - beginner

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.