[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode c2f8a7f 175/468: Use define-derived-mode
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode c2f8a7f 175/468: Use define-derived-mode |
Date: |
Thu, 5 Aug 2021 04:58:31 -0400 (EDT) |
branch: elpa/lua-mode
commit c2f8a7f8a5948de985b42a2e02dbd08bad2b605a
Author: Julien Danjou <julien@danjou.info>
Commit: Julien Danjou <julien@danjou.info>
Use define-derived-mode
This allows to inherit from `prog-mode', which is very convenient. It also
simplifies the declaration, and do not recreate the syntax table on each
lua-mode call.
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lua-mode.el | 59 +++++++++++++++++++++++++++++------------------------------
1 file changed, 29 insertions(+), 30 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 4f79e82..d8588ae 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -422,18 +422,37 @@ index of respective Lua reference manuals.")
(temp-directory)
temporary-file-directory))))))
+(defvar lua-mode-syntax-table
+ (let ((st (copy-syntax-table)))
+ (modify-syntax-entry ?+ ".")
+ (modify-syntax-entry ?- ". 12")
+ (modify-syntax-entry ?* ".")
+ (modify-syntax-entry ?/ ".")
+ (modify-syntax-entry ?^ ".")
+ ;; This might be better as punctuation, as for C, but this way you
+ ;; can treat table index as symbol.
+ (modify-syntax-entry ?. "_") ; e.g. `io.string'
+ (modify-syntax-entry ?> ".")
+ (modify-syntax-entry ?< ".")
+ (modify-syntax-entry ?= ".")
+ (modify-syntax-entry ?~ ".")
+ (modify-syntax-entry ?\n ">")
+ (modify-syntax-entry ?\' "\"")
+ (modify-syntax-entry ?\" "\""))
+ "Syntax table used while in `lua-mode'.")
+
+;; For Emacs < 24.1
+(unless (fboundp 'prog-mode)
+ (defalias 'prog-mode 'fundamental-mode))
+
;;;###autoload
-(defun lua-mode ()
- "Major mode for editing Lua code.
-The following keys are bound:
-\\{lua-mode-map}
-"
- (interactive)
+(define-derived-mode lua-mode prog-mode "Lua"
+ "Major mode for editing Lua code."
+ :abbrev-table lua-mode-abbrev-table
+ :syntax-table lua-mode-syntax-table
+ :group 'lua
(let ((switches nil)
s)
- (kill-all-local-variables)
- (setq major-mode 'lua-mode)
- (setq mode-name "Lua")
(setq comint-prompt-regexp lua-prompt-regexp)
(make-local-variable 'lua-default-command-switches)
(set (make-local-variable 'beginning-of-defun-function)
@@ -447,26 +466,7 @@ The following keys are bound:
nil nil ((?_ . "w"))))
(set (make-local-variable 'imenu-generic-expression)
lua-imenu-generic-expression)
- (setq local-abbrev-table lua-mode-abbrev-table)
- (abbrev-mode 1)
(make-local-variable 'lua-default-eval)
- (use-local-map lua-mode-map)
- (set-syntax-table (copy-syntax-table))
- (modify-syntax-entry ?+ ".")
- (modify-syntax-entry ?- ". 12")
- (modify-syntax-entry ?* ".")
- (modify-syntax-entry ?/ ".")
- (modify-syntax-entry ?^ ".")
- ;; This might be better as punctuation, as for C, but this way you
- ;; can treat table index as symbol.
- (modify-syntax-entry ?. "_") ; e.g. `io.string'
- (modify-syntax-entry ?> ".")
- (modify-syntax-entry ?< ".")
- (modify-syntax-entry ?= ".")
- (modify-syntax-entry ?~ ".")
- (modify-syntax-entry ?\n ">")
- (modify-syntax-entry ?\' "\"")
- (modify-syntax-entry ?\" "\"")
;; setup menu bar entry (XEmacs style)
(if (and (featurep 'menubar)
(boundp 'current-menubar)
@@ -491,8 +491,7 @@ The following keys are bound:
(set (make-local-variable 'parse-sexp-lookup-properties) t)
(lua-mark-all-multiline-literals)
- (lua--automark-multiline-update-timer)
- (run-hooks 'lua-mode-hook)))
+ (lua--automark-multiline-update-timer)))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
- [nongnu] elpa/lua-mode aec4eea 117/468: lua-mark/-unmark-all-multiline-literals: fix error occurring on empty buffer (fixes #4 ?), (continued)
- [nongnu] elpa/lua-mode aec4eea 117/468: lua-mark/-unmark-all-multiline-literals: fix error occurring on empty buffer (fixes #4 ?), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 535ca1b 128/468: lua-mark-char-multiline-delim, lua-unmark-multiline-literals: inhibit after-change-functions to avoid running automarking twice on the same text, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bb9330f 132/468: Fix string contents indentation (issue #6), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d57fdaf 134/468: String content indentation: put back code that forbidden ANY indentation unless it's enabled, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8435a96 137/468: Major modifications to indentation logic., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 98f7fb0 145/468: lua-calculate-indentation: remove unneeded variables & "let" form, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 167e046 147/468: lua-calculate-indentation-override: fix typo (caddr was a reference to wrong field of token table), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a0490fc 150/468: lua-font-lock-keywords: highlight hash-bang line as comment (#17), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6563aeb 156/468: Merge pull request #30 from vhallac/fix-22, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9d75878 159/468: lua-font-lock-keywords: highlight numbers as constants (issue #15), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c2f8a7f 175/468: Use define-derived-mode,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 9f5107e 181/468: Fix population of lua-mode-syntax-table (issue #42), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f92ced5 283/468: lua-send-region: send extra printline, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 68cd23d 292/468: Merge pull request #85 from immerrr/beginning-of-proc-regex, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 532701b 298/468: Add missing Lua 5.3 functions and modules, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 445bad6 301/468: Merge pull request #92 from ramnes/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7f8fbf2 308/468: lua-mode: don't remove syntax-table during unfontification, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b4943f6 313/468: Add luadoc keyword fontification (issue #71), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode debba6c 317/468: Use electric-indent-mode for per-char electric indentation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bdf121b 318/468: New release 20151025, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4b5aad7 326/468: lua-try-match-multiline-begin: don't do syntax-ppss after the opener, Philip Kaludercic, 2021/08/05