unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
@ 2020-10-07 14:11 Corwin Brust
  2020-10-07 15:27 ` Noam Postavsky
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Corwin Brust @ 2020-10-07 14:11 UTC (permalink / raw)
  To: 43847

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

This patch provides erc-yank and binds it to C-y for erc-mode buffers.
This does the same as `yank'; however, the text is unfilled (collapsed
to a single line) before it is inserted.

It might make sense to have a defcustom to get back the old behavior
but I haven't included that.  This is my second attempt at sharing a
patch for Emacs; I sent one about an hour ago.  I believe, taking both
patches together, I should be pretty close to the max for tiny-change.
I've started the copyright assignment process.

All feedback gratefully received :)


In GNU Emacs 27.1 (build 1, x86_64-w64-mingw32)
 of 2020-08-21 built on CIRROCUMULUS
Repository revision: 86d8d76aa36037184db0b2897c434cdaab1a9ae8
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.18363
System Description: Microsoft Windows 10 Home (v10.0.1909.18363.1082)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2
HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads w32notify w32 lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 46659 8583)
 (symbols 48 6075 1)
 (strings 32 16982 2021)
 (string-bytes 1 519943)
 (vectors 16 9274)
 (vector-slots 8 123598 13156)
 (floats 8 22 312)
 (intervals 56 222 0)
 (buffers 1000 12))

Corwin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 14:11 bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch* Corwin Brust
@ 2020-10-07 15:27 ` Noam Postavsky
  2020-10-07 15:30   ` Corwin Brust
  2020-10-07 16:56 ` Brett Gilio
  2020-10-09  4:54 ` Lars Ingebrigtsen
  2 siblings, 1 reply; 16+ messages in thread
From: Noam Postavsky @ 2020-10-07 15:27 UTC (permalink / raw)
  To: Corwin Brust; +Cc: 43847

Corwin Brust <corwin@bru.st> writes:

> I hate it when I accidentally paste multi-line text into ERC.  I
> *never* actually intend to do this.
>
> This patch provides erc-yank and binds it to C-y for erc-mode buffers.
> This does the same as `yank'; however, the text is unfilled (collapsed
> to a single line) before it is inserted.

> All feedback gratefully received :)

I think you may have forgotten to include the patch :)






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 15:27 ` Noam Postavsky
@ 2020-10-07 15:30   ` Corwin Brust
  2020-10-07 16:05     ` Noam Postavsky
  0 siblings, 1 reply; 16+ messages in thread
From: Corwin Brust @ 2020-10-07 15:30 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 43847

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

Goldarn.

On Wed, Oct 7, 2020 at 10:27 AM Noam Postavsky <npostavs@gmail.com> wrote:
>
> Corwin Brust <corwin@bru.st> writes:
>
> > All feedback gratefully received :)
>
> I think you may have forgotten to include the patch :)
>

Thanks so much Noam.

Corwin

[-- Attachment #2: erc-yank.patch --]
[-- Type: application/octet-stream, Size: 1237 bytes --]

diff -u "c:/emacs/share/emacs/27.1/lisp/erc/erc.el-27.1" "c:/emacs/share/emacs/27.1/lisp/erc/erc.el"
--- c:/emacs/share/emacs/27.1/lisp/erc/erc.el-27.1	2020-10-07 08:10:35.000000000 -0500
+++ c:/emacs/share/emacs/27.1/lisp/erc/erc.el	2020-10-07 08:19:36.205700600 -0500
@@ -1154,6 +1154,7 @@
     (define-key map "\C-m" 'erc-send-current-line)
     (define-key map "\C-a" 'erc-bol)
     (define-key map [home] 'erc-bol)
+    (define-key map "\C-y" 'erc-yank)
     (define-key map "\C-c\C-a" 'erc-bol)
     (define-key map "\C-c\C-b" 'erc-switch-to-buffer)
     (define-key map "\C-c\C-c" 'erc-toggle-interpret-controls)
@@ -4084,6 +4085,19 @@
         (setq erc-input-ring-index nil))
     (kill-line)))
 
+(defun erc-yank (&optional arg)
+  "Unfill then yank.  ARG is handled by `yank', which see."
+  (interactive)
+  (insert
+   (save-excursion
+     (with-temp-buffer
+       (yank arg)
+       (goto-char (point-min))
+       (let ((fill-column (point-max))
+	     (emacs-lisp-docstring-fill-column t))
+	 (fill-paragraph))
+       (buffer-string)))))
+
 (defun erc-complete-word-at-point ()
   (run-hook-with-args-until-success 'erc-complete-functions))
 

Diff finished.  Wed Oct  7 08:20:01 2020

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 15:30   ` Corwin Brust
@ 2020-10-07 16:05     ` Noam Postavsky
  2020-10-09  2:01       ` Corwin Brust
  0 siblings, 1 reply; 16+ messages in thread
From: Noam Postavsky @ 2020-10-07 16:05 UTC (permalink / raw)
  To: Corwin Brust; +Cc: 43847

I hope an ERC user will follow up (I think Bandali was going over ERC
patches at some point?), but just some general comments:

> diff -u "c:/emacs/share/emacs/27.1/lisp/erc/erc.el-27.1" "c:/emacs/share/emacs/27.1/lisp/erc/erc.el"

> +(defun erc-yank (&optional arg)
> +  "Unfill then yank.  ARG is handled by `yank', which see."
> +  (interactive)
> +  (insert
> +   (save-excursion

I believe the save-excursion is redundant since all the movement happens
inside a temp buffer.

> +     (with-temp-buffer
> +       (yank arg)
> +       (goto-char (point-min))
> +       (let ((fill-column (point-max))
> +	     (emacs-lisp-docstring-fill-column t))

I don't think binding emacs-lisp-docstring-fill-column should be needed?

> +	 (fill-paragraph))

The TAB character should be spaces instead.  I recommend (setq-default
indent-tabs-mode nil), or at least

    (defun my-lisp-mode-hook ()
      (setq-local indent-tabs-mode nil))
    (add-hook 'emacs-lisp-mode-hook #'my-lisp-mode-hook)

Note that if you edit the git repo, it comes with an indent-tabs-mode=nil
setting for emacs-lisp-mode in .dir-locals.el.

> +       (buffer-string)))))





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 14:11 bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch* Corwin Brust
  2020-10-07 15:27 ` Noam Postavsky
@ 2020-10-07 16:56 ` Brett Gilio
  2020-10-09  1:32   ` Corwin Brust
  2020-10-09  4:54 ` Lars Ingebrigtsen
  2 siblings, 1 reply; 16+ messages in thread
From: Brett Gilio @ 2020-10-07 16:56 UTC (permalink / raw)
  To: Corwin Brust; +Cc: 43847

Corwin Brust <corwin@bru.st> writes:

> I hate it when I accidentally paste multi-line text into ERC.  I
> *never* actually intend to do this.
>
> This patch provides erc-yank and binds it to C-y for erc-mode buffers.
> This does the same as `yank'; however, the text is unfilled (collapsed
> to a single line) before it is inserted.
>
> It might make sense to have a defcustom to get back the old behavior
> but I haven't included that.  This is my second attempt at sharing a
> patch for Emacs; I sent one about an hour ago.  I believe, taking both
> patches together, I should be pretty close to the max for tiny-change.
> I've started the copyright assignment process.
>
> All feedback gratefully received :)
>

A possible alternative behavior could be somewhat similar to what CIRCE
does, but may be more intensive to implement. CIRCE, when pasting
multiline content offers to send the content to a paste-service, and
then kills the URL to the buffer and sends that instead.

What if we had a paste.emacs.org that ERC could utilize here?

Just a thought.

Brett Gilio





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 16:56 ` Brett Gilio
@ 2020-10-09  1:32   ` Corwin Brust
  2020-10-09  1:59     ` Corwin Brust
  2020-10-09 14:32     ` Brett Gilio
  0 siblings, 2 replies; 16+ messages in thread
From: Corwin Brust @ 2020-10-09  1:32 UTC (permalink / raw)
  To: Brett Gilio; +Cc: 43847

Hi Brett!  Thanks so much for the reply!

On Wed, Oct 7, 2020 at 11:56 AM Brett Gilio <brettg@gnu.org> wrote:
>
> Corwin Brust <corwin@bru.st> writes:
>
> > I hate it when I accidentally paste multi-line text into ERC.  I
> > *never* actually intend to do this.
> >
> > This patch provides erc-yank and binds it to C-y for erc-mode buffers.
> > This does the same as `yank'; however, the text is unfilled (collapsed
> > to a single line) before it is inserted.
> >
> > It might make sense to have a defcustom to get back the old behavior
> > but I haven't included that.  This is my second attempt at sharing a
> > patch for Emacs; I sent one about an hour ago.  I believe, taking both
> > patches together, I should be pretty close to the max for tiny-change.
> > I've started the copyright assignment process.
> >
> > All feedback gratefully received :)
> >
>
> A possible alternative behavior could be somewhat similar to what CIRCE
> does, but may be more intensive to implement. CIRCE, when pasting
> multiline content offers to send the content to a paste-service, and
> then kills the URL to the buffer and sends that instead.

This is a wonderful suggestion.  Speaking for myself, personally, I'd
like to see it as somewhat of a secondary behavior, what sending a
prefix arg does, or something.  In any case a very fine feature,
indeed.

A quick perusal of CIRCE[1] (which looks lovely), suggests the present
approach there involves having various paste-services explicitly
supported.  Perhaps this could be implemented in terms of a
def-paste-service macro, of some sort.  I would expect some amount of
discussion may be involved in selecting an initial service or services
to support, as it were, of the the box.  Maybe that conversation would
be approprite to Emacs devel, in case this feature would be
interesting to a more general cross-section of users vs ERC/IRC.

> What if we had a paste.emacs.org that ERC could utilize here?

I think that's an excellet idea in several regards.  In addition to
simplifying, potentially trivializing the decision of what service to
support, it also leads to a bunch of links getting shared around which
point into the fsfverse.  It's a tiny bit of mind-share, but I'd be
inclined to take it.  That said, having a "branded" paste-service
"baked in" to Emacs would seem to me to stengthen the argument to
formalize the interface for people to setup their own; to make ours
easy and others hard would be very off-brand.

This is something I'd be happy to work on, but I'm not how we would
approach something like requesting a http facing new service, going
forward.

> Just a thought.

As I hope I made clear, I love it.

I'm tempted tho, to suggest we might move forward with my more trival
suggested change in the mean-time.

It seems like having something special at C-y in `erc-mode' is
probably on the road-map for any of this, and may make live easier for
ERC users somewhat more quickly than some of the other ideas discussed
so far can move.

>
> Brett Gilio


Regards,
Corwin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09  1:32   ` Corwin Brust
@ 2020-10-09  1:59     ` Corwin Brust
  2020-10-09 14:32     ` Brett Gilio
  1 sibling, 0 replies; 16+ messages in thread
From: Corwin Brust @ 2020-10-09  1:59 UTC (permalink / raw)
  To: Brett Gilio; +Cc: 43847

Hi again.

On Thu, Oct 8, 2020 at 8:32 PM Corwin Brust <corwin@bru.st> wrote:
>

>
> A quick perusal of CIRCE[1] (which looks lovely), suggests the present

I see that I forgot the link for the source I looked at.  Here it is:

[1] https://github.com/jorgenschaefer/circe/blob/master/lui-autopaste.el

Corwin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 16:05     ` Noam Postavsky
@ 2020-10-09  2:01       ` Corwin Brust
  2020-10-10  5:00         ` Corwin Brust
  0 siblings, 1 reply; 16+ messages in thread
From: Corwin Brust @ 2020-10-09  2:01 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 43847

[-- Attachment #1: Type: text/plain, Size: 1847 bytes --]

Many thanks, Noam.

On Wed, Oct 7, 2020 at 11:05 AM Noam Postavsky <npostavs@gmail.com> wrote:
>
> I hope an ERC user will follow up (I think Bandali was going over ERC
> patches at some point?), but just some general comments:

I'm hoping Bandali and other ERC users will look, also.  I spoke to
someone on ERC today who is using the (prior version), I believe and
has agreed to mention any issues or suggestions.  (They agreed with
you about e-l-d-f-c being irrelevant, which seems pretty darned
obvious to me now too.)

> > diff -u "c:/emacs/share/emacs/27.1/lisp/erc/erc.el-27.1" "c:/emacs/share/emacs/27.1/lisp/erc/erc.el"
>
> > +(defun erc-yank (&optional arg)
> > +  "Unfill then yank.  ARG is handled by `yank', which see."
> > +  (interactive)
> > +  (insert
> > +   (save-excursion
>
> I believe the save-excursion is redundant since all the movement happens
> inside a temp buffer.

Removed save-excursion, thank you.

>
> > +     (with-temp-buffer
> > +       (yank arg)
> > +       (goto-char (point-min))
> > +       (let ((fill-column (point-max))
> > +          (emacs-lisp-docstring-fill-column t))
>
> I don't think binding emacs-lisp-docstring-fill-column should be needed?

*Smacking of forehead*  Right you are.


> > +      (fill-paragraph))
>
> The TAB character should be spaces instead.  I recommend (setq-default
> indent-tabs-mode nil), or at least
>
>     (defun my-lisp-mode-hook ()
>       (setq-local indent-tabs-mode nil))
>     (add-hook 'emacs-lisp-mode-hook #'my-lisp-mode-hook)
>
> Note that if you edit the git repo, it comes with an indent-tabs-mode=nil
> setting for emacs-lisp-mode in .dir-locals.el.
>
> > +       (buffer-string)))))

I'm pulling master now.  This version was created after evaling your
suggested one-liner in my erc.el buffer & please let me know if that's
got it.

Again, thanks

Corwin

[-- Attachment #2: erc-yank_002_rm_save-excusrion-and-elsip-docstring-col.patch --]
[-- Type: application/octet-stream, Size: 1144 bytes --]

diff -u "c:/emacs/share/emacs/27.1/lisp/erc/erc.el-27.1" "c:/emacs/share/emacs/27.1/lisp/erc/erc.el"
--- c:/emacs/share/emacs/27.1/lisp/erc/erc.el-27.1	2020-10-07 08:10:35.000000000 -0500
+++ c:/emacs/share/emacs/27.1/lisp/erc/erc.el	2020-10-08 20:42:26.207684100 -0500
@@ -1155,6 +1155,7 @@
     (define-key map "\C-a" 'erc-bol)
     (define-key map [home] 'erc-bol)
     (define-key map "\C-c\C-a" 'erc-bol)
+    (define-key map "\C-y" 'erc-yank)
     (define-key map "\C-c\C-b" 'erc-switch-to-buffer)
     (define-key map "\C-c\C-c" 'erc-toggle-interpret-controls)
     (define-key map "\C-c\C-d" 'erc-input-action)
@@ -4084,6 +4085,16 @@
         (setq erc-input-ring-index nil))
     (kill-line)))
 
+(defun erc-yank (&optional arg)
+  "Unfill then yank.  ARG is handled by `yank', which see."
+  (interactive)
+  (with-temp-buffer
+    (yank arg)
+    (goto-char (point-min))
+    (let ((fix-column (point-max)))
+      (fill-paragraph))
+    (buffer-string)))
+
 (defun erc-complete-word-at-point ()
   (run-hook-with-args-until-success 'erc-complete-functions))
 

Diff finished.  Thu Oct  8 20:43:11 2020

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-07 14:11 bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch* Corwin Brust
  2020-10-07 15:27 ` Noam Postavsky
  2020-10-07 16:56 ` Brett Gilio
@ 2020-10-09  4:54 ` Lars Ingebrigtsen
  2020-10-09  7:52   ` Kévin Le Gouguec
  2 siblings, 1 reply; 16+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-09  4:54 UTC (permalink / raw)
  To: Corwin Brust; +Cc: 43847

Corwin Brust <corwin@bru.st> 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





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09  4:54 ` Lars Ingebrigtsen
@ 2020-10-09  7:52   ` Kévin Le Gouguec
  2020-10-09 15:41     ` Corwin Brust
  0 siblings, 1 reply; 16+ messages in thread
From: Kévin Le Gouguec @ 2020-10-09  7:52 UTC (permalink / raw)
  To: 43847

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Corwin Brust <corwin@bru.st> 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.

Seconded.  I think a whitespace-fixing yank command could be useful in
more situations than just ERC; OTOH I'd much rather keep C-y as a
"reliably dumb" yank in all contexts, at least by default.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09  1:32   ` Corwin Brust
  2020-10-09  1:59     ` Corwin Brust
@ 2020-10-09 14:32     ` Brett Gilio
  1 sibling, 0 replies; 16+ messages in thread
From: Brett Gilio @ 2020-10-09 14:32 UTC (permalink / raw)
  To: Corwin Brust, bandali; +Cc: 43847

Corwin Brust <corwin@bru.st> writes:

>
> As I hope I made clear, I love it.
>
> I'm tempted tho, to suggest we might move forward with my more trival
> suggested change in the mean-time.
>


Understood. I think it would be a great discussion to have with the ERC
people to further compliment the proposed change for future? I cc'ed
bandali to see what they think.

Brett Gilio





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09  7:52   ` Kévin Le Gouguec
@ 2020-10-09 15:41     ` Corwin Brust
  2020-10-09 16:00       ` Brett Gilio
  0 siblings, 1 reply; 16+ messages in thread
From: Corwin Brust @ 2020-10-09 15:41 UTC (permalink / raw)
  To: Kévin Le Gouguec, Lars Ingebrigtsen; +Cc: 43847, Amin Bandali

Hi Kévin and Lars.  CCd Amin on this one also :)

On Fri, Oct 9, 2020 at 2:54 AM Kévin Le Gouguec
<kevin.legouguec@gmail.com> wrote:
>
> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> > Corwin Brust <corwin@bru.st> 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.
>
> Seconded.  I think a whitespace-fixing yank command could be useful in
> more situations than just ERC; OTOH I'd much rather keep C-y as a
> "reliably dumb" yank in all contexts, at least by default.
>

I mean, diversity, right :)

This hasn't come up for me outside IRC/ERC, that I can recall, but it
definitely does makes sense to me that people would want an easy way
to strip new-lines when yanking in contexts out-side IRC. Any thoughts
as to the approach for this?  The first thing that occurs would be to
have an additional var akin to `yank-handled-properties' and
`yank-excluded-properties', perhaps `yank-unfilled'.  This would
change the behavior of `yank' when bound to a non-nil value.   I guess
we'd want a new function wrapping `yank' with the new var lexically
bound to t.  As for a default binding for this, I note that M-y
doesn't seem to do anything helpful when not proceeded by a C-y.
Maybe more special case logic there?

That said, I opened this bug with the goal of making it realy easy to
avoid accidental muli-line spaces when pasting into ERC.

To double confirm, both of you are saying that it is a frequent
use-case that you want to yank content including new-lines into
erc-mode buffers?

I'd really like to see something like a defcustom that can make the
default behavior of C-y for ERC buffers less IRC surly.   IMHO, making
this default to t is more newbie friendly, while those who have a
use-case for multi-line paste directly into ERC seem more likely to be
those who will know how to set the var.

  (defcustom erc-yank-unfilled t "When non-nill, ERC unfills before
inserting from the kill-ring.")

  (defun erc-yank (..)
    ..
    (let ((yank-unfilled erc-yank-unfilled))
      .. ))

Couple additional notes:

 -  I need to respin this to use [rebind] (thanks to wgreenhouse from #erc)
 -  I haven't written anything for News, which I suspect anything we
would decide on will end-up reaching

Thanks much,
Corwin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09 15:41     ` Corwin Brust
@ 2020-10-09 16:00       ` Brett Gilio
  2020-10-10 20:11         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 16+ messages in thread
From: Brett Gilio @ 2020-10-09 16:00 UTC (permalink / raw)
  To: Corwin Brust
  Cc: 43847, Lars Ingebrigtsen, Amin Bandali, Kévin Le Gouguec

Corwin Brust <corwin@bru.st> writes:
> This hasn't come up for me outside IRC/ERC, that I can recall, but it
> definitely does makes sense to me that people would want an easy way
> to strip new-lines when yanking in contexts out-side IRC. Any thoughts
> as to the approach for this?
>

After giving it more thought, perhaps a prefix arg is the correct way to
go here. It would be enough that people would not experience a breaking
change. Or, it could be such that ERC alerts in the echo buffer that you
are about to send a multiline paste and ask if it should be sanitized?

Brett Gilio





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09  2:01       ` Corwin Brust
@ 2020-10-10  5:00         ` Corwin Brust
  0 siblings, 0 replies; 16+ messages in thread
From: Corwin Brust @ 2020-10-10  5:00 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 43847, Amin Bandali

If you are using this patch please ROLLBACK. 😊

On Thu, Oct 8, 2020 at 9:01 PM Corwin Brust <corwin@bru.st> wrote:
>
> Many thanks, Noam.
>
> On Wed, Oct 7, 2020 at 11:05 AM Noam Postavsky <npostavs@gmail.com> wrote:
> >
> > I hope an ERC user will follow up (I think Bandali was going over ERC
> > patches at some point?), but just some general comments:
>
> I'm hoping Bandali and other ERC users will look, also.  [...]

This has unpleasant results when the point is not immediately after
the ERC prompt, and likely in other cases I haven't found.

For a next pass I plan to:
* use `erc-display-line' instead of `insert'
* remove the new binding while we discuss ideal approaches
* create from master and see if I can I get tabs/spaces correct
* CC emacs-erc in hopes of soliciting more inputs

Thanks to Amin and others for discussions on IRC this evening.

Regards
Corwin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-09 16:00       ` Brett Gilio
@ 2020-10-10 20:11         ` Lars Ingebrigtsen
  2020-10-10 20:22           ` Brett Gilio
  0 siblings, 1 reply; 16+ messages in thread
From: Lars Ingebrigtsen @ 2020-10-10 20:11 UTC (permalink / raw)
  To: Brett Gilio; +Cc: 43847, Corwin Brust, Amin Bandali, Kévin Le Gouguec

Brett Gilio <brettg@gnu.org> writes:

> Corwin Brust <corwin@bru.st> writes:
>> This hasn't come up for me outside IRC/ERC, that I can recall, but it
>> definitely does makes sense to me that people would want an easy way
>> to strip new-lines when yanking in contexts out-side IRC. Any thoughts
>> as to the approach for this?

I think a new command, like `yank-trim-whitespace', might be nice.  I
have no idea where I'd put something like that in the global keymap,
which is why I've never proposed it...

But we could put it somewhere in the erc keymap for sure.

> After giving it more thought, perhaps a prefix arg is the correct way to
> go here. It would be enough that people would not experience a breaking
> change. Or, it could be such that ERC alerts in the echo buffer that you
> are about to send a multiline paste and ask if it should be sanitized?

That sounds nice...  doesn't erc already have an (optional) way of
warning against multi-line yanks?

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





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch*
  2020-10-10 20:11         ` Lars Ingebrigtsen
@ 2020-10-10 20:22           ` Brett Gilio
  0 siblings, 0 replies; 16+ messages in thread
From: Brett Gilio @ 2020-10-10 20:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen
  Cc: 43847, Corwin Brust, Amin Bandali, Kévin Le Gouguec

Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> That sounds nice...  doesn't erc already have an (optional) way of
> warning against multi-line yanks?

Perhaps that is what `erc-toggle-flood-control' is.
https://www.gnu.org/software/emacs/manual/html_mono/erc.html#Concept-Index

Brett Gilio





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-10-10 20:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-07 14:11 bug#43847: ERC - prevent yanking multiple lines into IRC (feature request) *patch* Corwin Brust
2020-10-07 15:27 ` Noam Postavsky
2020-10-07 15:30   ` Corwin Brust
2020-10-07 16:05     ` Noam Postavsky
2020-10-09  2:01       ` Corwin Brust
2020-10-10  5:00         ` Corwin Brust
2020-10-07 16:56 ` Brett Gilio
2020-10-09  1:32   ` Corwin Brust
2020-10-09  1:59     ` Corwin Brust
2020-10-09 14:32     ` Brett Gilio
2020-10-09  4:54 ` Lars Ingebrigtsen
2020-10-09  7:52   ` Kévin Le Gouguec
2020-10-09 15:41     ` Corwin Brust
2020-10-09 16:00       ` Brett Gilio
2020-10-10 20:11         ` Lars Ingebrigtsen
2020-10-10 20:22           ` Brett Gilio

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).