简体   繁体   中英

Copy result of a region operation to kill ring

I have the following code in Emacs that removes line breaks in a highlighted region:

(defun remove-newlines-in-region ()
  "Removes all newlines in the region."
  (interactive)
  (save-restriction
    (narrow-to-region (point) (mark))
    (goto-char (point-min))
    (while (search-forward "\n" nil t) (replace-match "" nil t))))

I would to expand this function to also automatically copy (not kill) the result to the kill ring. How can I do this?

(kill-ring-save (point-min) (point-max))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM