Re: [code] [textadept] History for TA

From: Mitchell <>
Date: Tue, 30 Jul 2019 15:26:23 -0400 (EDT)


On Tue, 30 Jul 2019, Qwerky wrote:

> Hi Mitchell,
> On 2019-07-30 12:14, Mitchell wrote:
>> Hi,
>> On Tue, 30 Jul 2019, Qwerky wrote:
>>> A question that your step 3 and '_M.history' brought to mind:  as a
>>> relatively new user, I am somewhat confused by using 'M.function' or
>>> 'M.variable' in the module, as opposed to 'local function' or 'local
>>> variable'.  What is the difference between the two?
>> The `M.` prefix makes those fields accessible outside the module (e.g. from
>> one's *~/.textadept/init.lua*). If those fields were local, they are not
>> accessible from the outside.
>> Cheers,
>> Mitchell
> I had a suspicion that it was something along those lines.  But try as I
> might, I couldn't figure out 'how' to access them from outside.  I would
> think it would require the module name, but no matter what I try, I get
> errors, such as "attempt to access global 'history'" or similar.  So how is
> that done?

You can either use:

   local history = require('history') -- or whatever path/to/history is
   -- history.variable is now accessible

Or you can access it directly from `require()`:


> And that would apply to both functions and variables?  And I would assume
> that even though externally accessibly, that they are still not global (which
> is good), otherwise there would be no difference between the 'M.' version and
> a global one.

This method applies to any fields that exist in the module being required.


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Tue 30 Jul 2019 - 15:26:23 EDT

This archive was generated by hypermail 2.2.0 : Wed 31 Jul 2019 - 06:48:56 EDT