feat: Customise scratch buffer
This commit is contained in:
1
users/crumb/programs/emacs/.persistent-scratch
Normal file
1
users/crumb/programs/emacs/.persistent-scratch
Normal file
@@ -0,0 +1 @@
|
||||
(["*scratch*" "ahhhii" (6) lisp-interaction-mode nil nil])
|
||||
@@ -17,5 +17,6 @@
|
||||
(require 'syd-display-startup-time)
|
||||
(require 'syd-evil)
|
||||
(require 'syd-keybinds)
|
||||
(require 'syd-scratch)
|
||||
(require 'syd-smartparens)
|
||||
(require 'syd-ui)
|
||||
|
||||
@@ -113,6 +113,7 @@ are active.")
|
||||
(general-def
|
||||
:keymaps 'syd-leader-map
|
||||
"." #'find-file
|
||||
"x" `("Open scratch buffer" . ,#'scratch-buffer)
|
||||
"b" `("Buffer" . ,syd-leader-buffer-map)
|
||||
"w" `("Window" . ,syd-leader-window-map)
|
||||
"f" `("File" . ,syd-leader-file-map)
|
||||
|
||||
44
users/crumb/programs/emacs/modules/syd-scratch.el
Normal file
44
users/crumb/programs/emacs/modules/syd-scratch.el
Normal file
@@ -0,0 +1,44 @@
|
||||
;;; 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
|
||||
Reference in New Issue
Block a user