Skip to content

Commit

Permalink
feat(core): use persistent scratch buffers by default
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 16, 2023
1 parent a46a79f commit 936dae0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/me-keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"bu" #'+sudo-save-buffer
"bx" #'bury-buffer
"bS" #'save-some-buffers
"bs" #'scratch-buffer
"bs" #'+scratch-open-project-scratch-buffer
"bM" #'view-echo-area-messages
"bA" #'+kill-some-buffers
"bk" `(,(+cmdfy! (kill-buffer (current-buffer)))
Expand Down
16 changes: 12 additions & 4 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,25 @@
;; `minemacs-theme' is set in user configuration, it is loaded here.
(+load-theme)

(+log! "Filling scratch buffer content.")
(+fill-scratch-buffer)
(+deferred!
(+log! "Loading the default persistent scratch buffer.")
(let ((buf (current-buffer)))
;; Load the default persistent scratch buffer
(+scratch-open-buffer nil nil 'same-window)
;; Switch to the previous buffer
(switch-to-buffer buf)
;; And kill the Emacs' default scratch buffer
(when-let ((s (get-buffer "*scratch*"))) (kill-buffer s))))

;; In `me-defaults', the `initial-major-mode' is set to `fundamental-mode'
;; to enhance startup time. However, I like to use the scratch buffer to
;; evaluate Elisp code, so we switch to Elisp mode in the scratch buffer
;; when Emacs is idle for 10 seconds.
(+eval-when-idle-for! 10.0
(setq initial-major-mode 'lisp-interaction-mode)
(with-current-buffer (get-scratch-buffer-create)
(emacs-lisp-mode))))
(when-let ((scratch-buffer (get-buffer "*scratch*")))
(with-current-buffer scratch-buffer
(emacs-lisp-mode)))))

;; Require the virtual package to triggre loading packages depending on it
(require 'minemacs-loaded))
Expand Down

0 comments on commit 936dae0

Please sign in to comment.