Update "Cool new scratch buffers" post

This commit is contained in:
Tom Willemsen 2012-08-07 23:10:45 +02:00
parent c78f760c56
commit b8bfdaee9c

View file

@ -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)
(goto-char (point-max))
(newline)))
(when (fboundp mode-sym)
(funcall mode-sym)
(goto-char (point-max))
(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.