emacs搭建web开发环境
web-mode
About
HTML documents can embed parts (CSS / JavaScript) and blocks (client / server side).
Download
Install
(require 'web-mode) (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) ;; indent setting (defun my-web-mode-hook () "Hooks for Web mode." (setq web-mode-markup-indent-offset 2) ) (add-hook 'web-mode-hook 'my-web-mode-hook) ;; comment style setting (setq web-mode-comment-style 2)
emacs中调用外部浏览器打开html文档
emacs默认的html-mode
browse-url-of-buffer
C-c C-v runs the command browse-url-of-buffer, which is an interactive compiled Lisp function. It is bound to C-c C-v, <menu-bar> <html> <browse-url-of-buffer>. (browse-url-of-buffer &optional BUFFER) Ask a WWW browser to display BUFFER. Display the current buffer if BUFFER is nil. Display only the currently visible part of BUFFER (from a temporary file) if buffer is narrowed.
在web-mode中绑定按键来调用上述函数
(defun web-mode-keybinding-settings () "Settings for keybinding." (eal-define-keys '(web-mode-map) '(("C-c C-v" browse-url-of-file)))) (eval-after-load "web-mode-keybinding-settings" '(web-mode-keybinding-settings))
定义web-mode中的键绑定C-c C-v 调用上述函数,在其他mode中这个快捷键不起作用
web-settings.el
(require 'web-mode) (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) ;; indent setting (defun my-web-mode-hook () "Hooks for Web mode." (setq web-mode-markup-indent-offset 2) ) (add-hook 'web-mode-hook 'my-web-mode-hook) ;; comment style setting (setq web-mode-comment-style 2) ;; keybinding (defun web-mode-keybinding-settings () "Settings for keybinding." (eal-define-keys '(web-mode-map) '(("C-c C-v" browse-url-of-file)))) (eval-after-load "web-mode-keybinding-settings" '(web-mode-keybinding-settings)) (provide 'web-settings)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。