diff options
author | Amin Bandali <bandali@kelar.org> | 2022-05-19 21:42:23 -0400 |
---|---|---|
committer | Amin Bandali <bandali@kelar.org> | 2022-05-19 22:20:04 -0400 |
commit | 272a75dc74b1d02748472d5014be26aab7c060be (patch) | |
tree | e317c9c95a31ec781806a69fc31b8f65fca6633f | |
parent | 78d731e133fcef8464acb1d0eb8a51864d0189cd (diff) | |
download | configs-272a75dc74b1d02748472d5014be26aab7c060be.tar.gz configs-272a75dc74b1d02748472d5014be26aab7c060be.tar.xz configs-272a75dc74b1d02748472d5014be26aab7c060be.zip |
Rewrite `b/*scratch*' function in init file
* .emacs.d/init.el (b/*scratch*): Rewrite to use the new
`get-scratch-buffer-create' function in emacs.git master branch if
available, otherwise use the old `startup--get-buffer-create-scratch'.
-rw-r--r-- | .emacs.d/init.el | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 0fd70e5..459dbe8 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -812,11 +812,10 @@ Effectively a very simple light/dark theme toggle switch." (defun b/*scratch* () "Switch to `*scratch*' buffer, creating it if it does not exist." (interactive) - (switch-to-buffer - (or (get-buffer "*scratch*") - (with-current-buffer (get-buffer-create "*scratch*") - (set-buffer-major-mode (current-buffer)) - (current-buffer))))) + (let ((fun (if (functionp #'get-scratch-buffer-create) + #'get-scratch-buffer-create ; (version<= "29" emacs-version) + #'startup--get-buffer-create-scratch))) ; (version< emacs-version "29") + (switch-to-buffer (funcall fun)))) (global-set-key (kbd "C-c s") #'b/*scratch*) ;; ,---- |