Bug#504244: Vim script to turn on and use xterm bracketed paste mode

2014-02-07 Thread Josh Triplett
On Wed, Dec 23, 2009 at 02:27:01AM -0800, Josh Triplett wrote:
 The following, added somewhere vim runs at startup, will use xterm's
 bracketed paste mode to make pasting automatically enable paste mode
 (and insert mode).  Also works fine in ~/.vimrc .
 
 if term == xterm
 let t_ti = t_ti . \e[?2004h
 let t_te = \e[?2004l . t_te
 function XTermPasteBegin(ret)
 set pastetoggle=Esc[201~
 set paste
 return a:ret
 endfunction
 map expr Esc[200~ XTermPasteBegin(i)
 imap expr Esc[200~ XTermPasteBegin()
 endif

I received a question via private email regarding the licensing of this
snippet, which hadn't occurred to me.  (The request was regarding the
use of this as the basis for implementing support for Emacs.)  I suppose
I'd originally figured that if vim wanted to incorporate it, it could do
so under the vim license.  However, given that (pleasantly unexpected)
request, I'll be more explicit, and more permissive:

Feel free to use this code under any of the vim license, the MIT
license, or the GPL version 2 or later, whatever's convenient for the
context you want to use it in.  (MIT is compatible with both of the
other two, but I'm mentioning them explicitly to avoid any need for a
prospective user to include the terms of the MIT license if dropping
this into a project under the vim license or the GPL.)

In my opinion, I'd also suggest that this code seems so short and so
directly based on the definition of bracketed paste mode that any
reimplementation for another editor (in another language and using
another editor's features in place of things like vim's paste mode)
would almost certainly be sufficiently different so as to no longer be a
derived work of the snippet above, and not subject to the above license
at all.

It's sad that this mail is longer than the snippet it references.

Hope that helps,
Josh Triplett


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#504244: Vim script to turn on and use xterm bracketed paste mode

2009-12-23 Thread Josh Triplett
tags 504244 + patch
thanks

Well, most of the patch, anyway.

The following, added somewhere vim runs at startup, will use xterm's
bracketed paste mode to make pasting automatically enable paste mode
(and insert mode).  Also works fine in ~/.vimrc .

if term == xterm
let t_ti = t_ti . \e[?2004h
let t_te = \e[?2004l . t_te
function XTermPasteBegin(ret)
set pastetoggle=Esc[201~
set paste
return a:ret
endfunction
map expr Esc[200~ XTermPasteBegin(i)
imap expr Esc[200~ XTermPasteBegin()
endif

Note that this will only work in terminals which implement bracketed
paste mode.  This includes xterm, but not necessarily every terminal
with TERM=xterm; however, it shouldn't do any harm if bracketed paste
mode doesn't exist, assuming the terminal at least knows to ignore
enable/disable commands for modes it doesn't know about.

Due to limitations of paste mode, I couldn't make this work if already
*in* paste mode (because vim doesn't interpret mappings), nor can I
avoid overwriting pastetoggle (because I don't have a place to restore
it from after the paste finishes).  However, note that I don't overwrite
pastetoggle unless the bracketed paste mode works.  Native support for
bracketed paste modes in vim could potentially avoid both of those problems.

- Josh Triplett



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org