Emacs的Python模式语法高亮 [英] Emacs Python-mode syntax highlighting

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

问题描述

我在Ubuntu 10.04桌面计算机上安装了GNU Emacs 23(包 emacs23 ),并且包 emacs23-nox 安装在Ubuntu 10.04无头服务器上(未安装X)。两个安装都具有相同的〜/ .emacs 文件。我在两台电脑上运行了 -nw 的Emacs。我没有在任一机器上安装 python-mode ,因为我的理解是这包含在Emacs 23中。

I have GNU Emacs 23 (package emacs23) installed on an Ubuntu 10.04 desktop machine and package emacs23-nox installed on an Ubuntu 10.04 headless server (no X installed). Both installations have the same ~/.emacs file. I run Emacs with -nw on both computers. I don't have python-mode installed on either machine as my understanding is that this is included in Emacs 23.

在台式机上,Python中的注释(以开头)以红色突出显示。在服务器上,注释以纯文本形式显示,如所有其他未突出显示的文本。关于为什么在服务器( nox )安装时没有正确突出评论的建议?

On the desktop machine, comments in Python (starting with #) are highlighted in red. On the server, comments appear in plain white text like all other non-highlighted text. Any suggestions as to why comments are not being highlighted correctly on the server (nox) installation?

更新:这似乎是与终端有关的问题。从终止者通过屏幕替换 ssh 进入服务器机器 byobu 。如果我使用 TERM =xterm-256coloremacs 在服务器上运行emacs,那么注释将突出显示,但所有其他颜色看起来都很奇怪。

Update: This appears to be a terminal-related issue. I ssh into the server machine from terminator via the screen replacement byobu. If I run emacs on the server with TERM="xterm-256color" emacs, then comments are highlighted, but all the other colours look very strange.

更新:添加export TERM =xterm-256color已解决现在的语法高亮现在有非常奇怪的颜色:紫色淡紫色和浅棕色。我现在的绿色线条亮点条现在是淡淡的淡黄色/绿色。注释以红色突出显示:)

Update: Adding `export TERM="xterm-256color" "solved" this. The syntax highlighting now has very strange colours though: purples lilacs and light browns. My green current line highlight bar is now a light pale yellow/green. Comments are highlighted in red though :)

更新:已解决。设置 TERM =xterm-color code>产生正确颜色,包括注释。服务器默认为 TERM 的值screen-bce,而不突出显示注释。

Update: Solved. Setting TERM="xterm-color" produces "proper" colors, including highlighting of comments. The server was defaulting to a value of "screen-bce" for TERM which was not highlighting comments.

Update:Unsolved。 byobu 为各种功能键提供了键盘绑定,可以轻松创建新的屏幕会话并在它们之间切换。当 TERM 设置为 xterm-color 时,这些功能键不再有效。所以我想我只需要在Emacs的Python代码中看到不高兴的评论。

Update: Unsolved. byobu provides keybindings for various function keys to easily create new screen sessions and switch between them. When TERM is set to xterm-color, these function keys no longer work. So I guess I'll just have to be happy with unhighlighted comments in Python code in Emacs.

推荐答案

对于我运行 emacs -nw byobu TERM = xterm 产生正确语法高亮的颜色(python和bash中的注释都不仅仅是#),功能键也可以工作。注意我设置 TERM 作为运行emacs的别名的一部分,而不是一般在 .bashrc 中设置:

For me running emacs -nw from inside byobu with TERM=xterm produced the correct colours for syntax highlighting (the comments in python and bash are all red not just the #) and the function keys work. Note I set TERM as part of an alias for running emacs rather than setting it generally in .bashrc:

alias emacs ='TERM = xterm; emacs -nw'

另请参阅这篇文章:终端emacs颜色只能使用TERM = xterm-256color

这篇关于Emacs的Python模式语法高亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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