[英]How can I make emacs load nXhtml only when php/html files are open and prevent it from loading at startup
So in order to optimize emacs startup time I prefer to encapsualte all mods within a hook or an eval-after-load. 因此,为了优化emacs启动时间,我更喜欢在钩子或eval-after-load中封装所有mod。 So I figured out python, cpp and latex but am stuck with nXhtml. 所以我想出了python,cpp和latex,但我坚持使用nXhtml。 I tried the following: 我尝试了以下方法:
(eval-after-load "HTML-mode"
'(progn
(load-file "~/.emacs.d/plugins/nxhtml/autostart.el")
))
Which doesn't work at all. 这根本不起作用。
The code : 编码 :
(add-hook 'html-mode-hook (lambda()
(progn
(load-file "~/.emacs.d/plugins/nxhtml/autostart.el")
)))
loads some parts of nXhtml but the nXhtml mode is not on (only SGML and AC) so scopes aren't colored differently in my php sources or autocomplete/ bracket completion doesn't work. 加载nXhtml的某些部分,但是nXhtml模式没有打开(只有SGML和AC),因此我的php源中的范围没有不同的颜色,或者自动完成/括号完成不起作用。
The only way it works properly is if I let it load on startup. 它正常工作的唯一方法是我在启动时加载它。
Looking at the trace , when nxhtml is loaded during startup it says : 查看跟踪,当在启动期间加载nxhtml时,它说:
"majmodpri-apply-priorities running ... (done)" “majmodpri-apply-priorities running ...(已完成)”
However when the load is encapsulated by an html-mode-hook or the eval-after-load the trace says: 但是当负载由html-mode-hook或eval-after-load封装时,跟踪显示:
"majmodpri-apply-priorities running ... MU:majmodpri-check changing majmodpri-apply-priorities: buffer=index.php, html-mode,nil => sgml-mode,nil majmodpri-apply-priorities running ... (done)" “运行majmodpri-apply-priorities ... MU:majmodpri-check更改majmodpri-apply-priorities:buffer = index.php,html-mode,nil => sgml-mode,nil majmodpri-apply-priorities running ...(完成)”
Any ideas? 有任何想法吗?
I think nXhtml's autostart file (which is all that you would be loading) is designed to be fairly minimal, so it might be the case that you can't reduce it too much more without constraining some of its abilities? 我认为nXhtml的自动启动文件(这就是你要加载的所有文件)被设计得相当小,所以可能是你不能在不限制它的某些能力的情况下减少它太多的情况?
How long is it actually taking? 它实际需要多长时间? It looks like there should be a "Nxml/Nxhtml Autostart.el loaded in %.1f seconds" message logged. 看起来应该记录“在%.1f秒内加载Nxml / Nxhtml Autostart.el”消息。
Infact html-mode
is defined in sgml-mode.el file. 事实上html-mode
在sgml-mode.el文件中定义。
So you eval-after-load
should be as follows 因此, eval-after-load
应如下所示
(eval-after-load "sgml-mode" (lambda ()
;;; code to load your nxhtml
))
I also use nxhtml-mode to edit the erb documents when I programming ROR app. 我在编写ROR应用程序时也使用nxhtml-mode来编辑erb文档。 Take a look at my configuration, this may help you. 看看我的配置,这可能会对你有所帮助。
(autoload 'eruby-nxhtml-mumamo-mode "autostart.el" "Edit erb document." t)
(add-to-list 'auto-mode-alist '("\\.erb" . eruby-nxhtml-mumamo-mode))
I just combined the OP code and it works for me: 我只是结合了OP代码,它对我有用:
(add-hook 'html-mode-hook (lambda()
(progn
(load-file "~/.emacs.d/vendor/~nxhtml/nxhtml/main/autostart.el")
)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.