Commit 6b2dde8c08db
Changed files (2)
tools
emacs
config
users
vincent
dev
tools/emacs/config/config-editing.el
@@ -273,5 +273,30 @@ instead. This command can then be followed by the standard
:commands (htmlize-paste-it)
:bind ("C-c e p" . htmlize-paste-it))
+(use-package scratch
+ :commands (scratch)
+ :config
+ (defun vde/scratch-buffer-setup ()
+ "Add contents to `scratch' buffer and name it accordingly.
+If region is active, add its contents to the new buffer."
+ (let* ((mode major-mode)
+ (string (format "Scratch buffer for: %s\n\n" mode))
+ (region (with-current-buffer (current-buffer)
+ (if (region-active-p)
+ (buffer-substring-no-properties
+ (region-beginning)
+ (region-end)))
+ ""))
+ (text (concat string region)))
+ (when scratch-buffer
+ (save-excursion
+ (insert text)
+ (goto-char (point-min))
+ (comment-region (point-at-bol) (point-at-eol)))
+ (forward-line 2))
+ (rename-buffer (format "*Scratch for %s*" mode) t)))
+ :hook (scratch-create-buffer-hook . vde/scratch-buffer-setup)
+ :bind ("C-c s" . scratch))
+
(provide 'config-editing)
;;; config-editing.el ends here
users/vincent/dev/emacs.nix
@@ -110,6 +110,7 @@ let
rainbow-mode
rg
ripgrep
+ scratch
smartparens
symbol-overlay
try