viper-auto-indent 打破了劣等模式

发布于 2024-08-05 20:25:29 字数 417 浏览 9 评论 0原文

作为一个 vim 转换者,我已经相当习惯 viper 模式了。然而,我发现的一个问题是 viper-auto-indent 破坏了所有低级模式。发生的情况是,当我输入任何类型的低级模式(sql-mode、ess-mode 等)并按 Enter 键时,Enter 键实际上不会将命令发送到低级进程,而是给出进程的外观绞刑。

如果不设置 viper-auto-indent,我会遇到编写代码时 Enter 键不会自动缩进的问题,这意味着我在输入新行后总是需要按 Tab,这很烦人。我一直在使用的解决方法是默认启用 viper-auto-indent (因为我大部分时间都在编程),然后在进入劣质模式缓冲区时禁用它。

有谁知道如何解决这个问题?或者,任何人都可以帮助我提供 elisp,以在切换到内部模式缓冲区时禁用 viper-auto-indent,并在处于非劣等模式缓冲区时启用它?谢谢。

As a vim convert, I've gotten fairly used to viper mode. One issue that I've discovered, however, is that viper-auto-indent breaks all inferior modes. What happens is when I enter any sort of inferior mode (sql-mode, ess-mode, etc.) and hit Enter, the Enter key doesn't actually send the command off to the inferior process and gives the appearance of the process just hanging.

Without setting viper-auto-indent I have the problem that the Enter key doesn't automatically indent when writing code, meaning that I need to always hit tab after entering a new line, which is annoying. The workaround I've been using is to have viper-auto-indent enabled by default (since I spend most of my time programming), and then disabling it when I enter an inferior-mode buffer.

Does anyone know how to fix this problem? Alternatively, can anyone help supply me with the elisp to disable viper-auto-indent when switching to an interior mode buffer, and enabling it when in a non-inferior mode buffer? Thanks.

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

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

发布评论

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

评论(2

浅浅 2024-08-12 20:25:29

我认为 Emacs 的意图是让您使用“Cj”进行换行和缩进,而让 Enter 保持不变。

如果您还不能接受,那么这个未经测试的代码可能会起作用:

(add-hook 'inferior-ess-mode-hook
               '(lambda () (set (make-local-variable 'viper-auto-indent) nil))

I think Emacs' intent is to have you use "C-j" for newline-and-indent, and let Enter be left alone.

If that is not yet acceptable to you, then this untested code may work:

(add-hook 'inferior-ess-mode-hook
               '(lambda () (set (make-local-variable 'viper-auto-indent) nil))
落叶缤纷 2024-08-12 20:25:29

我无法重现你的问题。我尝试了 viper 模式的各个级别(1-5),以及一些较差的进程。也就是说,从您的实际问题来看,这段代码似乎应该符合要求。如果/当'viper-autoindent被调用时,如果当前缓冲区有一个进程,它会调用刚刚按下的键的原始绑定。如果没有进程,则调用原始的 viper-autoindent。

(defadvice viper-autoindent (around viper-autoindent-but-not-when-buffer-has-process activate)
  "work around reported user problem"
  (if (and (this-command-keys)
           (get-buffer-process (current-buffer)))
      (let* ((viper-mode nil)
             (thiskey (key-binding (this-command-keys))))
        (when thiskey
          (call-interactively thiskey)))
    ad-do-it))

I'm not able to reproduce your problem. I tried every level of viper-mode (1-5), and a number of inferior processes. That said, from your actual question, this code appears like it should fit the bill. If/when 'viper-autoindent is called, if the current buffer has a process, it calls the original binding for the keys just pressed. If there's no process, the original viper-autoindent is called.

(defadvice viper-autoindent (around viper-autoindent-but-not-when-buffer-has-process activate)
  "work around reported user problem"
  (if (and (this-command-keys)
           (get-buffer-process (current-buffer)))
      (let* ((viper-mode nil)
             (thiskey (key-binding (this-command-keys))))
        (when thiskey
          (call-interactively thiskey)))
    ad-do-it))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文