[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode debba6c 317/468: Use electric-indent-mode for per
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode debba6c 317/468: Use electric-indent-mode for per-char electric indentation |
Date: |
Thu, 5 Aug 2021 04:59:01 -0400 (EDT) |
branch: elpa/lua-mode
commit debba6c8ffa3be85fd2d5d36045aa535e353c375
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Use electric-indent-mode for per-char electric indentation
---
lua-mode.el | 32 +++++++++++++++++++++-----------
test/test-electric-mode.el | 4 ++++
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 1bed9fd..ea84ee5 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -313,16 +313,20 @@ Should be a list of strings."
If the latter is nil, the keymap translates into `lua-mode-map' verbatim.")
+(defvar lua--electric-indent-chars
+ (mapcar #'string-to-char '("}" "]" ")")))
+
+
(defvar lua-mode-map
(let ((result-map (make-sparse-keymap))
prefix-key)
- (mapc (lambda (key_defn)
- (define-key result-map (read-kbd-macro (car key_defn)) (cdr
key_defn)))
- ;; here go all the default bindings
- ;; backquote enables evaluating certain symbols by comma
- `(("}" . lua-electric-match)
- ("]" . lua-electric-match)
- (")" . lua-electric-match)))
+ (unless (boundp 'electric-indent-chars)
+ (mapc (lambda (electric-char)
+ (define-key result-map
+ (read-kbd-macro
+ (char-to-string electric-char))
+ #'lua-electric-match))
+ lua--electric-indent-chars))
(define-key result-map [menu-bar lua-mode] (cons "Lua" lua-mode-menu))
;; FIXME: see if the declared logic actually works
@@ -664,9 +668,9 @@ Groups 6-9 can be used in any of argument regexps."
"Imenu generic expression for lua-mode. See `imenu-generic-expression'.")
(defvar lua-sexp-alist '(("then" . "end")
- ("function" . "end")
- ("do" . "end")
- ("repeat" . "until")))
+ ("function" . "end")
+ ("do" . "end")
+ ("repeat" . "until")))
(defvar lua-mode-abbrev-table nil
"Abbreviation table used in lua-mode buffers.")
@@ -744,6 +748,11 @@ Groups 6-9 can be used in any of argument regexps."
(with-no-warnings
(lua--setq-local comment-use-global-state t))
(lua--setq-local imenu-generic-expression lua-imenu-generic-expression)
+ (when (boundp 'electric-indent-chars)
+ ;; If electric-indent-chars is not defined, electric indentation is done
+ ;; via `lua-mode-map'.
+ (lua--setq-local electric-indent-chars
+ (append electric-indent-chars lua--electric-indent-chars)))
;; setup menu bar entry (XEmacs style)
@@ -779,7 +788,8 @@ Groups 6-9 can be used in any of argument regexps."
(defun lua-electric-match (arg)
"Insert character and adjust indentation."
(interactive "P")
- (self-insert-command (prefix-numeric-value arg))
+ (let (blink-paren-function)
+ (self-insert-command (prefix-numeric-value arg)))
(if lua-electric-flag
(lua-indent-line))
(blink-matching-open))
diff --git a/test/test-electric-mode.el b/test/test-electric-mode.el
index ed7b72a..dac4d05 100644
--- a/test/test-electric-mode.el
+++ b/test/test-electric-mode.el
@@ -11,6 +11,8 @@
(it "works with curly braces"
(with-lua-buffer
(lua--setq-local blink-matching-paren nil)
+ (make-local-variable 'electric-indent-mode)
+ (electric-indent-mode 1)
(execute-kbd-macro (kbd "return SPC foo SPC { M-j"))
(execute-kbd-macro (kbd "'baz' M-j"))
(expect (current-indentation) :to-be lua-indent-level)
@@ -21,6 +23,8 @@
(it "works with parentheses"
(with-lua-buffer
(lua--setq-local blink-matching-paren nil)
+ (make-local-variable 'electric-indent-mode)
+ (electric-indent-mode 1)
(execute-kbd-macro (kbd "return SPC foo SPC ( M-j"))
(execute-kbd-macro (kbd "'baz' M-j"))
(should (eq (current-indentation) lua-indent-level))
- [nongnu] elpa/lua-mode 6563aeb 156/468: Merge pull request #30 from vhallac/fix-22, (continued)
- [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, 2021/08/05
- [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 <=
- [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
- [nongnu] elpa/lua-mode a9945c9 340/468: possibility to connect to remote lua process, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0407042 153/468: Make lua-with-silent-modifications available during byte-compilation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b1dc70c 158/468: lua-font-lock-keywords: highlight builtin symbols (issue #15), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 52dcf7b 167/468: Merge pull request #35 from vhallac/fix-34, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a3016a2 176/468: Avoid polluting "global namespace" when striving for backward compatibility, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b124dd0 194/468: Add field containing commit SHA expanded during archive creation., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 64c1e94 197/468: lua--builtins: add "self" as keyword, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d6c8419 202/468: Fix incorrect error highlighting in 'for x = ...' statements, Philip Kaludercic, 2021/08/05