Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defun my-copy-simple (&optional beg end)
"Save the current region (or line) to the `kill-ring' after stripping extra whitespace and new lines"
(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)))
(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