【问题标题】:Why do I start iswitchb-mode this way?为什么我要以这种方式启动 iswitchb-mode?
【发布时间】:2009-09-14 13:54:47
【问题描述】:

根据 emacs 信息页面,以下是启用 iswitchb-mode 的方法:

要启用 Iswitchb 模式,请键入 M-x iswitchb-mode,或自定义 变量iswitchb-modet

所以我在我的 .emacs 中加入了以下内容:

(setq iswitchb-mode t)

但是,这似乎不起作用。搜索了emacs wiki,发现需要用到这个:

(iswitchb-mode 1)

有人可以解释为什么我需要以这种方式启用它吗?我想更好地了解 elisp,而不仅仅是从不同的地方复制和粘贴内容。

【问题讨论】:

    标签: emacs elisp iswitchb-mode


    【解决方案1】:

    通常,模式将定义同名的变量和函数。该函数会在调用时正确设置变量,但打开模式的是函数,而不仅仅是变量(仅跟踪模式的状态)。

    在您的特定情况下,您被告知自定义变量,但您只需设置它即可。不同之处在于,当变量的值发生变化时,custom 知道要做什么,而 `setq' 对此一无所知。如果您查看此变量的帮助 (C-h v iswitchb-mode),您会得到:

    iswitchb-mode is a variable defined in `iswitchb.el'.
    Its value is t
    
    Documentation:
    Non-nil if Iswitchb mode is enabled.
    See the command `iswitchb-mode' for a description of this minor mode.
    Setting this variable directly does not take effect;
    either customize it (see the info node `Easy Customization')
    or call the function `iswitchb-mode'.
    
    You can customize this variable.
    

    【讨论】:

    • 谢谢。我不知道关于 elisp 的所有这些。
    • 不幸的是,这并不容易推断(除了变量的描述)。 iswitchb(和大多数次要模式)使用宏 define-minor-mode' to take care of the actual mechanics of constructing the mode, turning it on and off, customizing variables, keymaps and the like, so you have to dig into the function definition of define-minor-mode' 本身来收集这些东西是如何组合在一起的。
    猜你喜欢
    • 2022-01-13
    • 2023-04-01
    • 1970-01-01
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 2014-08-28
    相关资源
    最近更新 更多