Giter Site home page Giter Site logo

lua-mode's Issues

Highlightning local varialbes

  • Single declarations with assignemnts work well, like:

local a = 10 -- colorizes the 'a'

  • but this doesn't:

local a -- does not colorize.
a = 10

  • also multiple declarations won't work:

local a, b, c -- does not colorize
local x, z, y = 1, 2, 3 -- does not colorize either

Would be good to have colorizing also on the definiton and on multiple variables.

highlighting in warning face of parens in `local function foo()`

In definitions of local functions, the parenthesis around the arguments are highlighted in font-lock-warning-face. I think this an accidental side-effect of highlighting syntax errors in local variable assignments (at lua-mode.el:573).

Both

local foo = function()
   ;
end
-- and
local function foo()
   ;
end

show the problem.

feature request with patch: make --[[ ]]-- multiline comment handling not record undo information

i use this function:

http://www.emacswiki.org/cgi-bin/wiki/goto-last-change.el

and in lua buffers it always jumps to the beginning and the end of multiline comments.

please bind buffer-undo-list to T here like this to avoid recording undo information:

(defun lua-mark-char-multiline-delim (pos type)
"Mark character as a delimiter of Lua multiline construct

If TYPE is string, mark char as string delimiter. If TYPE is comment,
mark char as comment delimiter. Otherwise, remove the mark if any."
(let ((old-modified-p (buffer-modified-p))
(inhibit-modification-hooks t)
(buffer-undo-list t))
(unwind-protect
(lua-put-char-syntax-table pos (lua-get-multiline-delim-syntax type))
(set-buffer-modified-p old-modified-p))))

ANN: multiline literal handling reimplemented, feedback wanted

This is more an announcement than an real issue, but I couldn't figure out a better way to send it out, so, please, bear with me.

I've redone multiline literal recognition via standard Emacs24 facilities (syntax-propertize) in multiline_literals branch (dbedb1e). It made the highlighting process a lot smoother on my installation but I can't be sure about others. So, if you are a happy Emacs24 user and brave enough to check out something experimental, feel free to try it out and post the feedback here, especially if it doesn't work :) Your help is much appreciated.

Cheers,
immerrr

Indentation of function() used as expression

Currently the body of function is always indented according to function() keyword, which creates really suboptimal results:

local func = function()
                return k
             end

while I'd prefer

local func = function()
   return k
end

Funny indenting for functions

Consider the following code:

local function f ()
return function g()
foo ()
end
end

Note that lua-mode indents the first "end" to line up with the second "function" keyword. But in that case, to be consistent, it should have indented lines 2 and 3 much more. My preferred solution would be for it to indent the first "end" by only two spaces, to line up with the "return". (I have lua-indent-level set to 2, but no other customization.)

Request for support on indentation

Hi,

In our company we have relatively strict guidelines on Lua code formatting and several hundreds KLOC of existing code that follows them (so changing guidelines is not a good idea). I wonder, is lua-mode configurable to match our rules, or is it hard to be made flexible enough to be configurable.

You may find a bunch of code written according to our guidelines, for example, here: https://github.com/lua-nucleo/lua-nucleo/tree/master/lua-nucleo/. I believe that this indentation style is (mostly) not that uncommon.

Indentation rules in short:

  • tabs to spaces;
  • indent 2 spaces;
  • 80 chars max line width;
  • multi-line function arguments to be indented with two indents, closing parenthesis — with one (this, probably, is the uncommon part).

As an illustration, I prepared a naïve set of code (most likely incomplete, but will do as a start; if something more significant will be needed, I'll de-indent, say, a bunch of lua-nucleo files, that should cover most of the rules):

https://gist.github.com/37855303239506a16731

There is input, as typed (pasting it in console emacs works for me), expected output, and actual output with current lua-mode Git HEAD.

Unfortunately, we do not have any elisp gurus in-house, so we can't fix the problem ourselves. So I'm humbly asking for assistance. If this is something that is too large to be handled along the "public support" lines, I'll be happy to discuss sponshorship of one kind or another privately, please poke me via GH message.

Please note that we're not asking for a custom implementation of indentation code, but merely for the possibility to configure lua-mode to match our preferences.

Thank you in advance,
Alexander.

P.S. There was an year-old discussion on SO on that matter:

http://stackoverflow.com/questions/4643206/how-to-configure-indentation-in-emacs-lua-mode

I don't speak elisp, so for me that discussion resulted mostly in cargo-cult programming, with little effect.

indentation of 'end' following ' return function ...'

Here's what happens with auto-indentation:

function io.arg_files(arg)
  if #arg == 0 then
    local file = io.stdin
    return function()
      local answer = file
      file = nil
      return answer
           end
  else
    mumble

The end should be cognizant of the return, but it's not.

I have version 20111107.

revisit word-symbol handling

Reported at lua mailing list. Putting here to be sure I won't forget about it after holidays.

lua-mode redefines "_" as a word-component; it shouldn't, as it
really messes with users' instincts, and makes Emacs commands less
useful.  Historically this was often done by language-modes as an
simple (though misguided) expedient to allow them to safely use "\<"
and \>" in regexps matching keywords, but nowadays they shouldn't do
that, they should leave "_" alone and use "\_<" and "\_>" instead.

electric-pair-skip-self

Hello.
Using lua-mode in emacs 24.3 I've encountered that it doesn't honor electric-pair-skip-self set to true. It should skip second bracket when you try to close it, but instead it adds another one.
Thank you.

Filling a comment can turn comment into code

Consider the following snippet:

-- @param s {d1, ..., dn}
-- @param l list to reshape
-- @return reshaped list
-- FIXME: Use ileaves instead of flatten (needs a while instead of a for in fill function)
function shape (s, l)
end

Go down to line 4, which says FIXME, and at the start of the line, press C-o to open a blank line. Now press M-q. Some of the comment becomes uncommented when it's wrapped.

Press Undo, and then go down a line, and press M-q again; this time, starting on the comment line rather than the line before, it works.

Tested with git master HEAD.

Emacs 21 support

Note to myself.

It's been reported that installing syntax.el and linum.el helps running lua-mode on Emacs21, but something is still wrong with the indentation.

Emacs hangs if code sent to Lua subprocess contains input commands

Something as simple as

a = io.read("*number")

is enough to reproduce. Apparently, it's this line that blocks execution until any output, but there will be none while UI is unresponsible.

The "wait for output" is necessary to clean up temp file where the sent region is put, this should be addressed as well.

table constructor indentation

Hello.

For some reason lua-calculate-indentation-block-modifier returns zero for the closing brace, when opening brace starts on a separate line:

-- ok
a = {
}

b = {
}

-- wrong
a = 
   {
   }
   b = 
      {
      }

C-M-a and C-M-e

Maybe I'm misunderstanding something, but when I'm in a function body or in a "{}" I'd expect to jump to beginning of that body using C-M-a.

apostrophe in comment breaks font-lock

If there is an apostrophe (') in a comment, then the whole rest of the file is colored as a comment.

(Doesn't everybody use syntax colorization now?)

Byte compilation fails

I get the following error when installing from the latest MELPA package, which corresponds to the latest commit at the time of writing this:

Compiling file /Users/steve/.emacs.d/elpa/lua-mode-20130318.512/lua-mode.el at Mon Mar 18 08:23:44 2013
lua-mode.el:146:24:Warning: `interactive-p' is an obsolete function (as of
    23.2); use `called-interactively-p' instead.
lua-mode.el:148:13:Warning: called-interactively-p called with 0 arguments,
    but requires 1
lua-mode.el:155:50:Warning: `interactive-p' is an obsolete function (as of
    23.2); use `called-interactively-p' instead.
lua-mode.el:566:11:Error: Symbol's function definition is void: lua-make-delimited-matcher

Symbol's value as variable is void: last-command-char

I recently received an upgrade of emacs proper and lua-mode via Gentoo's portage system. Since doing so, I cannot edit at all in lua mode, essentially, because when I need to close a parenthesis, this error ("Symbol's value as variable is void: last-command-char") appears in the minibuffer, and I am not permitted to type anything, be it the closing parenthesis character, or anything else in the buffere at all, at that point -- thus preventing me from doing anything at all, obviously.

Please help!

Coloring gets into undo history

Sometimes when I undo in a lua-mode buffer, nothing changes except for coloring. As far as I can tell, some coloring actions are considered edits, which is confusing, as they're not things I've done! I'm using the tip of master.

#! on the first line

Not an important issue, but when using lua for scripts, the first line defined as: #!/usr/local/lua or similar, gets colorized as lua cod ('local' is colored). The whole line should be colorized as comment.

emacs hangup when eval lua code does not have output.

When using lua-send-file to eval current buffer, sometimes cause emacs hangup.

(defun lua-send-region (start end)
...
(setq prompt-found (and (lua-prompt-line) (< last-prompt (point-max)))))
...
)
should be:
(setq prompt-found (and (lua-prompt-line) (<= last-prompt (point-max)))))

Incorrect indentation following ({ sequence

When auto-indenting on a new line following a ({ sequence, the indentation is incorrect and seems to be relative to these braces rather than left-aligned. For example, when passing an inline table to a function:

foo({
      4,
      5,
      6,
})

I would expect this instead:

foo({
  4,
  5,
  6,
})

I am using Emacs 24.3.1 built on OSX 10.9 with Macports. I see this problem with both commit e430d01 and the version installed by el-get (not sure on exact version, might be the same).

It was suggested that I report this as a bug here.

underscore in function names

Bur gor feature? these two function names have different colors.

local foo_Bar = function (a)
    return a
end

local fooBar = function (a)
    return a
end

stdout not being captured in emacs 23 on windows

Not sure if the root of the problem is luamode or the emacs port (23.3.1 mingw)

I have no problem getting the mode up and running in windows, but the standard output is not echoing to the lua process' buffer.

Has anyone else seen this? Any ideas?

[update] the output is just not being flushed -- it all appears if I ctrl-d to kill the lua session

Request for handling multiline --[[ comment ]] identations correctly

Hi there,

lua-mode works almost perfectly for me but it fails to handle multiline block comments correctly. If I have a new lua file like this:

function foo()
    print "bar"
end

The indentation is correct, with the first line and the last line going to the left-most margin. However, suppose I have the following code:

--[[
    This is a 
    Multiline comment
--]]

function foo()
    print "bar"
end

When I type it out, lua-mode will automatically indent it to look like the following:

--[[
    This is a 
    Multiline comment
    --]]

    function foo()
        print "bar"
    end

Unfortunately, I don't understand elisp or the structure of lua-mode enough to fix it myself and submit a patch. Just for your information, I'm using lua-mode.el from the rel-20111107 tag. I'm not using the latest from HEAD because it doesn't byte compile (make compile fails with some error).

error when byte-compiling lua-mode

Hello,

Thanks for working on/maintaining lua-mode. I'm an emacs user who is looking to learn Lua and having an emacs-mode is quite handy. I cloned the git repo and the HEAD of my clone is currently at commit a3ed448. When I attempt to byte-compile lua-mode, I get the following error.

lua-mode.el:194:39:Error: Symbol's value as variable is void: lua-mode-menu

I'm running emacs 24.0.50 compiled from a checkout of the bzr repo and the HEAD of my clone is at
[email protected]

if/else blocks not indented correctly if they contain "return"

If I had the following code:

function foo()

   if 1 < 2 then
      print "one less than two"
   else
      print "what the hell"
   end

end

The indentation is ok. But if I had the following code:

function foo()

   if 1 < 2 then
      return
   else
      print "what the hell"
   end

end

and if I pressed [tab] on print "what the hell", some extra indentation would be added and the code would look like the following

function foo()

   if 1 < 2 then
      return
   else
         print "what the hell"
   end

end

This does not happen if the return statement contains a return value. But if it does not, then an extra indentation is added. I have verified that this issue exists in HEAD. The fix for #34 (pull request #35) does not introduce this error.

indentation and square brackets

Hello. I've found strange bug. When you use square brackets in a function body, indentation goes mad after that.
-- example --
function one()
return {
name = 1,
description = ([[some text]])
}
end

      function two()
                return 2
      end

-- example --
This happens only if you saved and reopened file, because simply putting square brackets doesn't syntax-highlight the expression.

I guess square brackets in lua-mode are a source of many obscure bugs currently.

Comments not highlighted correctly

Hi!

With latest git and emacs 24.1, single line comments are not highlighted with the comment face. Instead, the default face is used except for keywords like "if" or "for". I have also tried by starting emacs with "emacs -Q" without any change.

at end of session, emacs asks about saving abbrevs

Hello,

When exiting, emacs asks if I want to save abbrevs, but I don't want to be asked and I don't want to save a new file.

How to reproduce (the file `abbrev-file-name' must not exist):

  • emacs -Q
  • (load "path/to/lua-mode") ; this sets `abbrevs-changed' to t

Workaround:
(setq abbrevs-changed nil) ; after loading lua-mode

Cheers, Peter

font-lock error

I have this simple lua file

-- A syntax error caused by a missing quote
--
-- Checkers: lua

print "oh no"

print "hello world"

When I open the file I get the following error:
Error during redisplay: (jit-lock-function 1) signaled (wrong-type-argument stringp lua-comment-start-skip)

Only line 1 is colored, all other lines do not have syntax coloring.

I am on Emacs 24.3 and latest lua-mode.

Error in lua-mark-all-multiline-literals()

Hi,

I get the following backtrace when I try to open a lua file (lua-mode v20111107):

Debugger entered--Lisp error: (wrong-number-of-arguments called-interactively-p 1)
(called-interactively-p (quote any))
(and (called-interactively-p (quote any)) (use-region-p))
(if (and (called-interactively-p ...) (use-region-p)) (setq begin (region-beginning) end (region-end)))
lua-mark-all-multiline-literals()
(let ((switches nil) s) (kill-all-local-variables) (setq major-mode (quote lua-mode)) (setq mode-name "Lua") (setq comint-prompt-regexp lua-prompt-regexp) (make-local-variable (quote lua-default-command-switches)) (set (make-local-variable ...) (quote lua-beginning-of-proc)) (set (make-local-variable ...) (quote lua-end-of-proc)) (set (make-local-variable ...) (quote lua-indent-line)) (set (make-local-variable ...) lua-comment-start) (set (make-local-variable ...) lua-comment-start-skip) (set (make-local-variable ...) (quote ...)) (set (make-local-variable ...) lua-imenu-generic-expression) (setq local-abbrev-table lua-mode-abbrev-table) (abbrev-mode 1) (make-local-variable (quote lua-default-eval)) (use-local-map lua-mode-map) (set-syntax-table (copy-syntax-table)) (modify-syntax-entry 43 ".") (modify-syntax-entry 45 ". 12") (modify-syntax-entry 42 ".") (modify-syntax-entry 47 ".") (modify-syntax-entry 94 ".") (modify-syntax-entry 46 "_") (modify-syntax-entry 62 ".") (modify-syntax-entry 60 ".") (modify-syntax-entry 61 ".") (modify-syntax-entry 126 ".") (modify-syntax-entry 10 ">") (modify-syntax-entry 39 """) (modify-syntax-entry 34 """) (if (and ... ... ... ... ...) (progn ... ...)) (if (boundp ...) (setq mode-popup-menu ...)) (unless (assq ... hs-special-modes-alist) (add-to-list ... ...)) (set (make-local-variable ...) t) (lua-mark-all-multiline-literals) (lua--automark-multiline-update-timer) (run-hooks (quote lua-mode-hook)))
lua-mode()
set-auto-mode-0(lua-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
find-file-noselect-1(# "/test.lua" nil nil "/test.lua" (3285412 2055))
find-file-noselect("/test.lua" nil nil t)
find-file("
/test.lua" t)
call-interactively(find-file nil nil)

This error has got to do with giving an argument to (called-interactively-p) which takes no arguments in my emacs 23.1.1 or 22.2.1. You could work around this with: http://paste.lisp.org/display/115598

Regards,
Markus

Symbol's function definition is void: lua-make-delimited-matcher

Compile error using Emacs 24.3.50

$ make compile 
emacs --batch --no-site-file -f batch-byte-compile lua-mode.el
In toplevel form:
lua-mode.el:146:24:Warning: `interactive-p' is an obsolete function (as of
    23.2); use `called-interactively-p' instead.
lua-mode.el:148:13:Warning: called-interactively-p called with 0 arguments,
    but requires 1
lua-mode.el:155:50:Warning: `interactive-p' is an obsolete function (as of
    23.2); use `called-interactively-p' instead.
lua-mode.el:579:9:Error: Symbol's function definition is void: lua-make-delimited-matcher

make: *** [compile] Error 1

Single-line conditionals can confuse indenting

Try feeding the following code to lua-mode, and re-indent. The third line is indented an extra level, but it shouldn't be. However, the problem is minor, as the fourth line ("end") is correctly left alone.

function f (s, o)
if type (o) == "string" then return s .. o else return s .. tostring (o) end
return tostring (s) .. tostring (o)
end

indentation broken on emacs-24.0.50

Hello,
When creating this file:

local test = [[bla bla bla
bla bla bla]]

there is no problem.

But after reopening this same file, it's no more possible to indent the second line (TAB-key).
No problem with emacs-23.x.
Peter

Long strings can be confused by quotes

Load the linked code http://git.savannah.gnu.org/cgit/zile.git/plain/src/funcs.lua?h=lua&id=ce041ec6686409e372a2ae13df02e407488721fb into current lua-mode master head, and search for "fill-column". Note that you are in the middle of a long string, but it is not colored correctly. Note that after the close quote on `fill-column' the following text is highlighted as if it were a string, up to the end of the long string and beyond.

This bug depends on the size of the buffer. If I just save the "auto-fill-mode" block into a file, it is highlighted correctly. If I save the file up to that point (i.e. lines 1-68 inclusive), then the bug is triggered. However, if I then remove the comment block at the top of the file, the bug does not trigger.

I hope that's enough to repro! Of course let me know if you need more.

(Probably harmless) error when opening new file

If I create a buffer called foo.lua (so it is put into Lua mode), I get the following error:

File mode specification error: (args-out-of-range 0 1)

I doubt it matters, but it would be nice not to see it!

I'm using git master HEAD.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.