Merge pull request #592 from toctan/set-buffer-major-mode

Set new special buffer mode according to `auto-mode-alist'
This commit is contained in:
Bozhidar Batsov 2014-07-15 13:10:10 +03:00
commit a7bae36f8a
2 changed files with 9 additions and 4 deletions

View file

@ -371,10 +371,9 @@ Doesn't mess with special buffers."
(defun prelude-create-scratch-buffer ()
"Create a new scratch buffer."
(interactive)
(progn
(switch-to-buffer
(get-buffer-create (generate-new-buffer-name "*scratch*")))
(emacs-lisp-mode)))
(let ((buf (get-buffer-create (generate-new-buffer-name "*scratch*"))))
(set-buffer-major-mode buf)
(switch-to-buffer buf)))
(defvar prelude-tips
'("Press <C-c o> to open a file with external program."

View file

@ -176,6 +176,12 @@ The body of the advice is in BODY."
(when (version<= "24.4" emacs-version)
(add-hook 'focus-out-hook 'prelude-auto-save-command))
(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
(global-hl-line-mode +1)