Re: [code] [textadept] run external app from editor

From: Mitchell <m.att.foicica.com>
Date: Sun, 27 Dec 2015 14:58:25 -0500 (EST)

Hi Thorsten,

On Sun, 27 Dec 2015, Thorsten Kampe wrote:

> Hi,
>
> I would like to be able to run two external commands from within the
> editor:
>
> 1. `runscript` with the argument of the filename in the current
> buffer. This should be possible for all file types - as runscript is
> a wrapping extension to interpreter. Output of `runscript` should go
> into a buffer of Textadept.

You can put something like this in your ~/.textadept/init.lua:

   keys.caa = function()
     if not buffer.filename then return end
     local dir, file = buffer.filename:match('^(.+)[/\\]([^/\\]+)$')
     spawn('runscript "'..file..'"', dir, ui.print, ui.print)
   end

(The function is bound to the Ctrl+Alt+A key, but you can make it whatever
you want.) All output will go into Textadept's message buffer.

> 2. `showdocs` with the arguments "devdocs", "full_name_of_file" and
> "selected text in editor". This will open a browser and so the output
> should not be captured.

Something like this should work:

    keys.caA = function()
      if not buffer.filename then return end
      local sel_text = buffer:get_sel_text()
      if sel_text == '' then return end
      spawn('showdocs devdocs "'..buffer.filename..'" "'..sel_text..'"')
    end

That is bound to Ctrl+Alt+Shift+A, and can be changed, naturally.

> How can I achieve this? I had a look at the "Compile and Run Code"
> section of Quick Reference but I didn't understand it.

Textadept's Compile and Run Code feature is useful for source files in
particular programming languages. Since your functionality is
language-agnostic, you would create a generic tool (function) to perform
it.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sun 27 Dec 2015 - 14:58:25 EST

This archive was generated by hypermail 2.2.0 : Mon 28 Dec 2015 - 06:45:41 EST