Re: Request for a "Rewrap paragraph" function

From: Brian Schott <briancsch....at.gmail.com>
Date: Mon, 26 Apr 2010 20:18:18 -0700

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 Mon 26 Apr 2010 - 23:18:18 EDT

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