zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: [PATCH] bracketed-paste: change quoting style
Date: Tue, 11 Aug 2015 23:44:37 -0700	[thread overview]
Message-ID: <150811234437.ZM31842@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3RGk_S8sZAsW9qqLt=fyRRzOCDjk4imE0ZPDyOBLEB9xA@mail.gmail.com>

On Aug 12,  5:13am, Mikael Magnusson wrote:
} Subject: Re: [PATCH] bracketed-paste: change quoting style
}
} On Wed, Aug 12, 2015 at 4:52 AM, Bart Schaefer
} <schaefer@brasslantern.com> wrote:
} > I'm tempted simply to suggest that bracketed-paste should get
} > out of the way if there are no newlines in the pasted text, but
} > there may be other bindings that shouldn't run.
} 
} It's also nice for avoiding various other problems, like tabs.

How about this?

    bracketed-paste-magic() {
      local PASTED
      zle .bracketed-paste PASTED
      zle -U - $PASTED
      while [[ -n $PASTED ]] && zle .read-command
      do
	PASTED=${PASTED#$KEYS}
	case $REPLY in
	(self-insert*) zle $REPLY;;
	(*) zle self-insert-unmeta;;
	esac
      done
    }
    zle -N bracketed-paste bracketed-paste-magic

I actually wonder if implementing the above loop in C might not be
preferable to flatly calling doinsert().

} I feel like the widget is already getting quite DWIMmy, and what "we"
} mean might not be what everyone else means. (I'm not even convinced we
} all want the things it's already doing).

Yes, the above breaks the (so far undocumented?) vi-mode cutbuffer stuff,
doesn't handle overwriting the region or setting undo points, probably
breaks somehow with multibyte characters, etc.

} I would also argue that intentionally putting text in the paste buffer
} to invoke widgets by pasting it is somewhat perverse

I'm not sure what you're talking about here.  I'd put text in the paste
buffer in order to paste it.  For pasting to result in a widget being
invoked is no different than any other interaction with the editor and
amounts to an implemention detail of the real desire, which is to paste
the text without something unexpected happening.

Of course if what you are expecting is for it to behave as if you typed
each character individually, bracketed-paste is going to confuse you.  

} and if you want to do it, you get to change the default configuration
} to do it. It shouldn't depend on something mostly orthogonal like if
} there is a newline.

"If there is a newline" is shorthand for "if any action other than a
self-insert would occur".

} I thought earlier we may even want to add a
} bracketed-paste-raw/simple/literal function that just does what
} bracketed-paste does in the case of being passed a parameter, but also
} inserts it on the command line for you, and nothing more.

Yes, I could see the utility of this.


  reply	other threads:[~2015-08-12  6:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-11 22:09 Daniel Shahaf
2015-08-12  1:08 ` Mikael Magnusson
2015-08-12  2:52   ` Bart Schaefer
2015-08-12  3:13     ` Mikael Magnusson
2015-08-12  6:44       ` Bart Schaefer [this message]
2015-08-13 14:49 ` Oliver Kiddle
2015-08-13 16:20   ` Bart Schaefer
2015-08-13 23:19     ` Daniel Shahaf
2015-08-13 23:57       ` Bart Schaefer
2015-08-17 21:59         ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150811234437.ZM31842@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).