[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua-mode
- From: Stephan Herrmann <stephan@...>
- Date: 15 Apr 1999 17:10:46 +0200
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))))))