Add doom/copy-buffer-contents command

To make it easier for beginners to copy content from logs or backtrace
windows.
This commit is contained in:
Henrik Lissner 2020-11-04 19:41:48 -05:00
parent 0446c2a853
commit 611fdade09
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -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