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
|
(let* ((bname (if mode
|
||||||
(concat "*" mode "-scratch*")
|
(concat "*" mode "-scratch*")
|
||||||
"*scratch*"))
|
"*scratch*"))
|
||||||
(buffer (get-buffer bname)))
|
(buffer (get-buffer bname))
|
||||||
|
(mode-sym (intern (concat mode "-mode"))))
|
||||||
|
|
||||||
(unless buffer
|
(unless buffer
|
||||||
(setq buffer (generate-new-buffer bname))
|
(setq buffer (generate-new-buffer bname))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(add-file-local-variable-prop-line 'mode (make-symbol mode))
|
(when (fboundp mode-sym)
|
||||||
(set-auto-mode t)
|
(funcall mode-sym)
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(newline)))
|
(newline))))
|
||||||
|
|
||||||
(switch-to-buffer buffer)))
|
(switch-to-buffer buffer)))
|
||||||
#+end_src
|
#+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.
|
chosen, but that's really up to whomever uses it.
|
||||||
|
|
||||||
It makes me very happy to use such an extensible editor.
|
It makes me very happy to use such an extensible editor.
|
||||||
|
|
||||||
|
*Update:* fixed my flawed code.
|
||||||
|
|
Loading…
Reference in a new issue