【问题标题】:Prevent HAML snippets loading when using sass-mode and yasnippet使用 sass-mode 和 yasnippet 时防止加载 HAML 片段
【发布时间】:2014-03-02 01:58:01
【问题描述】:

我正在使用带有 sass-mode 和 yasn-p 的 Emacs 来编辑 .sass 文件。这一切都很好,并且 sn-ps 正在扩展。但是由于 sass-mode 需要 haml-mode,所以在编辑 sass 文件时也会加载 haml sn-ps。这很烦人,因为 haml sn-ps 在 sass 中没用。

我检查了我的 sn-ps 目录中的 .yas-parents 文件,但没有找到。而且我已经搜索了文档和 elisp 代码,但设置或功能并没有跳出来。当我在 sass 缓冲区中运行 M-x yas-describe-table 时,我会在 sass 和 haml 的扩展表上显示。

理想情况下,我希望在处理 sass 缓冲区时打开时阻止 haml sn-ps 加载。但是,如果我可以设置某种钩子来在加载 sass 缓冲区时删除 sn-ps 的 haml 表,那也很好。

谢谢!

【问题讨论】:

标签: emacs elisp yasnippet


【解决方案1】:

在 yasn-ps 中似乎没有办法做你想做的事。所以你应该在yasnippetgithub repo 上打开请求这个特性的问题。

作为一个临时解决方案,您可以通过如下建议 yas--modes-to-activate 来禁用 sass-mode 中的 haml-mode sn-ps 加载。请记住,这是推荐

(eval-after-load "yasnippet"
  '(progn (defadvice yas--modes-to-activate (after my-simple-advise)
           (when (eq major-mode 'sass-mode)
             (setq ad-return-value (remove 'haml-mode ad-return-value))))

         (ad-activate 'yas--modes-to-activate)))

以上建议yas--modes-to-activate 以便haml-modesass-mode 中时不会作为要加载的模式返回。

【讨论】:

  • 你是个天才!谢谢你。我刚刚打开了一个 yasn-p github.com/capitaomorte/yasnippet/issues/465 的问题,所以也许我们会为此提供一个选项。
  • 您的修复也与我的 yasn-p 版本完美配合。版本:20140227.703
猜你喜欢
  • 2015-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-03
  • 1970-01-01
相关资源
最近更新 更多