Subject: bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 09 Oct 2020 06:54:42 +0200

Corwin Brust <[email-masked]> writes:

> I hate it when I accidentally paste multi-line text into ERC.  I
> *never* actually intend to do this.

I sometimes want to, and sometimes I don't want to.  I think it would be
pretty surprising for users if we rebind `C-y' in this way.

I'm using a command that fixes whitespace and removes newlines from the
kill ring, which is perhaps more generally useful.  Let's see...

(global-set-key
 [(hyper y)]
 (lambda ()
   (interactive)
   (insert
    (with-temp-buffer
      (yank)
      (goto-char (point-min))
      (while (re-search-forward "[\t\n ]+" nil t)
        (replace-match " "))
      (goto-char (point-min))
      (when (re-search-forward " +$" nil t)
        (replace-match ""))
      (buffer-string)))))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no