From 611fdade09c40b42b56ee1c2a9af85e005b1a367 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 4 Nov 2020 19:41:48 -0500 Subject: [PATCH] Add doom/copy-buffer-contents command To make it easier for beginners to copy content from logs or backtrace windows. --- core/autoload/debug.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/autoload/debug.el b/core/autoload/debug.el index ef5832dae..0410e03bd 100644 --- a/core/autoload/debug.el +++ b/core/autoload/debug.el @@ -450,6 +450,21 @@ will be automatically appended to the result." (interactive) (browse-url "https://github.com/hlissner/doom-emacs/issues/new/choose")) +;;;###autoload +(defun doom/copy-buffer-contents (buffer-name) + "Copy the contents of BUFFER-NAME to your clipboard." + (interactive + (list (if current-prefix-arg + (completing-read "Select buffer: " (mapcar #'buffer-name (buffer-list))) + (buffer-name (current-buffer))))) + (let ((buffer (get-buffer buffer-name))) + (unless (buffer-live-p buffer) + (user-error "Buffer isn't live")) + (kill-new + (with-current-buffer buffer + (substring-no-properties (buffer-string)))) + (message "Contents of %S were copied to the clipboard" buffer-name))) + ;; ;;; Profiling