[code] Re: Digest of code@foicica.com issue 145 (828-839)

From: Sandeep Datta <datta.sandeep.att.gmail.com>
Date: Thu, 9 May 2013 21:52:00 +0530

Mitchel and Rob,

Thanks a lot for your help. Your suggestions have been very helpful.

Regards,
Sandeep Datta.

On Tue, May 7, 2013 at 7:30 AM, <code+help.att.foicica.com> wrote:

> Topics (messages 828 through 839):
>
> [code] Kudos
> 828 - Sandeep Datta <datta.sandeep.att.gmail.com>
>
> [code] Kudos
> 829 - Robert <rob.g.att.web.de>
>
> [code] Do the GUI and curses versions of Textadept use the same code?
> 830 - Russell Dickenson <russelldickenson.att.gmail.com>
>
> [code] I need help adding a language-specific snippet
> 831 - Russell Dickenson <russelldickenson.att.gmail.com>
>
> [code] I need help adding a language-specific snippet
> 832 - Mitchell <m.att.foicica.com>
>
> [code] Do the GUI and curses versions of Textadept use the same code?
> 833 - Mitchell <m.att.foicica.com>
>
> [code] Kudos
> 834 - Mitchell <m.att.foicica.com>
>
> [code] I need help adding a language-specific snippet
> 835 - Russell Dickenson <russelldickenson.att.gmail.com>
>
> [code] Do the GUI and curses versions of Textadept use the same code?
> 836 - Russell Dickenson <russelldickenson.att.gmail.com>
>
> [code] I need help adding a language-specific snippet
> 837 - Russell Dickenson <russelldickenson.att.gmail.com>
>
> [code] I need help adding a language-specific snippet
> 838 - Mitchell <m.att.foicica.com>
>
> [code] I need help adding a language-specific snippet
> 839 - Russell Dickenson <russelldickenson.att.gmail.com>
>
>
>
> Hi Mitchell,
>
> I chanced upon Textadept while looking for a good text editor in Ubuntu.
> Using Textadept has been a pleasure. Hats off to you for creating this
> wonderful piece of software and sharing it with the world.
>
> However I do have a few requests to make to help improve my workflow with
> Textadept...
>
> 1. Invoking the find bar by pressing Ctrl+F does not copy the currently
> highlighted text to the find textbox (as is the norm in editors these days)
>
> 2. I am missing the ability to use regular expressions for search. I
> understand keeping the code size to a minimum is a important goal for this
> project. But is it possible for you to provide an API for using external
> search and replace algorithms? If you already have kindly point me towards
> some documentation.
>
> 3. Running textadept-curses file.ext produces the following error:-
> /home/sandeepd/Misc/textadept/core/file_io.lua:142: bad argument #1 to
> 'iconv' (string expected, got nil)
>
> 4. Errors do not appear in a "dialog" in the ncurses version so it makes
> it difficult to know that pressing CTRL+Q to quit will not work unless you
> press ESC first. Press CTRL+O to see what I mean by a dialog in this
> context.
>
> I am running Ubuntu 12.10 x64 FYI.
>
> I am an experienced programmer but a Lua newbie. However if you want I can
> try to give you a helping hand in implementing these things, though I can't
> promise I will be able to. I assure you this is due to a lack of expertise
> and not effort!
>
> Regards,
> Sandeep.
>
> Hi Sandeep
>
> On Sun, May 5, 2013 at 7:48 PM, Sandeep Datta <datta.sandeep.att.gmail.com>
> wrote:
> [..]
> > However I do have a few requests to make to help improve my workflow with
> > Textadept...
>
> For two of your questions and I can give you some pointers.
>
> > 1. Invoking the find bar by pressing Ctrl+F does not copy the currently
> > highlighted text to the find textbox (as is the norm in editors these
> days)
>
> This has been requested before, you can put this snippet in your init.lua:
> http://foicica.com/lists/textadept_archive/201112/2211.html
> If nothing is selected, the word under the caret is put in the find
> box, you can overwrite it if necessary. If something is selected the
> whole selection is put in the find box.
>
> > 2. I am missing the ability to use regular expressions for search. I
> > understand keeping the code size to a minimum is a important goal for
> this
> > project. But is it possible for you to provide an API for using external
> > search and replace algorithms? If you already have kindly point me
> towards
> > some documentation.
>
> Mitchell put a script on the Wiki, that lets you use Scintilla's
> built-in regex engine.
> http://foicica.com/wiki/regex-searches
>
> You can also use external tools like ack or grep with Textadept, here
> is something I build a while ago:
> http://rgieseke.github.io/ta-common/ack.html
>
> Robert
> --
> 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.
>
> This question was raised by a colleague and while I strongly believe the
> answer is "Yes", I can't be sure.
>
> Can someone please confirm this?
>
> Robert,
>
> Thanks for your feedback. When I opted to create 'post_init.lua' in
> ~/.textadept/modules/xml/ I thought that this module would be run *after*
> the standard XML Textadept module, therefore achieving the result of having
> an XML-specific snippet.
>
> Note that I did this as a small step toward understand how Textadept can
> be customised. My previous attempts have been flawed because I have simply
> been cutting-and-pasting, without trying to understand how things worked.
>
> To answer your first question, no, I didn't have an
> ~/.textadept/modules/xml/init.lua file. The 'post_init.lua' file is to
> *only* custom file, aside from those automatically created by Textadept. I
> didn't want this cluttered by anything else, so that troubleshooting was
> easier.
>
> I renamed my post_init.lua file init.lua but after restarting Textadept
> and opening an XML file I got the following error message:
>
> /home/rdickens/.textadept/modules/xml/init.lua:1: attempt to index field
> 'xml' (a nil value)
>
> Does this mean I need to 'include' the standard XML module? My attempt
> with the 'post_init.lua' file was as the documentation states, to have some
> custom code run in addition to the standard code.
>
>
>
> On 3 May 2013 16:10, Robert <rob.g.att.web.de> wrote:
>
>> Hi Russell,
>>
>> On Fri, May 3, 2013 at 2:52 AM, Russell Dickenson
>> <russelldickenson.att.gmail.com> wrote:
>> > In this case I wanted to better understand how to customise the
>> handling of
>> > a specific file type. I read the following text and thought, "OK, I'll
>> try
>> > adding a snippet that is specific to XML."
>> >
>> > "Similarly, you can use post_init.lua to change the module’s compile
>> and run
>> > commands, load more Adeptsense tags, and add additional key bindings and
>> > snippets (instead of in ~/.textadept/init.lua)."
>> >
>> > I created in ~/.textadept/modules/xml/ a file named "post_init.lua",
>> with
>> > the contents:
>> >
>> > snippets.xml['hi'] = 'hello there'
>> >
>> > I then open an existing XML file, which is properly recognised by TA as
>> of
>> > type "xml" and I type the snippet "hi", then press [Tab]. The snippet
>> is not
>> > converted to the text "hello there".
>> >
>> > Where am I going wrong here?
>>
>> do you still have a file '.textadept/modules/xml/init.lua'? The
>> post_init.lua files are loaded after a language module in your
>> '.textadept/modules/' or in Textadepts 'modules' directory (Lua, Cpp
>> or one of the official modules) has been found.
>>
>> So, if you want to extend Brian's module (to not have to update your
>> stuff if there is an update to Brian's module) your snippet should
>> work, if you want to start from scratch you need to start your own
>> language module in '.textadept/modules/xml'.
>>
>> If you just need a few snippets you can place your code in 'init.lua'
>> as well, as it is just adding to the global snippet table.
>>
>> Cheers,
>> Robert
>> --
>> 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.
>>
>>
>
> Russell,
>
> On Mon, 6 May 2013, Russell Dickenson wrote:
>
> [snip]
>> I renamed my post_init.lua file init.lua but after restarting Textadept
>> and
>> opening an XML file I got the following error message:
>>
>> /home/rdickens/.textadept/**modules/xml/init.lua:1: attempt to index
>> field
>> 'xml' (a nil value)
>>
>
> The snippets.xml table has not been defined yet so you have to do it
> manually:
>
> snippets.xml = {
> ['hi'] = 'hello there'
> }
>
> or
>
> snippets.xml = {}
> snippets.xml['hi'] = 'hello there'
>
> 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.
>
> Hi Russell,
>
> On Mon, 6 May 2013, Russell Dickenson wrote:
>
> This question was raised by a colleague and while I strongly believe the
>> answer is "Yes", I can't be sure.
>>
>> Can someone please confirm this?
>>
>
> Yes they do. There are #ifdefs in the C code for curses-specific behavior
> as well as "if CURSES" statements in Lua. There is also a curses-specific
> interface for Textadept's editing component Scintilla: Scinterm[1].
>
> Cheers,
> Mitchell
>
> [1]: http://foicica.com/scinterm
> --
> 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.
>
> Hi Sandeep,
>
> On Sun, 5 May 2013, Sandeep Datta wrote:
>
> Hi Mitchell,
>>
>> I chanced upon Textadept while looking for a good text editor in Ubuntu.
>> Using Textadept has been a pleasure. Hats off to you for creating this
>> wonderful piece of software and sharing it with the world.
>>
>
> Cheers! I'm glad you find it useful :)
>
> However I do have a few requests to make to help improve my workflow with
>> Textadept...
>>
>> 1. Invoking the find bar by pressing Ctrl+F does not copy the currently
>> highlighted text to the find textbox (as is the norm in editors these
>> days)
>>
>
> Perhaps this would be useful in a future release. I will consider it.
>
> 2. I am missing the ability to use regular expressions for search. I
>> understand keeping the code size to a minimum is a important goal for this
>> project. But is it possible for you to provide an API for using external
>> search and replace algorithms? If you already have kindly point me towards
>> some documentation.
>>
>
> Robert linked to my page on the wiki which may be of use. However,
> Scintilla's regex implementation is somewhat limited. If you are feeling
> adventurous, you may be able to compile Textadept with a regex library
> using a Scintilla hook[1]. If you manage to get it working, let me know and
> it may be included in the future.
>
> 3. Running textadept-curses file.ext produces the following error:-
>> /home/sandeepd/Misc/textadept/**core/file_io.lua:142: bad argument #1 to
>> 'iconv' (string expected, got nil)
>>
>
> What are your $CHARSET, $LC_ALL, and $LANG environment variables?
> Textadept checks each sequentially to determine your filesystem's encoding.
> Mine is 'en_US.UTF-8', so UTF-8 is what _CHARSET is set to. I suspect yours
> is not being detected correctly.
>
> 4. Errors do not appear in a "dialog" in the ncurses version so it makes
>> it
>> difficult to know that pressing CTRL+Q to quit will not work unless you
>> press ESC first. Press CTRL+O to see what I mean by a dialog in this
>> context.
>>
>
> Unfortunately this is an issue with the curses toolkit Textadept uses to
> get user input from dialogs. However, in the GUI version, Textadept behaves
> in the same way: Ctrl+Q with a dialog open does not quit.
>
> I am an experienced programmer but a Lua newbie. However if you want I can
>> try to give you a helping hand in implementing these things, though I
>> can't
>> promise I will be able to. I assure you this is due to a lack of expertise
>> and not effort!
>>
>
> Thanks for any effort :)
>
> Cheers,
> Mitchell
>
> [1]: http://scintilla.org/**ScintillaDoc.html#**AlternativeRegEx<http://scintilla.org/ScintillaDoc.html#AlternativeRegEx>
> --
> 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.
>
> Mitchell,
>
> Thankyou!
>
> Apologies for tackling this in such a noob fashion! :( I will make the
> necessary changes then move on to bigger and better things. I'm sure
> everyone on this ML will be excited! :P
>
>
> On 6 May 2013 13:27, Mitchell <m.att.foicica.com> wrote:
>
>> Russell,
>>
>> On Mon, 6 May 2013, Russell Dickenson wrote:
>>
>> [snip]
>>>
>>> I renamed my post_init.lua file init.lua but after restarting Textadept
>>> and
>>> opening an XML file I got the following error message:
>>>
>>> /home/rdickens/.textadept/**modules/xml/init.lua:1: attempt to index
>>> field
>>> 'xml' (a nil value)
>>>
>>
>> The snippets.xml table has not been defined yet so you have to do it
>> manually:
>>
>> snippets.xml = {
>> ['hi'] = 'hello there'
>> }
>>
>> or
>>
>> snippets.xml = {}
>>
>> snippets.xml['hi'] = 'hello there'
>>
>> 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.
>>
>>
>
> Mitchell,
>
> Thankyou. I will pass the message on to my colleague. In this case I got
> the answer right! \O/
>
>
> On 6 May 2013 13:30, Mitchell <m.att.foicica.com> wrote:
>
>> Hi Russell,
>>
>>
>> On Mon, 6 May 2013, Russell Dickenson wrote:
>>
>> This question was raised by a colleague and while I strongly believe the
>>> answer is "Yes", I can't be sure.
>>>
>>> Can someone please confirm this?
>>>
>>
>> Yes they do. There are #ifdefs in the C code for curses-specific behavior
>> as well as "if CURSES" statements in Lua. There is also a curses-specific
>> interface for Textadept's editing component Scintilla: Scinterm[1].
>>
>> Cheers,
>> Mitchell
>>
>> [1]: http://foicica.com/scinterm
>> --
>> 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.
>>
>>
>
> Mitchell,
>
> I have modified my ~/.textadept/modules/xml/init.lua file, trying both of
> the forms you suggested earlier in this email thread.
>
> Regardless of which I choose, I get the following error message when I
> open an XML file:
>
> /usr/lib64/textadept/modules/textadept/mime_types.lua:95: attempt to index
> field '?' (a boolean value)
>
> In this case I have packaged Texadept 6.6 beta for Fedora 18 and installed
> the resulting package. I have tested and confirmed that I get the same
> error message even if using the pre-built binaries.
>
>
>
> On 6 May 2013 13:27, Mitchell <m.att.foicica.com> wrote:
>
>> Russell,
>>
>> On Mon, 6 May 2013, Russell Dickenson wrote:
>>
>> [snip]
>>>
>>> I renamed my post_init.lua file init.lua but after restarting Textadept
>>> and
>>> opening an XML file I got the following error message:
>>>
>>> /home/rdickens/.textadept/**modules/xml/init.lua:1: attempt to index
>>> field
>>> 'xml' (a nil value)
>>>
>>
>> The snippets.xml table has not been defined yet so you have to do it
>> manually:
>>
>> snippets.xml = {
>> ['hi'] = 'hello there'
>> }
>>
>> or
>>
>> snippets.xml = {}
>>
>> snippets.xml['hi'] = 'hello there'
>>
>> 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.
>>
>>
>
> Russell,
>
> On Mon, 6 May 2013, Russell Dickenson wrote:
>
> Mitchell,
>>
>> I have modified my ~/.textadept/modules/xml/init.**lua file, trying both
>> of
>> the forms you suggested earlier in this email thread.
>>
>> Regardless of which I choose, I get the following error message when I
>> open
>> an XML file:
>>
>> /usr/lib64/textadept/modules/**textadept/mime_types.lua:95: attempt to
>> index
>> field '?' (a boolean value)
>>
>> In this case I have packaged Texadept 6.6 beta for Fedora 18 and installed
>> the resulting package. I have tested and confirmed that I get the same
>> error message even if using the pre-built binaries.
>>
>
> Sorry for overlooking this. If you are trying to create an xml module
> (which it seems you are by creating init.lua), then that file must return a
> Lua table (a characteristic of a module). So at the end of your init.lua,
> add "return {}" since you do not have any special features. However, if you
> plan on adding them (such as XML-specific buffer properties or any
> XML-specific functions), then you would wrap everything in a "local M = {}
> ... return M" construct. For example:
>
> snippets.xml = {
> ['hi'] = 'hello there'
> }
>
> return {}
>
> or
>
> local M = {}
>
> function M.set_buffer_properties()
> -- buffer-specific properties like indentation here
> end
>
> snippets.xml = {
> ['hi'] = 'hello there'
> }
>
> return M
>
> 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.
>
> Mitchell,
>
> Yay! \O/ I made the necessary changes to my XML-specific 'init'lua',
> using the second form, and the XML-specific snippet now works as expected.
>
> I expect that what you explained in your previous email would normally be
> covered in "Lua 101", so thanks for taking the time to explain the basics.
> I feel that by enabling this very simple option I have learned a little
> about how Textadept works. Now to take on the world!!
>
> Before advancing too far I need to have one point clarified: the use of
> "post_init.lua". When I was first trying to enable the XML-specific
> snippet, I thought that I should be using "post_init.lua" but that wasn't
> working so instead I switched to "init.lua". Can you please clarify if I
> have the right configuration according to my goals? In future I intend
> enabling buffer-specific properties, such as word-wrap etc, so I want to be
> sure I am defining these in the right place.
>
>
>
> On 6 May 2013 22:29, Mitchell <m.att.foicica.com> wrote:
>
>> Russell,
>>
>> On Mon, 6 May 2013, Russell Dickenson wrote:
>>
>> Mitchell,
>>>
>>> I have modified my ~/.textadept/modules/xml/init.**lua file, trying
>>> both of
>>> the forms you suggested earlier in this email thread.
>>>
>>> Regardless of which I choose, I get the following error message when I
>>> open
>>> an XML file:
>>>
>>> /usr/lib64/textadept/modules/**textadept/mime_types.lua:95: attempt to
>>> index
>>> field '?' (a boolean value)
>>>
>>> In this case I have packaged Texadept 6.6 beta for Fedora 18 and
>>> installed
>>> the resulting package. I have tested and confirmed that I get the same
>>> error message even if using the pre-built binaries.
>>>
>>
>> Sorry for overlooking this. If you are trying to create an xml module
>> (which it seems you are by creating init.lua), then that file must return a
>> Lua table (a characteristic of a module). So at the end of your init.lua,
>> add "return {}" since you do not have any special features. However, if you
>> plan on adding them (such as XML-specific buffer properties or any
>> XML-specific functions), then you would wrap everything in a "local M = {}
>> ... return M" construct. For example:
>>
>>
>> snippets.xml = {
>> ['hi'] = 'hello there'
>> }
>>
>> return {}
>>
>> or
>>
>> local M = {}
>>
>> function M.set_buffer_properties()
>> -- buffer-specific properties like indentation here
>> end
>>
>>
>> snippets.xml = {
>> ['hi'] = 'hello there'
>> }
>>
>> return M
>>
>>
>> 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.
>>
>>
>
>

-- 
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 Thu 09 May 2013 - 12:22:00 EDT

This archive was generated by hypermail 2.2.0 : Fri 10 May 2013 - 06:28:58 EDT