简体   繁体   English

在Emacs中仅将2模式与Web模式一起使用

[英]Only use 2 mode in Emacs with web-mode

I use web-mode in Emacs, everything is fine except that when editing a .js.erb file in Rails. 我在Emacs中使用Web模式,除了在Rails中编辑.js.erb文件时,一切都很好。

Because there's only 2 modes in .js.erb file: js and ruby and web-mode only recognize javascipt code in <scipt type="javascript"></scipt> . 因为.js.erb文件中只有2种模式: jsruby和Web模式仅识别<scipt type="javascript"></scipt> javascipt代码。

I'm not very familiar with emacs and web-mode, maybe there's a way to config. 我对emacs和网络模式不是很熟悉,也许有一种配置方法。

You can change the "default" mode of an active buffer by modifying the variable web-mode-content-type , eg from M-: : 您可以通过修改变量web-mode-content-type来更改活动缓冲区的“默认”模式,例如从M-: ::

(setq web-mode-content-type "javascript")

Default modes may be specified by file name (or pattern) by modifying the web-mode-content-types alist somewhere in your configuration, eg 通过修改配置中某处的web-mode-content-types可以通过文件名(或模式)指定默认模式。

(eval-after-load "web-mode"
  '(add-to-list 'web-mode-content-types '("javascript" . "\\.js\\.erb\\'")))

web-mode的作者已解决此问题,因此只需更新您的网络模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM