summary refs log tree commit diff stats
path: root/lisp/+scratch.el
diff options
context:
space:
mode:
authorCase Duckworth2022-05-09 20:36:32 -0500
committerCase Duckworth2022-05-09 20:36:32 -0500
commit3cb2f98be42b53aeea5edb65c9c1bde08a8496b1 (patch)
treede71c6862970519cc34e5cc38119b4d25d5c0362 /lisp/+scratch.el
parentDon't query to install pdf-tools (diff)
downloademacs-3cb2f98be42b53aeea5edb65c9c1bde08a8496b1.tar.gz
emacs-3cb2f98be42b53aeea5edb65c9c1bde08a8496b1.zip
meh
Diffstat (limited to 'lisp/+scratch.el')
-rw-r--r--lisp/+scratch.el25
1 files changed, 24 insertions, 1 deletions
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 @@
7(defun +scratch-immortal () 7(defun +scratch-immortal ()
8 "Bury, don't kill \"*scratch*\" buffer. 8 "Bury, don't kill \"*scratch*\" buffer.
9For `kill-buffer-query-functions'." 9For `kill-buffer-query-functions'."
10 (if (eq (current-buffer) (get-buffer "*scratch*")) 10 (if (or (eq (current-buffer) (get-buffer "*scratch*"))
11 (eq (current-buffer) (get-buffer "*text*")))
11 (progn (bury-buffer) 12 (progn (bury-buffer)
12 nil) 13 nil)
13 t)) 14 t))
@@ -35,5 +36,27 @@ For `kill-buffer-query-functions'."
35 (concat (replace-regexp-in-string "^" ";; " s) 36 (concat (replace-regexp-in-string "^" ";; " s)
36 "\n\n"))) 37 "\n\n")))
37 38
39;; [[https://old.reddit.com/r/emacs/comments/ui1q41/weekly_tips_tricks_c_thread/i7ef4xg/][u/bhrgunatha]]
40(defun +scratch-text-scratch ()
41 "Create a \"*text*\" scratch buffer in Text mode."
42 (with-current-buffer (get-buffer-create "*text*")
43 (text-mode)))
44
45(defun +scratch-toggle (buffer)
46 "Switch to BUFFER, or to the previous buffer."
47 (switch-to-buffer (unless (eq (current-buffer)
48 (get-buffer buffer))
49 buffer)))
50
51(defun +scratch-switch-to-scratch ()
52 "Switch to scratch buffer."
53 (interactive)
54 (+scratch-toggle "*scratch*"))
55
56(defun +scratch-switch-to-text ()
57 "Switch to text buffer."
58 (interactive)
59 (+scratch-toggle "*text*"))
60
38(provide '+scratch) 61(provide '+scratch)
39;;; +scratch.el ends here 62;;; +scratch.el ends here