emacs 术语模式中的 Unicode 字符 [英] Unicode characters in emacs term-mode

查看:20
本文介绍了emacs 术语模式中的 Unicode 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在正常的终端会话中使用 ansi-term.我倾向于在提示中使用 unicode 字符来执行诸如根据我使用的源代码管理类型设置尾随字符之类的操作.

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.

我使用字符±"作为 git 存储库的提示.

I use the character "±" as my prompt for git repositories.

在 Emacs 的 ansi-term 中,我的提示未呈现为 unicode,而是显示为302261".显示当前的编码系统表明它默认为 utf-8-unix 作为进程的输入,但我得到原始二进制作为解码输出.我可以按 C-c RET p 来更改编码和解码编码系统.我对如何在启动终端时自动设置这个问题一无所知?我已经尝试添加到 term-mode-hook 来设置缓冲区的编码系统无济于事.我想我已经在 term.el 中找到了我要找的东西,但我不想调整发行版 elisp,而且似乎添加了原始二进制文件是为了修复其他地方的错误.

In Emacs' ansi-term, my prompt isn't rendered as unicode, and shows as "302261". 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.

这最初不清楚.我在为 MacOS 上的 Cocoa-ized Emacs 23.3 下运行的 ansi-term 设置默认进程编码系统时遇到问题.Emacs 本身不在终端中运行,我的终端在 Emacs 中运行.

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.

推荐答案

在对term.el有了更深入的了解后,如下工作:

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)

term-mode-hook 尝试这个是坏的,因为在 term.el 中,term-mode-hook 在切换到终端缓冲区之前被调用,所以 set-buffer-process-coding-system 由于缺少与缓冲区关联的进程而中断.

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.

这篇关于emacs 术语模式中的 Unicode 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆