【问题标题】:RET adds a line below but doesn't jump to it in Matlab mode on EmacsRET 在下面添加一行,但在 Emacs 上的 Matlab 模式下不会跳转到它
【发布时间】:2015-06-25 02:25:52
【问题描述】:

当我在 Emacs 上处于 matlab 模式时(我使用 Aquamacs),RET 在下面添加一行,但不会跳转到该行(即,它充当 C-o 应该做的)。如果 RET 的行为符合预期,即在下方添加一行并将光标移至该行,则此行为不会在其他模式下发生。

当我在 matlab 模式下按 RET 时,我会收到此消息

错误的类型参数“wholenump -1”

我不知道这是从哪里来的。我已将所有与 matlab 相关的文件重新安装到 .emacs,查看了 .emacs、Preferences.el、customizations.el,并查看了 customise-apropos 'matlab' 的所有选项。我还没有找到任何可以给我线索的东西。我不知道任何 lisp,即使我已经使用 emacs 几年了,也可以被认为是菜鸟。有人可以帮我追踪问题吗?

我正在使用 Aquatics 3.2 GNU Emacs 24.4.51.2。几年前,我最初运行的是一个未知来源的matlab-mode,但在尝试解决此问题时,我通过运行update scripthttps://github.com/pronobis/matlab-mode 升级到最新版本。这并没有解决我的问题。

正如在 this SO chat 中发现的那样,某些东西正在将 fill-column 设置为值 -1

fill-column is a variable defined in `C source code'. 
Its value is -1 
Original value was 70 
Local in buffer funfzero.m; global value is the same.

手动将其设置回 70 暂时解决了我的问题。但是是什么导致它被设置为这样的虚假值?我怎样才能知道这是在哪里设置的?

这是调试输出

Debugger entered--Lisp error: (wrong-type-argument wholenump -1)
  move-to-column(-1)
  (save-excursion (move-to-column fill-column) (if (not (bobp)) (forward-char -1)) (if (matlab-cursor-in-string (quote incomplete)) 4 3))
  (if matlab-fill-count-ellipsis-flag (save-excursion (move-to-column fill-column) (if (not (bobp)) (forward-char -1)) (if (matlab-cursor-in-string (quote incomplete)) 4 3)) 0)
  (- fill-column (if matlab-fill-count-ellipsis-flag (save-excursion (move-to-column fill-column) (if (not (bobp)) (forward-char -1)) (if (matlab-cursor-in-string (quote incomplete)) 4 3)) 0))
  (let ((fill-prefix fill-prefix) (fill-column (- fill-column (if matlab-fill-count-ellipsis-flag (save-excursion (move-to-column fill-column) (if (not ...) (forward-char -1)) (if (matlab-cursor-in-string ...) 4 3)) 0)))) (if (> (current-column) fill-column) (cond ((matlab-ltype-comm-ignore) nil) ((or (matlab-ltype-comm) (and (save-excursion (move-to-column fill-column) (matlab-cursor-in-comment)) (matlab-lattr-comm))) (matlab-set-comm-fill-prefix) (do-auto-fill) (matlab-reset-fill-prefix)) ((and (matlab-ltype-code) (not (matlab-lattr-cont)) matlab-fill-code) (let ((m (make-marker))) (move-marker m (point)) (set-marker-insertion-type m t) (if (not (matlab-find-convenient-line-break)) nil (if (not ...) (progn ... ... ...) (if matlab-fill-strings-flag ...))) (goto-char m))))))
  matlab-auto-fill()
  self-insert-command(1)
  newline()
  matlab-plain-ret()
  funcall(matlab-plain-ret)
  matlab-return()
  call-interactively(matlab-return nil nil)
  command-execute(matlab-return)

【问题讨论】:

    标签: emacs elisp


    【解决方案1】:

    虽然这可能无法找到导致 fill-column 设置为 -1 的任何原因,但一个简单的解决方法是将对 set-fill-column 的调用添加到 matlab-mode-hook

    (add-hook 'matlab-mode-hook
              (lambda ()
                (set-fill-column 70)))
    

    通过将此添加到init.elfill-column 将在输入 matlab-mode 时自动设置为 70。

    【讨论】:

    • 我很确定我之前在摆弄 aquamacs 时更改了填充列变量,但无论如何最好有你的线路以防万一:)
    【解决方案2】:

    一直都是这样吗?

    从您的调试器日志中,看起来 matlab-mode 将 RET 绑定到它自己的 matlab-return,其目的类似于 auto-pretty-indent。

    fill-column 在该代码中设置。在 (let ...) 行中。

    所以,看起来,这是代码的逻辑错误。

    一个简单的解决方法是简单地将换行符绑定到 RET,就像在

    (defun my-matlab-mode-stuff ()
      (local-set-key (kbd "RET") 'newline))
    (add-hook 'matlab-mode-hook 'my-matlab-mode-stuff)
    

    您可以将 'newline 更改为 'matlab-plain-ret,因为这似乎只是插入 return 的意思。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-26
      • 2015-11-03
      • 1970-01-01
      • 2017-07-04
      • 2015-12-15
      • 1970-01-01
      • 2023-03-10
      相关资源
      最近更新 更多