[code] Confused about Events

From: DrTebi <drtebi.att.gmail.com>
Date: Fri, 2 Jan 2015 01:38:17 -0800

Hello,

I am a new Textadept user and have started to write some custom functions.

What I am trying to accomplish is the following when I am in 'rst'
mode (ReStructuredText):

- pressing Ctrl+S saves the file
- after saving the file Textadept runs an external command (rst2html)

From the manual I have gathered so far that I should create the file
~/.textadept/modules/rest/post_init.lua
And that I can then add this functionality somehow like this:

events.connect(events.LEXER_LOADED, function(lang)
  if lang == 'rest' then
    events.connect(events.FILE_AFTER_SAVE, function(f)
      os.execute('rst2html "%(filepath)" "%d%e.html"')
    end)
  end
end)

Before I actually tried the rst2html command, I tested this by
displaying a message box (ui.dialogs.ok_msgbox{title=f}) and noticed
that my function runs in every mode, not just rst.

Well, that's where the main problem is... I assume I have to put these
custom events somewhere else?

I would also appreciate help with constructing the rst2html command,
as I am not certain whether the %-variables can be used.

Thanks,
DrTebi

-- 
"The bitterness of poor quality remains long after the sweetness of
low price is forgotten."
-- 
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 Fri 02 Jan 2015 - 04:38:17 EST

This archive was generated by hypermail 2.2.0 : Fri 02 Jan 2015 - 06:31:45 EST