From aab5bfd074e57d06a79e39d7c7c4760e1f385a06 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 17 Oct 2022 21:41:28 -0500 Subject: Bankruptcy 9 --- lisp/+scratch.el | 77 -------------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 lisp/+scratch.el (limited to 'lisp/+scratch.el') diff --git a/lisp/+scratch.el b/lisp/+scratch.el deleted file mode 100644 index 7fc2bde..0000000 --- a/lisp/+scratch.el +++ /dev/null @@ -1,77 +0,0 @@ -;;; +scratch.el -*- lexical-binding: t; -*- - -;;; Code: - -;;(require 'scratch) - -(defun +scratch-immortal () - "Bury, don't kill \"*scratch*\" buffer. -For `kill-buffer-query-functions'." - (if (or (eq (current-buffer) (get-buffer "*scratch*")) - (eq (current-buffer) (get-buffer "*text*"))) - (progn (bury-buffer) - nil) - t)) - -(defun +scratch-buffer-setup () - "Add comment to `scratch' buffer and name it accordingly." - (let* ((mode (format "%s" major-mode)) - (string (concat "Scratch buffer for:" mode "\n\n"))) - (when scratch-buffer - (save-excursion - (insert string) - (goto-char (point-min)) - (comment-region (point-at-bol) (point-at-eol))) - (next-line 2)) - (rename-buffer (concat "*scratch<" mode ">*") t))) - -(defun +scratch-fortune () - (let* ((fmt (if (executable-find "fmt") - (format "| fmt -%d -s" (- fill-column 2)) - "")) - (s (string-trim - (if (executable-find "fortune") - (shell-command-to-string (concat "fortune -s" fmt)) - "ABANDON ALL HOPE YE WHO ENTER HERE")))) - (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))) - -(defcustom +scratch-buffers '("*text*" "*scratch*") - "Scratch buffers.") - -(defvar +scratch-last-non-scratch-buffer nil - "Last buffer that wasn't a scratch buffer.") - -(defun +scratch-toggle (buffer) - "Switch to BUFFER, or to the previous (non-scratch) buffer." - (if (or (null +scratch-last-non-scratch-buffer) - (not (member (buffer-name (current-buffer)) +scratch-buffers))) - ;; Switch to a scratch buffer - (progn - (setq +scratch-last-non-scratch-buffer (current-buffer)) - (switch-to-buffer buffer)) - ;; Switch away from scratch buffer ... - (if (equal (get-buffer-create buffer) (current-buffer)) - ;; to the original buffer - (switch-to-buffer +scratch-last-non-scratch-buffer) - ;; to another scratch - (switch-to-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