lua-mode

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

lua-mode

Mark Tigges
Hello all,

If anyone has a lua-mode.el for emacs I would be most appreciative if
you could share the wealth.  Otherwise I will begin writing a simple one. 

Thanks,
Mark.

Reply | Threaded
Open this post in threaded view
|

RE: lua-mode

Thomas Rolfes
On Wednesday, October 28, 1998 4:05 PM, [hidden email]
[SMTP:[hidden email]] wrote:
> If anyone has a lua-mode.el for emacs I would be most appreciative if
> you could share the wealth.  Otherwise I will begin writing a simple one. 

I would also appreciate a proper lua mode. Currently I am using the
following code, which works fine in GNU Emacs 19.34

Thomas

------------------------------------>
;;; Lua
(defun lua-mode ()
  "Lua mode"
  (interactive)
  (setq tab-width 4
	;; this will make sure that tabs are used instead of spaces
	indent-tabs-mode t)
  (font-lock-mode nil)
  (setq font-lock-keywords
	'(
	  ("[^\\\\]\\(\\(\".*\"\\)\\|\\('.*'\\)\\)"
	   . font-lock-string-face)
	  ("--.*$"
	   . font-lock-comment-face)
	  ("^[$][^ \\t]*"
	   . font-lock-preprocesspr-face)  ; evil spelling mistake!!!!
	  ("\\([^_]\\|^\\)\\<\\(and\\|do\\|else\\|elseif\\|end\\|\
repeat\\|return\\|then\\|until\\|while\\|\
if\\|local\\|nil\\|not\\|or\\)\\>\\([^_]\\|$\\)"
	   . font-lock-keyword-face)
	  ("^[ \\t]*function[^(]*"
	   . font-lock-function-name-face)
	  ))
  (font-lock-fontify-buffer))
(setq auto-mode-alist (append '((".*\\.lua" . lua-mode)) auto-mode-alist))
<--------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: lua-mode

Mark Tigges

Thank you very much Thomas, I appreciate it.
mark.

> 
> On Wednesday, October 28, 1998 4:05 PM, [hidden email]
> [SMTP:[hidden email]] wrote:
> > If anyone has a lua-mode.el for emacs I would be most appreciative if
> > you could share the wealth.  Otherwise I will begin writing a simple one. 
> 
> I would also appreciate a proper lua mode. Currently I am using the
> following code, which works fine in GNU Emacs 19.34
> 
> Thomas
> 
> ------------------------------------>
> ;;; Lua
> (defun lua-mode ()
>   "Lua mode"
>   (interactive)
>   (setq tab-width 4
> 	;; this will make sure that tabs are used instead of spaces
> 	indent-tabs-mode t)
>   (font-lock-mode nil)
>   (setq font-lock-keywords
> 	'(
> 	  ("[^\\\\]\\(\\(\".*\"\\)\\|\\('.*'\\)\\)"
> 	   . font-lock-string-face)
> 	  ("--.*$"
> 	   . font-lock-comment-face)
> 	  ("^[$][^ \\t]*"
> 	   . font-lock-preprocesspr-face)  ; evil spelling mistake!!!!
> 	  ("\\([^_]\\|^\\)\\<\\(and\\|do\\|else\\|elseif\\|end\\|\
> repeat\\|return\\|then\\|until\\|while\\|\
> if\\|local\\|nil\\|not\\|or\\)\\>\\([^_]\\|$\\)"
> 	   . font-lock-keyword-face)
> 	  ("^[ \\t]*function[^(]*"
> 	   . font-lock-function-name-face)
> 	  ))
>   (font-lock-fontify-buffer))
> (setq auto-mode-alist (append '((".*\\.lua" . lua-mode)) auto-mode-alist))
> <--------------------------------------
> 
> 

Reply | Threaded
Open this post in threaded view
|

RE: lua-mode

Bret Mogilefsky
In reply to this post by Mark Tigges
Here's mine... I started from tcl-mode, so if there's something not quite
functional (lua-send-region is untested, for example) you might look at
tcl-mode.el and see how it works properly there.  It was written for v2.5,
and is a little buggy with indentation on function parameters and table
initializations that span lines.  It's also got problems with anonymous
functions, but it's not at all unusable... Works great for me, though of
course there is a ton of room for improvement!  Please share any changes you
make with the class.

Bret


-----Original Message-----
From: [hidden email] [[hidden email]]
Sent: Wednesday, October 28, 1998 8:07 AM
To: Multiple recipients of list
Subject: lua-mode



Hello all,

If anyone has a lua-mode.el for emacs I would be most appreciative if
you could share the wealth.  Otherwise I will begin writing a simple one. 

Thanks,
Mark.

Attachment: lua-mode.el
Description: Binary data

Reply | Threaded
Open this post in threaded view
|

Re: lua-mode

Stephan Herrmann-2
Hi,

I just started using this lua-mode for emacs. 
Looks nice!

> Here's mine... I started from tcl-mode, so if there's something not quite
> functional (lua-send-region is untested, for example) you might look at
> tcl-mode.el and see how it works properly there.  It was written for v2.5,
> and is a little buggy with indentation on function parameters and table
> initializations that span lines.  It's also got problems with anonymous
> functions, but it's not at all unusable... 
Ok, a good starting point, but unfortunately indentation gets completely
messed up on anon-funcs etc. until the next "end"! 
Is anybody currently improving this piece of code?

> Works great for me, though of
> course there is a ton of room for improvement!  Please share any changes you
> make with the class.
I have a little addition to make the menu work with xemacs 
  (taken again from tcl.el (version of xemacs) ;-).

The second patch is a clumsy attempt to fix the problems with tables, and
anonymous functions. It still needs "special care": if you have an "end"
followed by "," or ")" you have to insert a space, like in
   foreach (tab, function (i, v)
      print("looking at ",i,v)
   end )
   print("done.")
Also the spaces around "function" are needed!
Again: are there any better solutions around?

Regards
Stephan

PS: after a little fixup, I would definitely recommend to put this on
the lua-addons page!
----------------------------- XEMACS-Patch ------------------------------

*** lua-mode.el~	Thu Apr 15 12:51:56 1999
--- lua-mode.el	Thu Apr 15 13:31:18 1999
***************
*** 76,81 ****
--- 76,83 ----
  ;;}}}
  
  ;;; Code:
+ (defconst lua-using-xemacs (string-match "XEmacs" emacs-version)
+   "Nil unless using XEmacs).")
  
  ;; We need that !
  (require 'comint)
***************
*** 189,194 ****
--- 191,207 ----
      (modify-syntax-entry ?\' "\"")
      (modify-syntax-entry ?\" "\"")
      (modify-syntax-entry ?_ "w")
+     (if (and lua-using-xemacs
+ 	     (featurep 'menubar)
+ 	     current-menubar
+ 	     (not (assoc "Lua" current-menubar)))
+ 	(progn
+ 	  (set-buffer-menubar (copy-sequence current-menubar))
+ 	  (add-menu nil "Lua" lua-xemacs-menu)))
+     ;; Append Lua menu to popup menu for XEmacs.
+     (if (and lua-using-xemacs (boundp 'mode-popup-menu))
+ 	(setq mode-popup-menu
+ 	      (cons (concat mode-name " Mode Commands") lua-xemacs-menu)))
      (run-hooks 'lua-mode-hook)))
  
  ;;}}}
***************
*** 643,648 ****
--- 656,676 ----
  (define-key lua-mode-menu [send-buffer]
    '("Send Buffer" . lua-send-buffer))
  
+ (defvar lua-xemacs-menu 
+   '(["Restart With Whole File" lua-restart-with-whole-file t]
+     ["Kill Process" lua-kill-process t]
+     ["Hide Process Buffer" lua-hide-process-buffer t]
+     ["Show Process Buffer" lua-show-process-buffer t]
+     ["Beginning Of Proc" lua-beginning-of-proc t]
+     ["End Of Proc" lua-end-of-proc t]
+     ["Set Lua-Region Start" lua-set-lua-region-start t]
+     ["Set Lua-Region End" lua-set-lua-region-end t]
+     ["Send Lua-Region" lua-send-lua-region t]
+     ["Send Current Line" lua-send-current-line t]
+     ["Send Region" lua-send-region t]
+     ["Send Proc" lua-send-proc t]
+     ["Send Buffer" lua-send-buffer t])
+   "XEmacs menu for Lua mode.")
  
  ;;}}}
  

----------------------------- Indentation-Patch ------------------------------

*** lua-mode.el~ Thu Apr 15 15:12:48 1999
--- lua-mode.el	 Thu Apr 15 17:01:23 1999
***************
*** 256,262 ****
      (setq beg (point))
      (skip-chars-forward " \t")
      (save-excursion
!       (while (looking-at "\\(}\\|else\\|elseif\\|end\\)\\($\\|\\s \\)")
                    (setq indent (max (- indent lua-indent-level) 0))
                    (forward-char 1)
                    (if (looking-at "\\([ \t]*\\)}")
--- 256,262 ----
      (setq beg (point))
      (skip-chars-forward " \t")
      (save-excursion
!       (while (looking-at "\\(}\\|else\\|elseif\\|end\\)\\([;,]\\|$\\|\\s \\)")
        (setq indent (max (- indent lua-indent-level) 0))
        (forward-char 1)
        (if (looking-at "\\([ \t]*\\)}")
***************
*** 288,294 ****
        ;; Regexp skips blank lines, searches backwards for begin/end
        ;; block markers
        (if (not (re-search-backward
!                 "\\({\\s *[#\n]\\)\\|\\(}[ \t,]*\n\\)\\|\\<\\(do\\|repeat\\|th
en\\|function\\|end\\)\\>"
                  nil t))
            (throw 'found nil)
          ;;(throw 'found t))))))
--- 288,294 ----
        ;; Regexp skips blank lines, searches backwards for begin/end
        ;; block markers
        (if (not (re-search-backward
!                 "\\({[^}]*$\\)\\|\\(}[ \t,]*\n\\)\\|\\<\\(do\\|repeat\\|while\
\|then\\|function\\|end\\)\\>"
                  nil t))
            (throw 'found nil)
          ;;(throw 'found t))))))