lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Come to think of this. I'm emacs user when comes to lua, lisp, shell scripts, etc. I'm not very good yet, but one thing that puzzles me, is how can I instruct emacs to follow different identation modes for
parts of the code. Sometimes that code would be in a string.

I'm talking about formatting better my luajit ffi bindings - there you have lua with C mixed.

On 8/12/2011 3:21 AM, Dirk Laurie wrote:
On Fri, Aug 12, 2011 at 11:58:53AM +0200, Pierre Chapuis wrote:

    if x: doThings(x)
    else: doThings(y)

I am not sure you can cleanly make this a one liner though.

Python 2.5 and later (don't have the older serpents around):

     doThings(x) if x else doThings(y)

An approach I like to solve the problem and make everybody
happy is the one used by the Go language: whitespace is not
significant but there is a canonical indentation style and
a tool (gofmt) that enforces it.

The style used in PiL is a candidate.

I don't see a reason why this wouldn't work with Lua. It is
probably possible to make a parser that takes valid Lua code
and returns a canonical representation for it.

For example: if you make an entry in LuaWiki that contains in
its source
   {{{!Lua
....
}}}
it would not merely highlight keywords as it does now, but also
do the indents.  It would show up canonically, no matter how it
was typed in. Why not?

Dirk