Pass word at cursor to 'run' function?

  • Mike Sanders

    Mike Sanders - 2009-10-07

    Is there any way to pass the word at the cursor to 'run'? Example:

    :def foo run, " $WORD_AT_CURSOR", rtn

    I know 'filt' can manage something close, but in this case, I'm not wanting to insert any data back into the document, but rather only pass the word to an external program. eg:

    lynx google-for-word-at-cursor

  • Joe Allen

    Joe Allen - 2015-03-28

    Use block copy for this:

    psh, -- Save markb/markk so they get restored at end of macro
    nextword,markk,prevword,markb, -- Mark word under cursor
    run,"lynx ",blkcpy,rtn -- Run program with argument

    Even so, this is not going to do quite what you want since the output of run is inserted into the buffer. But now with JOE 4.0 we have pop-up shell windows, so you could run the lynx command in JOE. You want to run something like this:

    lynx -accept_all_cookies

    Try this:

    psh,nextword,markk,prevword,markb,shell4!,killproc!,"y",shell4!,"lynx -accept-all-cookies",txt,blkcpy,rtn,rtn

    Mark the word. Switch to shell window. Kill already running program in it. Run shell window again to get a clean start, insert lynx command, use txt to insert the word. One issue is lack of quoting.

  • Joe Allen

    Joe Allen - 2015-03-28

    Played around with it some more: best so far:

    :def goog psh,nextword,markk,prevword,markb,shell4!,"qy\x0d\x0d","lynx -accept-all-cookies",txt,blkcpy,rtn,"\x0d"

    So if lynx is already running it tries to quit it first. JOE needs a better way to restart the shell for things like this.

    (there is a program 'urlencode' which could be used to quote the search argument)


Log in to post a comment.