lua-users home
lua-l archive

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


On Sat, 15 Apr 2006, Adam D. Moss wrote:

I use lua-mode constantly.  I think my hacked version is/was
on the wiki.  I really don't understand elisp though (I don't
think I want to!).

Argh. The version on the wiki looks older than the one I have (though Christian Vogler's stamp on it is newer on the wiki one). I attach a diff. If anyone would like to work on getting a definitive version up, I'm game. I use it all the time too.

As you'll see from the diff, the changes are mostly minor.

--
http://rrt.sc3d.org/
Reality is what refuses to disappear when you stop believing in it (Dick)
--- /home/rrt/download/lua-mode.el	2006-04-16 01:32:06.000000000 +0100
+++ lua-mode.el	2004-05-31 14:55:02.000000000 +0100
@@ -1,11 +1,12 @@
 ;;; lua-mode.el --- a major-mode for editing lua scripts
 
 ;; FIXME: Update this version number and date
-;; $Id: lua-mode.el 174 2005-09-25 13:59:28Z cvogler $
+;; $Id: lua-mode.el,v 1.26 2001/07/08 19:06:50 cvogler Exp $
 
-;; Copyright (C) 1997, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001, 2004 Free Software Foundation, Inc.
 
-;; Author: 2001 Christian Vogler <cvogler@gradient.cis.upenn.edu>
+;; Author: 2004 various (support for Lua 5 and byte compilation)
+;;         2001 Christian Vogler <cvogler@gradient.cis.upenn.edu>
 ;;         1997 Bret Mogilefsky <mogul-lua@gelatinous.com> starting from
 ;;              tcl-mode by Gregor Schmid <schmid@fb3-s7.math.tu-berlin.de>
 ;;              with tons of assistance from
@@ -93,7 +94,7 @@
 
 ;;{{{ variables
 
-(defvar lua-default-application "/home/swt/swt/oose/lua/bin/lua"
+(defvar lua-default-application "/usr/bin/lua"
   "Default application to run in lua subprocess.")
 
 (defvar lua-default-command-switches nil
@@ -130,6 +131,22 @@
 (defvar lua-mode-menu (make-sparse-keymap "Lua")
   "Keymap for lua-mode's menu.")
 
+(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.")
+
 (defvar lua-font-lock-keywords
   (eval-when-compile
     (list
@@ -168,6 +185,9 @@
   '((nil "^[ \t]*function[ \t]+\\(\\(\\sw:\\|\\sw_\\|\\sw\\.\\|\\sw\\)+\\)" 1)) ; Original
   "Imenu generic expression for lua-mode.  See `imenu-generic-expression'.")
 
+(defvar lua-mode-abbrev-table nil
+  "Abbreviation table used in lua-mode buffers.")
+
 (define-abbrev-table 'lua-mode-abbrev-table
   '(
         ("end" "end" lua-indent-line 0)
@@ -239,6 +259,9 @@
 	      (cons (concat mode-name " Mode Commands") lua-xemacs-menu)))
     (run-hooks 'lua-mode-hook)))
 
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
+
 ;;}}}
 ;;{{{ lua-setup-keymap
 
@@ -386,6 +409,27 @@
     (")"        "("                                           close)))
 
 
+(eval-when-compile
+  (defconst lua-indentation-modifier-regexp
+    ;; The absence of else is deliberate, since it does not modify the
+    ;; indentation level per se. It only may cause the line, in which the
+    ;; else is, to be shifted to the left.
+    ;; This is the code we used to generate the regexp:
+    (concat
+     "\\(\\<"
+     ; n.b. "local function" is a bit of a hack, allowing only a single space
+     (regexp-opt '("do" "local function" "function" "repeat" "then") t)
+     "\\>\\|"
+     (regexp-opt '("{" "(" "["))
+     "\\)\\|\\(\\<"
+     (regexp-opt '("elseif" "end" "until") t)
+     "\\>\\|"
+     (regexp-opt '("]" ")" "}"))
+     "\\)")
+
+    ))
+
+
 (defun lua-find-matching-token-word (token search-start)
   (let* ((token-info (assoc token lua-block-token-alist))
 	 (match (car (cdr token-info)))
@@ -649,29 +693,6 @@
 	  info-list)
     (cons type accu)))
 
-
-
-(defconst lua-indentation-modifier-regexp
-  (eval-when-compile
-    ;; The absence of else is deliberate, since it does not modify the
-    ;; indentation level per se. It only may cause the line, in which the
-    ;; else is, to be shifted to the left.
-    ;; This is the code we used to generate the regexp:
-    (concat
-     "\\(\\<"
-     ; n.b. "local function" is a bit of a hack, allowing only a single space
-     (regexp-opt '("do" "local function" "function" "repeat" "then") t)
-     "\\>\\|"
-     (regexp-opt '("{" "(" "["))
-     "\\)\\|\\(\\<"
-     (regexp-opt '("elseif" "end" "until") t)
-     "\\>\\|"
-     (regexp-opt '("]" ")" "}"))
-     "\\)")
-
-    ))
-
-
 (defun lua-calculate-indentation-block-modifier (&optional parse-start
 							   parse-end)
   "Return amount by which this line modifies the indentation.
@@ -689,22 +710,21 @@
 	 (cdr indentation-info)
 	 (if (lua-is-continuing-statement-p) (- lua-indent-level) 0)))))
 
-
-(defconst lua-left-shift-regexp-1
-  (eval-when-compile
+(eval-when-compile
+  (defconst lua-left-shift-regexp-1
     (concat "\\("
-	    "\\(\\<" (regexp-opt '("else" "elseif" "until") t)
-	    "\\>\\)\\($\\|\\s +\\)"
-	    "\\)")))
+            "\\(\\<" (regexp-opt '("else" "elseif" "until") t)
+            "\\>\\)\\($\\|\\s +\\)"
+            "\\)")))
 
-(defconst lua-left-shift-regexp-2
-  (eval-when-compile
+(eval-when-compile
+  (defconst lua-left-shift-regexp-2
     (concat "\\(\\<"
-	    (regexp-opt '("end") t)
-	    "\\>\\)")))
+            (regexp-opt '("end") t)
+            "\\>\\)")))
 
-(defconst lua-left-shift-regexp
-  (eval-when-compile
+(eval-when-compile
+  (defconst lua-left-shift-regexp
     ;; This is the code we used to generate the regexp:
     ;; ("else", "elseif", "until" followed by whitespace, or "end"/closing
     ;; brackets followed by
@@ -720,12 +740,12 @@
 (defconst lua-left-shift-pos-1
   2)
 
-(defconst lua-left-shift-pos-2
-  (eval-when-compile
+(eval-when-compile
+  (defconst lua-left-shift-pos-2
     (+ 3 (regexp-opt-depth lua-left-shift-regexp-1))))
 
-(defconst lua-left-shift-pos-3
-  (eval-when-compile
+(eval-when-compile
+  (defconst lua-left-shift-pos-3
     (+ lua-left-shift-pos-2
        (regexp-opt-depth lua-left-shift-regexp-2))))
 
@@ -1064,22 +1084,6 @@
 (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.")
-
 ;;}}}
 
 (provide 'lua-mode)