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

From: Mitchell <>
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)

(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..'"')

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


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
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