【问题标题】:How can I load highlight-lines-matching-regexp automatically in emacs?如何在 emacs 中自动加载 highlight-lines-matching-regexp?
【发布时间】:2013-08-16 21:59:47
【问题描述】:

我用

突出显示超过 80 个字符的行
M-x highlight-lines-matching-regexp RET .\{81\} RET hi-yellow RET

我希望 emacs 自动为我的所有缓冲区启用此功能。

我试过了

(add-hook 'after-load-functions
          '(lambda () ('highlight-lines-matching-regexp ".\{81\}" 'hi-yellow)))

How can I make emacs highlight lines that go over 80 chars? 中所写,但它不起作用。它说

run-hook-with-args: Wrong number of arguments: (lambda nil (highlight-lines-matching-regexp ".{81}" (quote hi-yellow))), 1

我如何告诉 emacs 自动将它应用到我的所有缓冲区?

【问题讨论】:

    标签: emacs hook highlight lines


    【解决方案1】:

    你犯了两个错误:

    1) 在highlight-lines-matching-regexp 之前有一个额外的'
    2) after-load-functions 不是正确的钩子(从某种意义上说,它会将参数传递给与after-load-functions 挂钩的函数)

    你应该使用这个(或者类似的钩子,你可以在the reference找到一个不完整的钩子列表):

    (add-hook 'change-major-mode-hook '(lambda () (highlight-lines-matching-regexp ".\\{81\\}" 'hi-yellow)))
    

    假设您只希望在编程模式下使用此功能,您可能希望使用 prog-mode-hook 而不是 change-major-mode-hook(这只适用于 emacs 版本 >= 24)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      • 2014-02-26
      • 2015-04-11
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      相关资源
      最近更新 更多