From 3cb2f98be42b53aeea5edb65c9c1bde08a8496b1 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 9 May 2022 20:36:32 -0500 Subject: meh --- lisp/+scratch.el | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lisp/+scratch.el') diff --git a/lisp/+scratch.el b/lisp/+scratch.el index bd16ec2..e9b825a 100644 --- a/lisp/+scratch.el +++ b/lisp/+scratch.el @@ -7,7 +7,8 @@ (defun +scratch-immortal () "Bury, don't kill \"*scratch*\" buffer. For `kill-buffer-query-functions'." - (if (eq (current-buffer) (get-buffer "*scratch*")) + (if (or (eq (current-buffer) (get-buffer "*scratch*")) + (eq (current-buffer) (get-buffer "*text*"))) (progn (bury-buffer) nil) t)) @@ -35,5 +36,27 @@ For `kill-buffer-query-functions'." (concat (replace-regexp-in-string "^" ";; " s) "\n\n"))) +;; [[https://old.reddit.com/r/emacs/comments/ui1q41/weekly_tips_tricks_c_thread/i7ef4xg/][u/bhrgunatha]] +(defun +scratch-text-scratch () + "Create a \"*text*\" scratch buffer in Text mode." + (with-current-buffer (get-buffer-create "*text*") + (text-mode))) + +(defun +scratch-toggle (buffer) + "Switch to BUFFER, or to the previous buffer." + (switch-to-buffer (unless (eq (current-buffer) + (get-buffer buffer)) + buffer))) + +(defun +scratch-switch-to-scratch () + "Switch to scratch buffer." + (interactive) + (+scratch-toggle "*scratch*")) + +(defun +scratch-switch-to-text () + "Switch to text buffer." + (interactive) + (+scratch-toggle "*text*")) + (provide '+scratch) ;;; +scratch.el ends here -- cgit 1.4.1-21-gabe81