Re: Request for a "Rewrap paragraph" function

From: Robert <ro....at.web.de>
Date: Tue, 27 Apr 2010 22:36:44 +0200

I actually tried to quickly get this working before replying to
Russell and failed...
First I tried to get a init.lua and copied the one from the docs - it
didn't work because textadept has to be required before menu. Then I
took the part from the original init.lua and then wrap.lua crashed
because I didn't had a buffer.edge_column...
I followed Brian's instructions and now it works - and do I wish I had
tried this before getting keyword lists for lexers together...
When testing it briefly now, it sometimes deleted all text - so I'll
be looking forward to the next version :-)
Example:
Empty buffer, typing one line longer than 80 chars, ctrl-h, perfect
rewrap, another line, ctrl-h, everythings gone.

I would propose to include a user's init.lua as a file in the docs
directory. So you could actually click on a link to it, save it in
.textadept and be ready.
Further I think the user snippets.lua and key_commands.lua
functionality could maybe be included in the user init.lua. (I know
I've been pro snippets.lua when this was discussed before :-)
I added an example for an init.lua. Certainly the wording or the
examples could be improved, maybe the comments for the first modules
could be shortened as most people would be interested in changing the
menu or key_commands.
Having a file and instructions like this would be one place less to
change things, as Russell mentioned, this can be confusing. Of course,
you can change things everywhere in Textadept, but in general I think
it would be nice to have as much as possible in one file.
What do you think?

Robert

On Tue, Apr 27, 2010 at 5:18 AM, Brian Schott <briancsch....at.gmail.com> wrote:
> On 04/26/10 15:10, phayz wrote:
>> On Apr 26, 4:59 am, Robert <ro....at.web.de> wrote:
>>
>>> On Sun, Apr 25, 2010 at 2:43 PM, phayz <russelldicken....at.gmail.com> wrote:
>>>
>>>> I certainly followed step 2 but possibly not correctly. I ought to
>>>> start with a much simpler question - what does the "ch" key sequence
>>>> mean? From my understanding, it represents Control+h, but I have tried
>>>> this key sequence and nothing happens.
>>>>
>>>
>>>> I think after this I still stop trying to tweak Textadept. It's quite
>>>> clear to me that I simply don't understand how it all "hangs
>>>> together."
>>>>
>>>
>>>> Regards,
>>>>
>>>
>>>> Russell Dickenson
>>>>
>>> Russell, don't give up! It took a me a long time to figure out how
>>> Textadept worked (and there are still lots of things I don't
>>> understand). If something doesn't work, try something simpler.
>>> For example, can you use another of Brian's modules in modules/common,
>>> can you assign keys.ch to a simple "textadept.print("test"), this
>>> approach helped me to learn about Textadept. And reading up on Lua. I
>>> started to read "Programming in Lua" more seriously, instead of just
>>> looking up things as I needed them. This is something I probably shoud
>>> have done earlier.
>>>
>>> Robert
>>>
>>
>> Robert,
>>
>> Thanks for your encouragement. I certainly don't intend walking away
>> from Textadept altogether (unless an even sexier text editor passes
>> through my field of vision :P). When I wrote my earlier message I was
>> tired and frustrated at not being able to get anything working WRT the
>> paragraph wrapping script, kindly written by Brian. My problems were
>> made worse by the fact that I was first working with the latest
>> Textadept build and was encountering a fatal bug (which I am yet to re-
>> test and report). I then switched to the version of Texadept packaged
>> for my Linux distribution but it was quite old and didn't activate/
>> enable/look for user Lua scripts. I finally installed a Textadept
>> package for version 2.1 and was working with that. All the to-ing and
>> fro-ing with versions of Textadept, together with being tired as I was
>> working late at night, put me in a rather negative mood.
>>
>> As you suggest, Robert, I will try a simpler approach, tying a key
>> sequence together with an associated action so that I understand
>> Textadept a little better. What has complicated things for me is the
>> fact that there are, apparently, several ways of achieving the same
>> goal. The paragraph wrapping script for example, requires changes to a
>> personal key_commands.lua. Another user-contributed script -
>> bufferutils.lua - seemingly contains its code and associated key
>> sequence in the same file. Do I understand this correctly, or some
>> other magic going on which makes the bufferutils.lua script "just
>> work".
>>
> I don't put any key combinations in my scripts so that people can choose
> their own key bindings for them. My key combos can be a bit strange
> since I type on a Dvorak keyboard.
>> I must reiterate my thanks to Brian for producing the script and his
>> help so far. The fact that it's not yet working for me should not
>> reflect badly on his good work. I hope that my "Eureka!" moment will
>> come soon.
>>
>>
>> Regards,
>>
>> Russell Dickenson
>>
> Step-by step instructions for setting this up from a clean install:
>
> 1. Download and unpack textadept
> 2. Create ~/.textadept/modules/common
> 3. Download http://caladbolg.net/textadeptwiki/uploads/wrap.lua and
> place it in ~/.textadept/modules/common
> 4. Create ~/.textadept/modules/common/init.lua:
>
> module('_m.common', package.seeall)
> require "common.wrap"
>
> 5. create ~/.textadept/init.lua:
>
> require 'textadept'
> require 'ext/keys'
> require 'ext/find'
> require 'ext/command_entry'
> require 'ext/mime_types'
> require 'ext/menu'
> require 'common'
> require 'ext/key_commands'
>
> 6. create ~/.textadept/key_commands.lua:
>
> local keys = _G.keys
> local m_wrap = _m.common.wrap
> keys.ch = { m_wrap.wrap_lines }
>
> 7. Set buffer.edge_column! Otherwise the script will hit an infinite
> loop or some other such nonsense. (I need to add a check for that in my
> script...) The best place for this is in your theme's buffer.lua.
>
> 8. DON'T FEEL STUPID! I ran into problems trying to build these
> instructions from a clean install. The order of the require statements
> in ~/.textadept/init.lua is really tricky. You have to require all the
> things that are dependencies of subsequent modules before requiring
> them. For instance, the key_commands needs _m.common.wrap to exist, but
> it isn't registered with Lua until the "module" statement in
> ~/.textadept/modules/common/init.lua.
>
> - Brian
>
>
> --

-- 
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 27 Apr 2010 - 16:36:44 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:41:18 EST