Emacs:将writeroom模式设置为默认值 [英] Emacs: Set writeroom mode as default

查看:430
本文介绍了Emacs:将writeroom模式设置为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是emacs的新手,我想知道如果我可以将writeroom模式设置为始终处于开启状态。我想要它启动时,我启动emacs,当我打开新的缓冲区或切换它们之间。

I am new to emacs and I am wondering if I can set the writeroom-mode to always be on. I want it to be on as I start up emacs and as I open new buffers or switch between them.

所有的帮助是非常感谢!

All help is highly appreciated!

推荐答案

所以现在你提供了一个链接(尽管在您的其他问题),我可以看到,库提供了一个全局小模式,它只适用于特定可配置的主要模式集。

So now that you've provided a link (albeit in your other question), I can see that the library provides a global minor mode which only turns itself on for a specific configurable set of major modes.

以下将重新定义做出该决定的函数,以便如果 writeroom-major-modes nil (空列表),它将打开任何主要模式。

The following will redefine the function which makes that decision, so that if the writeroom-major-modes is nil (empty list), it will turn on for any major mode.

我还更改了现有测试,以检查派生模式匹配,而不是简单的精确匹配。这样,默认值'(text-mode)将不仅匹配 text-mode ,而且可以将每个模式派生从文本模式。与您的问题不完全相关,但如果您发现所有模式的方法过度使用,也可能很有用。

I also changed the existing test to check for a derived mode match, rather than simply an exact match. That way the default value of '(text-mode) would match not only text-mode, but every mode derived from text-mode. Not strictly relevant to your question, but perhaps useful if you find the "all modes" approach overkill.

(eval-after-load 'writeroom-mode
  '(defun turn-on-writeroom-mode ()
     "Turn on `writeroom-mode'.
This function activates `writeroom-mode' in a buffer if that
buffer's major mode is a member of `writeroom-major-modes',
or derived from one of those modes.

If `writeroom-major-modes' is nil, activate `writeroom-mode'
in ALL buffers."
     (when (or (not writeroom-major-modes)
               (apply 'derived-mode-p writeroom-major-modes))
       (writeroom-mode 1))))

是否需要显式加载/需要库取决于您如何安装它;但是当你使用这个库时,这可能是被照顾的,这意味着它只是一个例子:

Whether you need to explicitly load/require the library depends on how you've installed it; but as you're using the library already, that's presumably been taken care of, meaning it's then just a case of:

(global-writeroom-mode 1)

另外),您可以忽略所提供的全局模式,并创建自己的替代全局小模式,如如何在emacs启动时默认启用非全局次模式?

Alternatively (to all of the above), you could ignore the global mode provided, and create your own alternative global minor mode, as described in How to enable a non-global minor mode by default, on emacs startup?

编辑:我有一个玩过 writeroom-mode 的游戏,似乎有很好的其全球模式有点保守的原因。您可能仍然会发现派生模式的改进很有用,但我怀疑尝试使这种100%全球化的模式根本不会很好。

Well I've had a bit of a play with writeroom-mode, and it would seem there are very good reasons why its global mode was a bit conservative. You might still find the "derived mode" improvement useful, but I suspect trying to make this particular mode 100% global is not going to work very well at all.

这篇关于Emacs:将writeroom模式设置为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆