当我在Emacs上使用matlab模式时(我使用Aquamacs),RET会在下面添加一行,但不会跳转到该行(即,它的作用就像C-o应该做的那样)。如果RET的行为符合预期,即在下面添加一行并将光标移动到该行,则这种行为在其他模式中不会发生
当我在matlab模式下按下RET时,我会收到以下消息
错误类型参数";wholenump-1";
我不知道这是从哪里来的。我已经将所有与matlab相关的文件重新安装到.emacs,我已经查看了.emacs、Preferences.el、customizations.el,并查看了定制程序"matlab"的所有选项。我没有找到任何能给我线索的东西。我不知道任何口齿不清,可以被认为是一个角落,尽管我已经使用emacs几年了。有人能帮我找出问题吗?
我使用的是Aquatics 3.2 GNU Emacs 24.4.51.2。几年前,我最初运行一个来源不明的matlab-mode
,但在尝试解决此问题时,我从升级到了最新版本https://github.com/pronobis/matlab-mode通过运行更新脚本。这并没有解决我的问题。
正如在这次SO聊天中发现的那样,有人将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)
虽然这可能无法找到导致fill-column
设置为-1的根源,但一个简单的解决方法是将对set-fill-column
的调用添加到matlab-mode-hook
:
(add-hook 'matlab-mode-hook
(lambda ()
(set-fill-column 70)))
通过将其添加到init.el
,fill-column
将在输入matlab-mode
时自动设置为70。
一直都是这样吗?
从调试器日志来看,它看起来像是matlab模式将RET绑定到它自己的matlab返回,目的看起来像是自动漂亮缩进。
填充列是在该代码中设置的。在(let…)行。
所以,看起来,这是一个代码的逻辑错误。
一个简单的解决方案是简单地将换行符绑定到RET,就像中一样
(defun my-matlab-mode-stuff ()
(local-set-key (kbd "RET") 'newline))
(add-hook 'matlab-mode-hook 'my-matlab-mode-stuff)
您可以将"换行符"更改为"matlab纯ret",因为这似乎是它只插入return的方式。