Created
April 14, 2020 05:50
-
-
Save shrysr/da4c711a0867b62323bd372d0352cd44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; http://emacs.stackexchange.com/questions/1051/copy-region-from-emacs-without-newlines | |
(defun my-copy-simple (&optional beg end) | |
"Save the current region (or line) to the `kill-ring' after stripping extra whitespace and new lines" | |
(interactive | |
(if (region-active-p) | |
(list (region-beginning) (region-end)) | |
(list (line-beginning-position) (line-end-position)))) | |
(let ((my-text (buffer-substring-no-properties beg end))) | |
(with-temp-buffer | |
(insert my-text) | |
(goto-char 1) | |
(while (looking-at "[ \t\n]") | |
(delete-char 1)) | |
(let ((fill-column 9333999)) | |
(fill-region (point-min) (point-max))) | |
(kill-region (point-min) (point-max))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment