Set buffer mode according to `auto-mode-alist'
With this, after we create a special buffer, the major-mode get set automatically. For example, we create a new buffer named "ruby.rb", `ruby-mode` was automatically enabled.
This commit is contained in:
parent
86f25a9462
commit
bc53a7008a
1 changed files with 6 additions and 0 deletions
|
@ -181,6 +181,12 @@ The body of the advice is in BODY."
|
||||||
(when (version<= "24.4" emacs-version)
|
(when (version<= "24.4" emacs-version)
|
||||||
(add-hook 'focus-out-hook 'prelude-save-all-buffers))
|
(add-hook 'focus-out-hook 'prelude-save-all-buffers))
|
||||||
|
|
||||||
|
(defadvice set-buffer-major-mode (after set-major-mode activate compile)
|
||||||
|
"Set buffer major mode according to `auto-mode-alist'."
|
||||||
|
(let* ((name (buffer-name buffer))
|
||||||
|
(mode (assoc-default name auto-mode-alist 'string-match)))
|
||||||
|
(with-current-buffer buffer (if mode (funcall mode)))))
|
||||||
|
|
||||||
;; highlight the current line
|
;; highlight the current line
|
||||||
(global-hl-line-mode +1)
|
(global-hl-line-mode +1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue