How to get support for '✖' and the like in the Emacs shell buffer?

时光毁灭记忆、已成空白 提交于 2019-12-10 13:49:00

问题


I'm running a process that, on failing error, outputs the character '✖'(as defined in Unicode). However, I don't see the error at all if running the process in an Emacs shell buffer (Aquamacs distro of GNU Emacs).

Using: GNU Emacs 23.3.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54) of 2011-03-18 on braeburn.aquamacs.org - Aquamacs Distribution 2.2

How to get the Emacs shell buffer to support such unicode characters?


回答1:


To tell an individual shell buffer to treat the output from the shell as UTF-8, issue the command C-x RET p, and type "utf-8" when asked "Coding system for output from the process: ". When then asked "Coding-system for input to the process: ", I just type RET; I never provide UTF-8 input directly to the shell.

Alternately, to get this behavior automatically, put (prefer-coding-system 'utf8) in your .emacs file. Actually, that will cause UTF-8 to be used in some other contexts as well, which is what most people would probably want.




回答2:


You could call a function like the following one to create a shell that supports utf-8:

(defun utf8-shell ()
  "Create Shell that supports UTF-8."
  (interactive)
  (set-default-coding-systems 'utf-8)
  (shell))

This sets both input and output to UTF-8 so you can do (for example) the following:

~ $ echo "✖"
✖

If you want to make shell always open with utf-8 support, you can do the following instead:

(defadvice shell (before advice-utf-shell activate)
  (set-default-coding-systems 'utf-8))

(ad-activate 'shell)



回答3:


Have a look to this EmacsForMacOS wiki page.



来源:https://stackoverflow.com/questions/6668580/how-to-get-support-for-and-the-like-in-the-emacs-shell-buffer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!