feat: Customise scratch buffer

This commit is contained in:
Madeleine Sydney
2025-01-15 01:45:44 -07:00
parent 76828c173a
commit 386779ce9b
6 changed files with 114 additions and 7 deletions

View File

@@ -91,9 +91,6 @@ On boot, ...
- =/persist/vault/«user»= :: Persistent files belonging to specific users. This differs from the persistent home directories in that files are not necessarily linked anywhere. - =/persist/vault/«user»= :: Persistent files belonging to specific users. This differs from the persistent home directories in that files are not necessarily linked anywhere.
* ~sydnix-cli~
sydnix-cli is a command-line utility written in Clojure wrapping various sydnix-related scripts.
** Deferring Emacs packages ** Deferring Emacs packages
@@ -137,24 +134,86 @@ As with the rest of the config, these are largely adapted from Doom's ([cite:@li
- ~«NAME»-h~ :: Procedure defined specifically to be added to a hook. - ~«NAME»-h~ :: Procedure defined specifically to be added to a hook.
* ~sydnix-cli~
sydnix-cli is a command-line utility written in Clojure wrapping various sydnix-related scripts.
* Tasks * Tasks
** Begin setting up doomless Emacs ** Emacs from scratch
*** DONE Daemon *** DONE Daemon
CLOSED: [2025-01-03 Fri 20:00] CLOSED: [2025-01-03 Fri 20:00]
*** DONE Encryption
*** DONE Mutable config *** DONE Mutable config
CLOSED: [2025-01-03 Fri 20:01] CLOSED: [2025-01-03 Fri 20:01]
Path is currently hardcoded to =/persist/dots/users/crumb/programs/emacs=. An immutable file (created by home-manager's =programs.emacs.extraConfig=) loads =init.el= from the hardcoded path. Path is currently hardcoded to =/persist/dots/users/crumb/programs/emacs=. An immutable file (created by home-manager's =programs.emacs.extraConfig=) loads =init.el= from the hardcoded path.
*** DONE Packages via Nixpkgs *** KILL Packages via Nixpkgs
CLOSED: [2025-01-03 Fri 20:40] CLOSED: [2025-01-03 Fri 20:40]
*** TODO =map!= macro *** TODO Org-mode
*** TODO Module system? **** TODO Roam
***** TODO Dailies
**** TODO Capture templates
*** TODO project.el
*** TODO Prose minor mode
**** TODO Grammar-checking
**** TODO Spell-checking
*** TODO Sexp editing
*** TODO Lookup handlers
*** TODO Comint
*** TODO Eshell
*** TODO Snippets
**** TODO File templates
**** TODO Project templates
*** TODO Magit
**** TODO Forges
*** TODO Dired/Dirvish
*** TODO [[kbd:][SPC i]]
*** TODO [[kbd:][SPC o]]
*** TODO [[kbd:][SPC t]]
*** TODO Vertico repeat
*** Language support
**** TODO Clojure
**** TODO Haskell
**** TODO Nix
**** TODO Open repl
**** TODO Elisp
*** IDEA =map!= macro
*** IDEA Module system?
** Emacs config ** Emacs config

View File

@@ -52,6 +52,7 @@ in {
# Impermanence expects the path to be relative to ~. # Impermanence expects the path to be relative to ~.
(lib.removePrefix config.home.homeDirectory straightBaseDir) (lib.removePrefix config.home.homeDirectory straightBaseDir)
]; ];
home.packages = [ emacsWrapper ]; home.packages = [ emacsWrapper ];
# TODO: Make sure this is using the right package for Emacs... # TODO: Make sure this is using the right package for Emacs...

View File

@@ -0,0 +1 @@
(["*scratch*" "ahhhii" (6) lisp-interaction-mode nil nil])

View File

@@ -17,5 +17,6 @@
(require 'syd-display-startup-time) (require 'syd-display-startup-time)
(require 'syd-evil) (require 'syd-evil)
(require 'syd-keybinds) (require 'syd-keybinds)
(require 'syd-scratch)
(require 'syd-smartparens) (require 'syd-smartparens)
(require 'syd-ui) (require 'syd-ui)

View File

@@ -113,6 +113,7 @@ are active.")
(general-def (general-def
:keymaps 'syd-leader-map :keymaps 'syd-leader-map
"." #'find-file "." #'find-file
"x" `("Open scratch buffer" . ,#'scratch-buffer)
"b" `("Buffer" . ,syd-leader-buffer-map) "b" `("Buffer" . ,syd-leader-buffer-map)
"w" `("Window" . ,syd-leader-window-map) "w" `("Window" . ,syd-leader-window-map)
"f" `("File" . ,syd-leader-file-map) "f" `("File" . ,syd-leader-file-map)

View 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