I believe I was doing a bit wrong earlier; it's fixed now ( https://github.com/kaushalmodi/.emacs.d/commit/822854333cd2cc05c2b4cfe642925f832cf40cfb ). ===== (defun modi/region-extract-function--C-u-kill (orig delete) "When a region is selected, and if \\[universal-argument] is used, and DELETE is \\='delete (when doing \\[kill-region]), or DELETE is nil (when doing \\[kill-ring-save]), kill the region with all trailing whitespace removed and also replace 2 or more spaces with single spaces. Else, execute ORIG function." (if (and (region-beginning) (eq 4 (prefix-numeric-value current-prefix-arg)) ; when using C-u, and (or (eq delete 'delete) ; when cutting (C-w), or (eq delete nil))) ; when copying (M-w) (let ((sel (filter-buffer-substring (region-beginning) (region-end) delete))) (with-temp-buffer (insert sel) (delete-trailing-whitespace) (goto-char (point-min)) (while (re-search-forward "\\s-\\{2,\\}" nil :noerror) (replace-match " ")) (buffer-string))) (funcall orig delete))) (add-function :around region-extract-function #'modi/region-extract-function--C-u-kill) ===== So now it is probably more immune to future changes to the default value of region-extract-function. Thanks for the tip to look into add-function.