I have used to pc for developing erlang program, one is mac os x 10.6, the other is mac os x 10.7.
In ".emacs" file of both pc, it contain the following script
;;handle emacs utf-8 input
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
But when I input remark including Chinese characters in one pc and saved, and download to the other pc. The chinese characters can't be shown correctly. The same story for reverse operation.
I want to know how to check the current file's encoding type? Is there any command can do that?
I believe you're looking for buffer-file-coding-system. M-x describe-variable will tell you more about it, and you can set it by M-x eval-expression and use (setq buffer-file-coding-system 'coding-system-i-want). That will set it for a single buffer; once you've got it working, you can add entries to file-coding-system-alist to permanently set the option as you'd like.
you may also set
coding-system-for-write
coding-system-for-read
To modify the coding system in order to to read and write all ‘.txt’ files using the coding system chinese-iso-8bit, you can execute this Lisp expression:
(modify-coding-system-alist 'file "\\.txt\\'" 'chinese-iso-8bit)
For more informations see Recognizing Coding Systems.
Related
I use ansi-term for my normal terminal sessions. I tend to use unicode characters in my prompt to do things like set the trailing character based on the type of source control I'm using.
I use the character "±" as my prompt for git repositories.
In Emacs' ansi-term, my prompt isn't rendered as unicode, and shows as "\302\261". Displaying the current coding system shows that it defaults to utf-8-unix for input to the process, but I get raw binary as the decoding output. I can hit C-c RET p to change the encoding and decoding coding systems. I'm drawing a blank as to how to set this automatically when I start a terminal? I've tried adding to term-mode-hook to set the buffer's coding system to no avail. I think I've found what I'm looking for in term.el, but I don't care to tweak the distribution elisp, and it appears the raw binary was added to fix a bug somewhere else.
EDIT: This was unclear originally. I'm having issues setting the default process coding system for ansi-term running under Cocoa-ized Emacs 23.3 on MacOS. Emacs itself isn't running in a terminal, my terminal is running in Emacs.
The following worked for me:
(add-hook 'term-exec-hook
(function
(lambda ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))))
ansi-term seems to ignore the default-process-coding-system variable, so I had to set it buffer-locally after it executes my shell.
After getting a better understanding of term.el, the following works:
(defadvice ansi-term (after advise-ansi-term-coding-system)
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(ad-activate 'ansi-term)
Trying this with term-mode-hook is broken because in term.el, term-mode-hook is called before switching to the terminal buffer, so set-buffer-process-coding-system breaks due to the lack of a process associated with the buffer.
Try
(set-terminal-coding-system 'utf-8-unix)
That's C-x RET t not C-x RET p.
So C-x RET p helps?
Unless C-h v default-process-coding-system is (utf-8-unix . utf-8-unix) try
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
when using C-x C-f, the filename which includes Chinese characters are shown as following:
How can I configure it to show Chinese words? Thank you.
=====updated=======
System: OS X 10.8.4
Emacs version: GNU Emacs 24.3.1 (x86_64-apple-darwin)
I think this may be caused by one of those annoying interactions between the operating system and Emacs. Emacs doesn't seem to know how to interpret the file names, so let's try to help it by inserting this in your .emacs file.
(setq default-buffer-file-coding-system 'utf-8-unix)
(setq default-file-name-coding-system 'gb2312)
(setq default-keyboard-coding-system 'utf-8-unix)
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
You may need to try a different system instead of gb2312.
I'm new to Emacs/Aquamacs, and want to use it to program in Prolog. My filename ends with ".pl" and Aquamacs automatically assumes it's a Perl file. How do I change it to use Prolog mode instead? I'd prefer an answer that doesn't assume I know how to get around in Emacs at all.
Under Preferences -> Programming -> Languages. I cannot find Prolog, even though the Aquamacs webpage states it's supposed to support Prolog? Do I need to install some addon?
You can activate Prolog mode manually with M-x prolog-mode.
I have the following line in my Emacs configuration file (usually referred to as .emacs, though I personally use the alternative location .emacs.d/init.el) to make it the default for .pl files:
(add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))
I use ansi-term for my normal terminal sessions. I tend to use unicode characters in my prompt to do things like set the trailing character based on the type of source control I'm using.
I use the character "±" as my prompt for git repositories.
In Emacs' ansi-term, my prompt isn't rendered as unicode, and shows as "\302\261". Displaying the current coding system shows that it defaults to utf-8-unix for input to the process, but I get raw binary as the decoding output. I can hit C-c RET p to change the encoding and decoding coding systems. I'm drawing a blank as to how to set this automatically when I start a terminal? I've tried adding to term-mode-hook to set the buffer's coding system to no avail. I think I've found what I'm looking for in term.el, but I don't care to tweak the distribution elisp, and it appears the raw binary was added to fix a bug somewhere else.
EDIT: This was unclear originally. I'm having issues setting the default process coding system for ansi-term running under Cocoa-ized Emacs 23.3 on MacOS. Emacs itself isn't running in a terminal, my terminal is running in Emacs.
The following worked for me:
(add-hook 'term-exec-hook
(function
(lambda ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))))
ansi-term seems to ignore the default-process-coding-system variable, so I had to set it buffer-locally after it executes my shell.
After getting a better understanding of term.el, the following works:
(defadvice ansi-term (after advise-ansi-term-coding-system)
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(ad-activate 'ansi-term)
Trying this with term-mode-hook is broken because in term.el, term-mode-hook is called before switching to the terminal buffer, so set-buffer-process-coding-system breaks due to the lack of a process associated with the buffer.
Try
(set-terminal-coding-system 'utf-8-unix)
That's C-x RET t not C-x RET p.
So C-x RET p helps?
Unless C-h v default-process-coding-system is (utf-8-unix . utf-8-unix) try
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
I'm trying to use Emacs and everything is fine, but the information about every file in my directory is too comprehensive. How can I tell it to show only file name (and maybe filesize in human readable format)? I tried options like dired-listing-switches but without any luck.
As of Emacs 24.4, hit key (.
Repeated, this will hide/unhide details. This is part of Dired Details.
You can reduce the amount of information displayed by using Emacs' ls emulation instead of allowing it to use ls directly.
To enable ls emulation, add the following code to your startup file (probably .emacs or .emacs.d/init.el):
(require 'ls-lisp)
(setq ls-lisp-use-insert-directory-program nil)
You can then customise the display with M-x customize-group RET ls-lisp RET. Specifically, the "Ls Lisp Verbosity" setting can be used to disable a number of columns. There's no obvious way to get it down to just the filename and size, but you can certainly get rid of the owner/group/link-count columns.
Great news, a more efficient version of DiredDetails is in the master branch of Emacs now; it uses text properties instead of overlays..
I looked for it because DiredDetails' reliance on overlays made it too slow for one find-dired result set.
I'm not sure if it'll be in 24.3 or 24.4. Get the raw file here: http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/dired.el
also, to show file sizes in human-readable format (kB/MB), add this to your .emacs:
(setq-default dired-listing-switches "-alh")