Update "Cool new scratch buffers" post
This commit is contained in:
parent
c78f760c56
commit
b8bfdaee9c
1 changed files with 8 additions and 5 deletions
|
@ -34,15 +34,16 @@ different major modes. This is handy for messing around with some
|
|||
(let* ((bname (if mode
|
||||
(concat "*" mode "-scratch*")
|
||||
"*scratch*"))
|
||||
(buffer (get-buffer bname)))
|
||||
(buffer (get-buffer bname))
|
||||
(mode-sym (intern (concat mode "-mode"))))
|
||||
|
||||
(unless buffer
|
||||
(setq buffer (generate-new-buffer bname))
|
||||
(with-current-buffer buffer
|
||||
(add-file-local-variable-prop-line 'mode (make-symbol mode))
|
||||
(set-auto-mode t)
|
||||
(when (fboundp mode-sym)
|
||||
(funcall mode-sym)
|
||||
(goto-char (point-max))
|
||||
(newline)))
|
||||
(newline))))
|
||||
|
||||
(switch-to-buffer buffer)))
|
||||
#+end_src
|
||||
|
@ -71,3 +72,5 @@ Of course, this approach doesn't ensure the right major mode gets
|
|||
chosen, but that's really up to whomever uses it.
|
||||
|
||||
It makes me very happy to use such an extensible editor.
|
||||
|
||||
*Update:* fixed my flawed code.
|
||||
|
|
Loading…
Reference in a new issue