【问题标题】:how to use dart-mode and d-mode together (why can't we all get along?)如何一起使用 dart-mode 和 d-mode (为什么我们不能相处?)
【发布时间】:2013-04-22 19:19:16
【问题描述】:

我正在尝试在 emacs 24 中使用 dart-mode 和 d-mode。如果我单独使用任何一种模式,一切都很好。如果我分别在每种类型的文件上使用这两种模式,我在尝试缩进 D 代码时会出错。

以下是在初始化时需要以下内容后的错误:

(require 'd-mode)
(require 'dart-mode)

然后我在第一个加载的 D 文件上打开 d-mode。

Error during redisplay: (jit-lock-function 1) signaled (invalid-function (setq ad-return-value (with-no-warnings (funcall ad--addoit-function))))

再次 - 如果我不 需要 'dart-mode 一切正常。

d-mode 来自https://raw.github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode/master/d-mode.el,dart 模式来自https://github.com/nex3/dart-mode/blob/master/dart-mode.el

这是否意味着这两种模式之间存在一些不兼容,或者其他一些设置问题?我尝试了 --no-site-file 但仍然没有运气。


换一种说法,鉴于以下情况,如果我调出一个 D 文件并在其中 M-x d-mode,我就会遇到问题:

user@user-thinkpad:/tmp/breakEmacs$ ls
dart-mode.el  d-mode.el  emacs_test.el
user@user-thinkpad:/tmp/breakEmacs$ cat emacs_test.el
(add-to-list 'load-path "/tmp/breakEmacs")
(require 'd-mode)
(require 'dart-mode)
user@user-thinkpad:/tmp/breakEmacs$ emacs-snapshot --no-init-file --no-site-file -l /tmp/breakEmacs/emacs_test.el 

我希望这种方式能够成功消除我的任何 .emacs 文件的潜在问题?


根据@wvxvw 的建议,我尝试通过添加 (setq debug-on-error t) 进行调试,它提供了如下所示的调用堆栈。我说 like 是因为有些行很大并且看起来像二进制编码,所以我省略了一些文本。但是,希望这里有一些有用的东西来指出罪魁祸首?

Debugger entered--Lisp error: (invalid-function (setq ad-return-value (with-no-warnings (funcall ad--addoit-function))))
  (setq ad-return-value (with-no-warnings (funcall ad--addoit-function)))()
  ad-Advice-c-parse-state(#[nil ...] 5])
  apply(ad-Advice-c-parse-state #[nil ...] nil)
  c-parse-state()
  #[nil  ...] 8 ("/usr/share/emacs/24.3.50/lisp/progmodes/cc-engine.elc" . 156151)]()
  ad-Advice-c-guess-basic-syntax(#[nil ...] 8 ("/usr/share/emacs/24.3.50/lisp/progmodes/cc-engine.elc" . 156151)])
  apply(ad-Advice-c-guess-basic-syntax #[nil ...] 8 ("/usr/share/emacs/24.3.50/lisp/progmodes/cc-engine.elc" . 156151)] nil)
  c-guess-basic-syntax()
  c-indent-line()
  c-indent-command(nil)
  c-indent-line-or-region(nil nil)
  call-interactively(c-indent-line-or-region nil nil)
  command-execute(c-indent-line-or-region)

【问题讨论】:

  • 嗯,使用 Emacs 24.2.1 以及那些完全相同的 d-mode 和 dart-mode 实现,我无法重现该问题。
  • 酷。您对如何解决问题有任何建议吗?有什么有用的信息吗?
  • 不,我不太确定。我添加了 elisp 标记,因为它似乎是 elisp 代码中的一个错误。
  • @DarshanComputing:我添加了一个非常简单的方法来查看它。我正在使用 GNU Emacs 24.3.50.1。你真的打开了一个d文件,进入了d-mode吗?
  • @user1338952 是的,我打开了一个D文件,进入d-mode,添加和删除代码,并通过各种方式让emacs成功缩进了我的代码。

标签: emacs elisp dart


【解决方案1】:

问题在于飞镖模式。它使用如下代码:

(if (not (c-major-mode-is 'dart-mode))
    (ad-do-it)

应该是这样的

(if (not (c-major-mode-is 'dart-mode))
    ad-do-it

注意 ad-do-it 周围的括号被删除。

【讨论】:

    猜你喜欢
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    • 2014-11-29
    • 2018-06-05
    • 1970-01-01
    • 2017-08-24
    • 1970-01-01
    • 2016-04-30
    相关资源
    最近更新 更多