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:
commit
a7bae36f8a
2 changed files with 9 additions and 4 deletions
|
@ -371,10 +371,9 @@ Doesn't mess with special buffers."
|
||||||
(defun prelude-create-scratch-buffer ()
|
(defun prelude-create-scratch-buffer ()
|
||||||
"Create a new scratch buffer."
|
"Create a new scratch buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(progn
|
(let ((buf (get-buffer-create (generate-new-buffer-name "*scratch*"))))
|
||||||
(switch-to-buffer
|
(set-buffer-major-mode buf)
|
||||||
(get-buffer-create (generate-new-buffer-name "*scratch*")))
|
(switch-to-buffer buf)))
|
||||||
(emacs-lisp-mode)))
|
|
||||||
|
|
||||||
(defvar prelude-tips
|
(defvar prelude-tips
|
||||||
'("Press <C-c o> to open a file with external program."
|
'("Press <C-c o> to open a file with external program."
|
||||||
|
|
|
@ -176,6 +176,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-auto-save-command))
|
(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
|
;; highlight the current line
|
||||||
(global-hl-line-mode +1)
|
(global-hl-line-mode +1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue