【问题标题】:Commented string to fix emacs ruby mode highlighting注释字符串以修复 emacs ruby​​ 模式突出显示
【发布时间】:2013-02-10 06:04:02
【问题描述】:

有时,文本编辑器为语法高亮所做的解析并不准确。经常发生在 ruby​​ 模式中引入 heredoc 会混淆 emacs 上的语法突出显示,如 this question。我对这种情况有疑问:

<<_
  some here doc content
  ...
  last line of the intended heredoc
_
this_ruby_code_line_and_any_line_after_it_is_highlightened_as_part_of_heredoc

我不希望为此修复 emacs ruby​​-mode,但是为了重置突出显示问题,我通常可以在 heredoc 和以下 Ruby 代码之间放置某种注释字符串吗?当我遇到的问题不是heredoc,而是时髦的字符串文字(尤其是那些包括引号的文字)时,有时会放置一个带注释的字符串,例如

#"'`

在行尾解决了这个问题。有没有这样的东西可以解决heredoc的问题,还有,有没有更通用的字符串?

【问题讨论】:

  • 虽然我无法在我的 emacs 安装中重现该错误,但我建议对符号使用“关闭”的东西,这会导致问题。在你的情况下,这可能就像#_&gt;&gt;.
  • 对不起我的懒惰。我喜欢阅读 Ruby 或 PCRE 中的正则表达式,但我没有足够的精力深入研究 ruby​​-mode.el 并阅读 emacs lisp 中的正则表达式。
  • @mudasobwa 谢谢,但没用。

标签: ruby emacs comments syntax-highlighting


【解决方案1】:

在 Emacs 主干构建中对我来说很好。

尝试更新的 Emacs 版本(我很确定这适用于即将发布的 24.3 版本,但也可能适用于当前版本)和/或确保您使用的是与 Emacs 捆绑的 ruby-mode,而不是通过 ELPA 等安装:

ELISP> (require 'which-func)
which-func
ELISP> (find-library-name "ruby-mode")
"/home/gutov/emacs-bzr/trunk/lisp/progmodes/ruby-mode.el"

【讨论】:

  • 谢谢,我升级到emacs 24,问题解决了。
猜你喜欢
  • 2016-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-23
  • 2010-10-08
  • 1970-01-01
  • 2010-09-24
  • 2012-05-15
相关资源
最近更新 更多