From b8bfdaee9c998538745b98367d96786741c6ecea Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Aug 2012 23:10:45 +0200 Subject: [PATCH] Update "Cool new scratch buffers" post --- blog/blog-2012-08-02-0027.org | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/blog/blog-2012-08-02-0027.org b/blog/blog-2012-08-02-0027.org index 1a91be7..86a205b 100644 --- a/blog/blog-2012-08-02-0027.org +++ b/blog/blog-2012-08-02-0027.org @@ -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.