【问题标题】:How do I set up Emacs colors correctly?如何正确设置 Emacs 颜色?
【发布时间】:2013-11-15 19:17:03
【问题描述】:

我设置了两个版本:

My computer      apt-get   emacs 23.0.91
Remote server    yum       emacs 21.4

我已经下载了 color-theme-6.6.0,将文件放在 /usr/share/emacs/-version-/lisp/ 中,我的 .emacs 中有这个:

(require 'color-theme)
(color-theme-initialize)
(color-theme-midnight)

在终端中运行 emacs,所有颜色在我的计算机上都正确显示,但在服务器上,我只得到两种颜色???背景是一种颜色,文字是另一种颜色,无论我选择什么主题。启动 emacs 时没有出现错误。

有什么建议吗?

【问题讨论】:

    标签: emacs colors color-scheme


    【解决方案1】:

    转述自Unix and Color Highlighting

    为了能够在 Unix/Linux 机器上使用语法高亮,您需要一个支持颜色的终端。某些系统(对我来说是 AIX)需要由 tic 在 xterm-color.tic 文件上生成的 TERMINFO 文件。这是一个片段:

     setenv TERMINFO /home/cfl/lib/terminfo
     tic xterm-color
     setenv TERM xterm-color
    

    再次阅读Unix and Color Highlighting 文章了解所有详细信息。


    另一方面,这是我的 .emacs 文件包含的用于设置颜色(在深色背景上)的内容。

    ;; Maximum colors
    (setq font-lock-maximum-decoration t)
    
    (setq frame-background-mode 'dark)
    
    (setq auto-mode-alist '(("\\.ad[bs]\\'"   . ada-mode)
                            ("\\.awk\\'"      . awk-mode)
                            ("\\.lex\\'"      . c-mode)
                            ("\\.[cy]\\'"     . c++-mode)
                            ("\\.h\\'"        . c++-mode)
                            ("\\.hxx\\'"      . c++-mode)
                            ("\\.[CH]\\'"     . c++-mode)
                            ("\\.java\\'"     . java-mode)
                            ("\\.cc\\'"       . c++-mode)
                            ("\\.hh\\'"       . c++-mode)
                            ("\\.cxx\\'"      . c++-mode)
                            ("\\.cpp\\'"      . c++-mode)
                            ("\\.rc\\'"       . c++-mode) ;; resource files
                            ("\\.rcv\\'"      . c++-mode)
                            ("\\.m\\'"        . matlab-mode)
                            ("\\.p[lm]\\'"    . perl-mode)
                            ("\\.cgi\\'"      . perl-mode)
                            ("\\.f\\'"      . fortran-mode)
                            ("\\.F\\'"      . fortran-mode)
                            ("\\.f90\\'"      . f90-mode)
                            ("\\.F90\\'"      . f90-mode)
                            ("\\.el\\'"       . emacs-lisp-mode)
                            ("\\.emacs\\'"    . emacs-lisp-mode)
                            ("\\.tex\\'"      . LaTeX-mode)
                            ("\\.bib\\'"      . bibtex-mode)
                            ("[Mm]akefile\\'" . makefile-mode)
                            ("\\.mak\\'"      . makefile-mode)
                            ("\\[Mm]akefile.\\'" . makefile-mode)
                            ("\\.bat\\'"      . shell-script-mode)
                            ("\\.tar\\'"      . tar-mode)
                            ("\\.php\\'"     . php-mode)
                            ("\\.html\\'"     . html-mode)
                            ("\\.jnlp\\'"     . html-mode)
                            ("\\.xml\\'"     . html-mode)
                            ("\\.pddl\\'"     . lisp-mode)
                            ("\\.css\\'"      . css-mode)
                            ("\\.py\\'"       . python-mode)
                            ("\\.yml\\'"      . yaml-mode)
                            ("\\.lisp\\'"     . lisp-mode)))
    

    【讨论】:

      【解决方案2】:

      你需要像这样设置环境变量TERM(假设是bash shell):

      导出 TERM="xterm-256color"

      如果您在屏幕内运行 emacs,则必须将以下内容添加到您的 .screenrc 中。

      term screen-256color

      如果这不起作用,可能是因为您的系统没有安装适当的 termcap。例如,在 deb/ubuntu 系统上,您必须:

      apt-get install ncurses-term

      我不确定是否使用基于 rpm 的系统,但请确保已安装 ncurses 和 termcap。

      【讨论】:

        【解决方案3】:

        使用http://www.fleiner.com/vim/xterm-color.tic

        在 AIX 上:

        su -
        tic xterm-color.tic
        alias emacs='TERM=xterm-color emacs'
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-03-17
          • 2013-11-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多