diff options
author | Case Duckworth | 2022-05-23 20:12:53 -0500 |
---|---|---|
committer | Case Duckworth | 2022-05-23 20:12:59 -0500 |
commit | dd3afe747ecf51f87d33318c2ad68953d153495f (patch) | |
tree | c364d2c59741f68bb3f51e8a28f84a2a9712fd37 /lisp/+scratch.el | |
parent | Add timers (diff) | |
download | emacs-dd3afe747ecf51f87d33318c2ad68953d153495f.tar.gz emacs-dd3afe747ecf51f87d33318c2ad68953d153495f.zip |
meh
Diffstat (limited to 'lisp/+scratch.el')
-rw-r--r-- | lisp/+scratch.el | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lisp/+scratch.el b/lisp/+scratch.el index e9b825a..7fc2bde 100644 --- a/lisp/+scratch.el +++ b/lisp/+scratch.el | |||
@@ -35,18 +35,33 @@ For `kill-buffer-query-functions'." | |||
35 | "ABANDON ALL HOPE YE WHO ENTER HERE")))) | 35 | "ABANDON ALL HOPE YE WHO ENTER HERE")))) |
36 | (concat (replace-regexp-in-string "^" ";; " s) | 36 | (concat (replace-regexp-in-string "^" ";; " s) |
37 | "\n\n"))) | 37 | "\n\n"))) |
38 | 38 | ||
39 | ;; [[https://old.reddit.com/r/emacs/comments/ui1q41/weekly_tips_tricks_c_thread/i7ef4xg/][u/bhrgunatha]] | 39 | ;; [[https://old.reddit.com/r/emacs/comments/ui1q41/weekly_tips_tricks_c_thread/i7ef4xg/][u/bhrgunatha]] |
40 | (defun +scratch-text-scratch () | 40 | (defun +scratch-text-scratch () |
41 | "Create a \"*text*\" scratch buffer in Text mode." | 41 | "Create a \"*text*\" scratch buffer in Text mode." |
42 | (with-current-buffer (get-buffer-create "*text*") | 42 | (with-current-buffer (get-buffer-create "*text*") |
43 | (text-mode))) | 43 | (text-mode))) |
44 | 44 | ||
45 | (defcustom +scratch-buffers '("*text*" "*scratch*") | ||
46 | "Scratch buffers.") | ||
47 | |||
48 | (defvar +scratch-last-non-scratch-buffer nil | ||
49 | "Last buffer that wasn't a scratch buffer.") | ||
50 | |||
45 | (defun +scratch-toggle (buffer) | 51 | (defun +scratch-toggle (buffer) |
46 | "Switch to BUFFER, or to the previous buffer." | 52 | "Switch to BUFFER, or to the previous (non-scratch) buffer." |
47 | (switch-to-buffer (unless (eq (current-buffer) | 53 | (if (or (null +scratch-last-non-scratch-buffer) |
48 | (get-buffer buffer)) | 54 | (not (member (buffer-name (current-buffer)) +scratch-buffers))) |
49 | buffer))) | 55 | ;; Switch to a scratch buffer |
56 | (progn | ||
57 | (setq +scratch-last-non-scratch-buffer (current-buffer)) | ||
58 | (switch-to-buffer buffer)) | ||
59 | ;; Switch away from scratch buffer ... | ||
60 | (if (equal (get-buffer-create buffer) (current-buffer)) | ||
61 | ;; to the original buffer | ||
62 | (switch-to-buffer +scratch-last-non-scratch-buffer) | ||
63 | ;; to another scratch | ||
64 | (switch-to-buffer buffer)))) | ||
50 | 65 | ||
51 | (defun +scratch-switch-to-scratch () | 66 | (defun +scratch-switch-to-scratch () |
52 | "Switch to scratch buffer." | 67 | "Switch to scratch buffer." |