This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun create-scratch-buffer (&optional nomode) | |
"Create a new scratch buffer and switch to it. If the region is active, then | |
paste the contents of the region in the new buffer. The new buffer inherits | |
the mode of the original buffer unless nomode is set. | |
Return the buffer." | |
(interactive "P") | |
(let (bufname (mjmode major-mode) (paste (and (region-active-p) (prog1 (buffer-substring (mark t) (point)) (deactivate-mark))))) | |
(if (and (not nomode) (boundp 'ess-dialect) ess-dialect) | |
(setq mjmode (intern-soft (concat ess-dialect "-mode")))) | |
(setq bufname (generate-new-buffer-name "*scratch*")) |