关闭 Emacs 空白模式“长行”可视化

发布于 2024-11-26 23:11:14 字数 293 浏览 6 评论 0原文

我个人将所有行控制在 80 个字符以内,但我也在其他程序员不关心行长度的团队中工作。

我喜欢使用空白模式,但是当我正在处理不应该干扰长线的项目时,长线可视化真的很烦人。似乎关闭长线可视化应该很容易——我点击了 mx global-whitespace-toggle-options l,然后可以点击 mx global-whitespace-toggel- options ? 确认“长线可视化”已关闭。但长线仍然突出显示。我杀死缓冲区并重新加载它们,突出显示仍然存在。我肯定使用全局的,而不是本地的空白模式。

为什么我无法关闭长线可视化?

I personally keep all lines under 80 characters, but I also work on projects in teams where other programmers don't care about line length.

I love using whitespace-mode, but the long line visualization is really annoying when I'm working on projects where I shouldn't interfere with the long lines. It seems like it should be easy to turn off the long line visualization---I hit m-x global-whitespace-toggle-options l, and then can hit m-x global-whitespace-toggel-options ? to confirm that the "long-line visualization" is turned off. But long lines are still highlighted. I kill buffers and reload them, and highlighting is still there. I'm definitely using global, not local, whitespace-mode.

Why can't I turn off the long line visualization?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

长安忆 2024-12-03 23:11:14

上次自定义 whitespace-mode 时,我注意到我对设置的更改对已存在的缓冲区没有任何影响;尝试重新创建缓冲区,或者退出并重新进入空白模式。如果您还不知道,您可以使用 Mxcustomize-groupwhitespace 完全关闭该特定选项,而不是手动执行此操作。

编辑:具体来说,您想要自定义 whitespace-style 变量。这使您可以打开和关闭单独的样式。在这种情况下,您应该关闭标有“(面部)线条”和“(面部)线条,仅过长部分”的标签。前者在线过长时改变整条线的面,而后者仅改变延伸超过阈值的部分的面。

(该组中的其他选项定义 whitespace-mode 将用于突出显示您已打开的样式的面孔、用于识别某些情况的正则表达式等,但通常您只关心 <代码>空白样式)。

The last time I customized whitespace-mode, I noticed that my changes to the settings didn't have any effect in buffers that already existed; try recreating the buffer, or leaving and reentering whitespace-mode. In case you don't already know, you can use M-x customize-group whitespace to turn off that particular option entirely, rather than doing it manually.

Edit: Specifically you want to customize the whitespace-style variable. This lets you turn on and off individual styles. In this case you should turn off the ones labelled "(Face) Lines" and "(Face) Lines, only overlong part". The former changes the face of the whole line when it is overly long, while the latter only changes the face of the part that extends past the threshold.

(Other options in this group define the faces that whitespace-mode will use to highlight the styles you've turned on, the regexes it uses to identify certain situations, etc, but usually you only care about whitespace-style).

z祗昰~ 2024-12-03 23:11:14

将whitespace-line-column 设置为更高的值(默认为80),这样长行的突出显示就不会生效:

(setqwhitespace-line-column 250)

Set whitespace-line-column to a higher value (default is 80), so the highlighting of long lines doesn't kick in:

(setq whitespace-line-column 250)

我也只是我 2024-12-03 23:11:14

我假设您已经在 init.el 或类似文件中的某个位置激活了 whitespace-mode。如果是这样,您可以改编 duma上面的注释,或者

  • 编辑 elisp设置whitespace-style来删除lines-tail。例如,Emacs Prelude

    (setq 空白样式'(面制表符空尾行-tail))

    只需将其更改为

    (setq whitespace-style '(face tabs empty Trailing))

  • 如果您不想直接编辑该 elisp,而是想覆盖稍后使用您自己的代码,执行类似的操作

    (setq 空白样式(删除 'lines-tail 空白样式))

    不幸的是,如果使用自动加载的缓冲区运行 Prelude(使用类似 Emacs Desktop),初始设置将优先:对于您希望显示 whitespace-style 的每个缓冲区按照指示,您必须[1]

    1. 终止缓冲区
    2. 重新打开缓冲区

[1]:请注意OP:如果有其他方法可以重新加载缓冲区,请编辑或评论此答案。我希望找到类似 Mx reload-buffer 的东西,但我没有看到 Ch a buffer 类似的东西。

I'm assuming that you already have whitespace-mode activated somewhere in your init.el or similar. If so, you can adapt duma's comment above, and either

  • Edit the elisp that sets whitespace-style to remove lines-tail. E.g., Emacs Prelude sets

    (setq whitespace-style '(face tabs empty trailing lines-tail))

    Simply change that to

    (setq whitespace-style '(face tabs empty trailing))

  • If you don't want to directly edit that elisp, but rather override it later with your own code, do something like

    (setq whitespace-style (delete 'lines-tail whitespace-style))

    Unfortunately, if running Prelude with auto-loaded buffers (using something like Emacs Desktop), the initial setting will take precedence: for each buffer on which you want to see whitespace-style displayed as directed, you must [1]

    1. kill the buffer
    2. re-open the buffer

[1]: Note to OP: if there's another way to reload a buffer, please edit or comment this answer. I was hoping to find something like M-x reload-buffer but am not seeing anything like that with C-h a buffer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文