【问题标题】:emacs identation works only in terminal (-nw)emacs 标识仅适用于终端(-nw)
【发布时间】:2011-05-26 11:47:57
【问题描述】:

我在 Ubuntu 10.10 上有 GNU Emacs 23.1.1。

我必须关注 .emacs:

(custom-set-variables
  '(cua-mode t nil (cua-base))
  '(inhibit-startup-screen t)
)

(show-paren-mode 1)
(setq show-paren-delay 0)

;; perl mode stuff
(fset 'perl-mode 'cperl-mode)
(setq cperl-indent-level 4
      cperl-close-paren-offset -4
      cperl-continued-statement-offset 0
      cperl-indent-parens-as-block t
      cperl-tab-always-indent t
      cperl-invalid-face nil
)

当我执行$ emacs -nw 时,制表符缩进效果很好。当我使用 $ emacs 启动 GUI 版本时,标签缩进不起作用。我只得到空格缩进。

如何在 GUI 中也获得制表符缩进?

cperl conf 取自 emacswiki

我拥有的 emacs 包:

$ dpkg -l | grep emacs
ii  emacs                                23.1+1-4ubuntu7.2+maverick1                       The GNU Emacs editor (metapackage)
ii  emacs-goodies-el                     33.6ubuntu1                                       Miscellaneous add-ons for Emacs
ii  emacs-snapshot                       1:20090909-1                                      The GNU Emacs editor (development snapshot)
ii  emacs-snapshot-bin-common            1:20090909-1                                      The GNU Emacs editor's shared, architecture dependent files
ii  emacs-snapshot-common                1:20090909-1                                      The GNU Emacs editor's common infrastructure
ii  emacs23                              23.1+1-4ubuntu7.2+maverick1                       The GNU Emacs editor (with GTK+ user interface)
ii  emacs23-bin-common                   23.1+1-4ubuntu7.2+maverick1                       The GNU Emacs editor's shared, architecture dependent files
ii  emacs23-common                       23.1+1-4ubuntu7.2+maverick1                       The GNU Emacs editor's shared, architecture independent infrastructure
ii  emacsen-common                       1.4.19ubuntu1                                     Common facilities for all emacsen

编辑:抱歉,我只是注意到我没有正确研究这种行为。在 gui 和 -nw 中,当我编辑一个已在制表符中缩进的文件时,它使用制表符,而当我编辑一个新文件时,它用空格缩进。

【问题讨论】:

  • C-h w <TAB> 的结果是什么?
  • @kindahero:在 GUI 中对吗?结果是“命令在哪里”的提示和可能的命令列表(我猜是由于
  • 对不起,那应该是C-h k <TAB>(C-h k 告诉你“命令”通过按键运行)
  • @kindahero 嗯,好像有什么东西。在 GUI 中 indent-for-tab-command 在 -nw forward-button 中。虽然看到我的编辑我犯了一个错误。

标签: emacs indentation emacs23 cperl-mode


【解决方案1】:

首先,在启动时检查*Messages**Warnings* 缓冲区。可能会有关于那里失败的提示。特别是,*Messages* 应该列出 emacs 正在加载的所有启动文件;在 Ubuntu 上,这将包括 /etc/emacs 以及您的 .emacs 中的文件。

如果这没有帮助,请尝试在 emacs 调试器中以交互方式运行您的 .emacs。使用 emacs -nw -q 启动 emacs 并将 .emacs 加载到缓冲区中。运行 M-x edebug-all-forms 然后运行 ​​M-x eval-buffer。反复按空格键可逐步浏览文件。

编辑:在两个环境的 perl 缓冲区中检查 indent-tabs-mode 的值。这用于控制是否使用制表符或空格缩进。添加(setq-default indent-tabs-mode t) 应该会强制emacs 使用制表符缩进。

【讨论】:

  • *Messages*: 没有任何可疑之处(全部为done)。我没有*Warnings* 缓冲区,我找不到如何打开它。我也尝试了其他的东西,但是调试器报告了每个命令返回的内容并愉快地完成了。
  • 我在;; perl mode stuff 之前添加了(setq-default indent-tabs-mode t),但它并没有改变任何东西。但是,请参阅我的编辑以了解我所犯的错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-28
  • 2021-06-02
  • 2014-02-22
  • 2018-12-03
  • 2012-04-20
  • 1970-01-01
  • 2014-10-27
相关资源
最近更新 更多