Re: How to implement custom compile/run commands?

From: Robert <ro....at.web.de>
Date: Tue, 11 May 2010 10:56:12 +0200

On Tue, May 11, 2010 at 1:21 AM, phayz <russelldicken....at.gmail.com> wrote:
> On May 11, 8:20 am, phayz <russelldicken....at.gmail.com> wrote:
>> On May 11, 2:36 am, mitchell <mforal.n....at.gmail.com> wrote:
>>
>>
>>
>> > Hi Russell,
>>
>> > On May 10, 1:30 am, phayz <russelldicken....at.gmail.com> wrote:
>>
>> > > I have searched and browsed this group and Textadept's documentation
>> > > but I am still not sure how I implement language-specific compile/run
>> > > commands.
>>
>> > > I browsed textadept\modules\textadept\run.lua and in that file found
>> > > the text -
>> > > "-- Module for running/executing source files.
>> > > -- Typically, language-specific modules populate the
>> > > 'compile_command',
>> > > -- 'run_command', and 'error_detail' tables for a particular
>> > > language's file
>> > > -- extension."
>>
>> > > With that information I then browsed and opened the file textadept
>> > > \modules\cpp\commands.lua and in that file found the text -
>> > > "-- Commands for the cpp module.
>> > > module('_m.cpp.commands', package.seeall)"
>>
>> > > The lines immediately following this text configured the 'run' and
>> > > 'compile' commands for this file type.
>>
>> > > Although I don't fully understand the patterns used, I get the gist of
>> > > these files.
>>
>> > > If I want to implement, for example, hypertext-specific 'run' and
>> > > 'compile' commands, would I create a textadept\modules\hypertext
>> > > \commands.lua file and in it, detail the appropriate commands?
>>
>> > > If my understanding of how file type-specific 'run' and 'compile'
>> > > commands is incorrect, as usual I am open to constructive criticism.
>>
>> > -- modules/hypertext/commands.lua
>>
>> > local m_run = _m.textadept.run
>>
>> > m_run.compile_command.hypertext = "tidy %(filename)"
>> > m_run.run_command.hypertext = "firefox file://%(filename)"
>>
>> > Maybe I am misunderstanding your question.
>>
>> > Mitchell
>>
>> > > Regards,
>>
>> > > Russell Dickenson
>>
>> Mitchell,
>>
>> You understand my question perfectly! :)  In reply to your answer, I
>> don't have a modules/hypertext/commands.lua module. Is this part of a
>> commit made after 2.2 beta 2 was released? I am currently running 2.2
>> beta 2 under Windows.
>>
>> Regards,
>>
>> Russell Dickenson
>
> Mitchell,
>
> Sorry, I realise I may have complicated things even more with my
> reply. In your reply are you providing an *example* of how I might
> implement custom 'run' and 'compile' commands, or are you pointing me
> to a file which should already exist in my instance of Textadept? In
> implementing an XML tags autocomplete module, also hypertext snippets,
> I have a "modules/hypertext/commands.lua" in my personal Textadept
> directory. I added the to this file the lines in your reply but
> selecting 'Run' and 'Compile' from Textadept's menu have no effect at
> all. I don't get any error messages etc, so I don't know where I might
> be going wrong. I will try to replace my hypertext commands.lua with
> only the lines that you provided and see if this works.
>
>
> Regards,
>
> Russell Dickenson
>
Russell,
just to make sure, do you have a file modules/hypertext/init.lua ?
A file commands.lua would not get loaded automatically.
It should look something like this:

-- The hypertext module.
-- It provides utilities for editing Hypertext.
module('_m.hypertext', package.seeall)

if type(_G.snippets) == 'table' then

---
-- @class table
-- @name snippets.hypertext
  _G.snippets.hypertext = {}
end
if type(_G.keys) == 'table' then
---
-- @class table
-- @name keys.hypertext
  _G.keys.hypertext = {}
end
require 'hypertext.commands'
require 'hypertext.snippets'
function set_buffer_properties()
end
Assuming that you have a file hypertext/snippets.lua as well.
Alternatively you could
require 'hypertext.commands'
in your .textadept/init.lua but simply copying the design of the
existing modules is probably better.
Robert
-- 
You received this message because you are subscribed to the Google Groups "textadept" group.
To post to this group, send email to textadept.at.googlegroups.com.
To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
Received on Tue 11 May 2010 - 04:56:12 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:45:25 EST