Files
sydnix/users/crumb/programs/emacs/modules/syd-scratch.el
2025-01-17 16:28:45 -07:00

45 lines
1.7 KiB
EmacsLisp

;;; syd-scratch.el -*- lexical-binding: t; -*-
(require 'syd-prelude)
;; Persist the scratch buffer between sessions. Note that it is not persisted
;; between boots.
;; TODO: This could be deferred better.
(use-package persistent-scratch
:hook (on-first-buffer)
:custom (persistent-scratch-save-file
(file-name-concat syd-data-dir "scratch"))
:config
;; The default error/warning message is a bit too error-looking for my tastes.
;; This is the same function, but with a tamer warning message.
(defun syd--persistent-scratch--auto-restore ()
"Automatically restore the scratch buffer once per session."
(unless persistent-scratch--auto-restored
(condition-case err
(persistent-scratch-restore)
(error
(message "No previous scratch buffer to restore")))
(setq persistent-scratch--auto-restored t)))
(advice-add #'persistent-scratch--auto-restore
:override #'syd--persistent-scratch--auto-restore)
;; Arrange the activation of autosave and auto-restore (if applicable) on
;; Emacs start.
(persistent-scratch-setup-default))
(use-package emacs
:custom ((initial-scratch-message
(with-temp-buffer
(insert-file-contents "/persist/vault/crumb/cool-deer.org")
(buffer-string)))
;; Initial major mode for scratch buffer.
(initial-major-mode 'fundamental-mode)
;; Disable the initial "help" screen, in favour of starting off in
;; the scratch buffer.
(inhibit-splash-screen t)
(inhibit-startup-screen t)
(inhibit-startup-message t)))
(provide 'syd-scratch)
;;; syd-scratch.el ends here