;;; scratch.el --- Custom scratchpads -*- lexical-binding: t -*- ;; This file is not part of GNU Emacs ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; commentary ;;; Code: ;; We have our own scratch buffers, don't need this (add-hook 'emacs-startup-hook (lambda () (when (get-buffer "*scratch*") (kill-buffer "*scratch*")))) (defcustom elisp-scratch-initial-contents ";; Emacs lisp scratch buffer\n\n" "Initial text for *elisp scratch*." :type 'string :group 'theurgy :group 'theurgy-scratch) (defcustom org-scratch-initial-contents "# Org scratch buffer\n\n" "Initial text for *org scratch*." :type 'string :group 'theurgy :group 'theurgy-scratch) (with-current-buffer (generate-new-buffer "*elisp scratch*") (insert elisp-scratch-initial-contents) (emacs-lisp-mode)) (with-current-buffer (generate-new-buffer "*org scratch*") (insert org-scratch-initial-contents) (org-mode)) (defun open-elisp-scratch () (interactive) (switch-to-buffer "*elisp scratch*")) (defun open-org-scratch () (interactive) (switch-to-buffer "*org scratch*")) (defun toggle-elisp-scratch () (interactive) (if (get-buffer-window "*elisp scratch*") (delete-window (get-buffer-window "*elisp scratch*")) (switch-to-buffer "*elisp scratch*"))) (defun toggle-org-scratch () (interactive) (if (get-buffer-window "*org scratch*") (delete-window (get-buffer-window "org scratch")) (switch-to-buffer "*org scratch*"))) (add-to-list 'display-buffer-alist '("\\*elisp scratch\\*" (display-buffer-in-side-window) (side . right) (slot . 1) (window-width . 0.2))) (add-to-list 'display-buffer-alist '("\\*org scratch\\*" (display-buffer-in-side-window) (side . right) (slot . 2) (window-width . 0.2))) (provide 'scratch) ;;; scratch.el ends here