vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] X copy/paste from xterm vile


From: Thomas Dickey
Subject: Re: [vile] X copy/paste from xterm vile
Date: Thu, 09 Aug 2007 17:00:16 -0400
User-agent: Mutt/1.5.16 (2007-06-11)

On Thu, Aug 09, 2007 at 11:42:17AM -0400, Daniel L. Ashbrook wrote:
> I was discussing vim vs vile vs emacs yesterday with a friend
> (explaining how 12 years of finger-feel of vile makes even thinking about
> chaning editors crazy) and he mentioned writing some vim macros to access
> the X (and OSX) clipboards from vim. He said that the '*' register in vim
> mirrors the state of the X clipboard, and under OSX he wrote a macro to
> use pbcopy and pbpaste to do the same thing.
> 
> That started me trying to figure out how to do the same sort of thing in
> vile. I guess one solution would be to allow the console version of vile
> to access the X clipboard (much as it changes the xterm title), but I
> don't enjoy mucking around with X code particularly so I'll leave that
> for Tom. The other solution I thought of was to pipe the contents of the
> unamed register (or some other) through the xclip program, which puts
> stdin onto the X clipboard (pbcopy does the same sort of thing on OSX)
> or puts the X clipboard onto stdout (pbpaste on OSX).
> 
> As it turns out, it's been a couple of years since I did vile macro
> programming and am apparently quite rusty now. Anyone have any
> advice? I started with this:
> 
> ;;Copy the current copy buffer to the clipboard
> store-procedure copy
>   set-variable %text &register 0
>   shell-command &cat &cat "cat | xclip -i" %text ^D
> ~endm
> 
> but it doesn't seem to quite work. For one, shell-command pauses to give
> you a chance to read output, which isn't appropriate in this case. The
> other ideal way to do it would be something like

right - you can make vile open a new buffer to show the result though.
Something like (untested)

        store-procedure copy
          set-variable %text &register 0
          edit-file \
                &cat    '!echo "Copying to clipboard..."; xclip -i <' \
                        %text
        ~endm

Some of vile's macros temporarily switch to another buffer and then go
back to the current buffer (see loaderrs.rc).
 
> store-procedure copy
>       filter-til get-movement-command "xclip -i"
> ~endm
> bind-key copy ^A-^C
> 
> and then ^A-^C5} would put the next 5 paragraphs onto the clipboard;
> unfortunately for me, get-movement-command doesn't exist.

That's an idea - though it seems that providing a macro parameter type
which is a motion would fit in better (I'm not sure which would be
easier to implement).  That is, 

        store-procedure copy goto="Motion"
                filter-til $1 "xclip -i"
        ~endm
        bind-key copy ^A-^C

For the special macro parameters that vile knows about, omitting one will
cause it to prompt for the parameter of the given type.  (I changed that
from "motion" to "goto" to allow one-character uniqueness...)

Anyway - the point of providing it in the macro parameters is that it
would be easier to make the result macro look like a "real" command.
A get-movement-command would prompt within the macro, possibly past
other prompts.

As a function, there's the &gtkey and &gtsequence functions.  Adding
a &gtmotion" would fit in, in that way.

> Any thoughts (or modifications to vile code! get-movement-command would
> be useful for a number of other macros I've been contemplating... ) would
> be most welcome.
> 
> 
> 
> dan
> 
> 
> _______________________________________________
> vile mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/vile

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]