Created
November 1, 2012 10:28
-
-
Save am0c/3992960 to your computer and use it in GitHub Desktop.
copy-region-as-fill in Emacs 24
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
;; copy region as `fill-region`ed even | |
;; in longlines-mode or visual-line-mode. | |
;; | |
;; thanks to @y0ngbin for this idea. | |
(global-set-key [?\C-x ?\M-w] 'copy-region-as-fill) | |
(defun copy-region-as-fill (beg end) | |
(interactive "r") | |
(when (region-active-p) | |
(kill-ring-save beg end) | |
(with-temp-buffer | |
(yank) | |
(mark-whole-buffer) | |
(fill-region (region-beginning) (region-end)) | |
(mark-whole-buffer) | |
(kill-ring-save (region-beginning) (region-end))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment