[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 85d26f8 065/468: lua-mode-map: initialize as soon
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 85d26f8 065/468: lua-mode-map: initialize as soon as lua-mode is loaded (previously waited for call to lua-mode) |
Date: |
Thu, 5 Aug 2021 04:58:09 -0400 (EDT) |
branch: elpa/lua-mode
commit 85d26f811b5e240c0c4ad896d7f31887e0422dac
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
lua-mode-map: initialize as soon as lua-mode is loaded (previously waited
for call to lua-mode)
---
lua-mode.el | 79 +++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 46 insertions(+), 33 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 38ed501..3053f40 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -137,19 +137,58 @@ Should be a list of strings."
(defvar lua-process-buffer nil
"Buffer used for communication with Lua subprocess")
-(defvar lua-mode-map nil
- "Keymap used with lua-mode.")
+(defcustom lua-prefix-key "\C-c"
+ "Prefix for all lua-mode commands."
+ :type 'string
+ :group 'lua)
+
+(defvar lua-mode-menu (make-sparse-keymap "Lua")
+ "Keymap for lua-mode's menu.")
+
+(defvar lua-prefix-mode-map
+ (eval-when-compile
+ (let ((result-map (make-sparse-keymap)))
+ (mapc (lambda (key_defn)
+ (define-key result-map (read-kbd-macro (car key_defn)) (cdr
key_defn)))
+ '(("C-l" . lua-send-buffer)
+ ("C-f" . lua-search-documentation)))
+ result-map))
+ "Keymap that is used to define keys accessible by `lua-prefix-key'.
+
+If the latter is nil, the keymap translates into `lua-mode-map' verbatim.")
+
+(defvar lua-mode-map
+ (eval-when-compile
+ (let ((result-map (make-sparse-keymap))
+ (prefix-key (if (boundp 'lua-prefix-key) lua-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)
+ ("C-M-a" . lua-beginning-of-proc)
+ ("C-M-e" . lua-end-of-proc)
+ ("C-M-<home>" . lua-beginning-of-proc)
+ ("C-M-<end>" . lua-end-of-proc)))
+ (define-key result-map [menu-bar lua-mode] (cons "Lua" lua-mode-menu))
+
+ ;; handle prefix-keyed bindings:
+ ;; * if no prefix, set prefix-map as parent, i.e.
+ ;; if key is not defined look it up in prefix-map
+ ;; * if prefix is set, bind the prefix-map to that key
+ (if lua-prefix-key
+ (define-key result-map lua-prefix-key lua-prefix-mode-map)
+ (set-keymap-parent result-map lua-prefix-mode-map))
+ result-map))
+ "Keymap used in lua-mode buffers.")
(defvar lua-electric-flag t
"If t, electric actions (like automatic reindentation) will happen when an
electric
key like `{' is pressed")
(make-variable-buffer-local 'lua-electric-flag)
-(defcustom lua-prefix-key "\C-c"
- "Prefix for all lua-mode commands."
- :type 'string
- :group 'lua)
-
(defcustom lua-prompt-regexp "[^\n]*\\(>[\t ]+\\)+$"
"Regexp which matches the Lua program's prompt."
:type 'regexp
@@ -178,9 +217,6 @@ traceback location."
(defvar lua-region-end (make-marker)
"End of special region for Lua communication.")
-(defvar lua-mode-menu (make-sparse-keymap "Lua")
- "Keymap for lua-mode's menu.")
-
(defvar lua-emacs-menu
'(["Restart With Whole File" lua-restart-with-whole-file t]
["Kill Process" lua-kill-process t]
@@ -283,7 +319,6 @@ The following keys are bound:
(setq local-abbrev-table lua-mode-abbrev-table)
(abbrev-mode 1)
(make-local-variable 'lua-default-eval)
- (unless lua-mode-map (setq lua-mode-map (lua-setup-keymap)))
(use-local-map lua-mode-map)
(set-syntax-table (copy-syntax-table))
(modify-syntax-entry ?+ ".")
@@ -324,28 +359,6 @@ The following keys are bound:
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
-(defun lua-setup-keymap ()
- "Set up keymap for Lua mode.
-
-If the variable `lua-prefix-key' is nil, the bindings go directly
-to `lua-mode-map', otherwise they are prefixed with `lua-prefix-key'."
- (let ((result-map (make-sparse-keymap))
- (prefix-key (if (boundp 'lua-prefix-key) lua-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)
- ("C-M-a" . lua-beginning-of-proc)
- ("C-M-e" . lua-end-of-proc)
- ("C-M-<home>" . lua-beginning-of-proc)
- ("C-M-<end>" . lua-end-of-proc)
- (,(concat prefix-key " C-l") . lua-send-buffer)
- (,(concat prefix-key " C-f") . lua-search-documentation)))
- (define-key result-map [menu-bar lua-mode] (cons "Lua" lua-mode-menu))
- result-map))
(defun lua-electric-match (arg)
"Insert character and adjust indentation."
- [nongnu] elpa/lua-mode 239783b 046/468: Bump version., (continued)
- [nongnu] elpa/lua-mode 239783b 046/468: Bump version., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a5f8e7b 048/468: Fix generation and use of VERSION, and ignore release notes files., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 14300f1 049/468: Specify branch to pull from., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 60073cc 050/468: Change https to http in URL., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7af5dec 057/468: Use line-beginning(-end)-position when possible, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3ba5bf1 059/468: Redo lua-toggle-electric-state, remove extra function lua-calculate-state, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e610db4 060/468: lua-make-indentation-info-pair: readability refactoring, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode cc46763 061/468: Add some comments, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b2860f1 062/468: lua-setup-keymap: improve readability, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7935b5f 064/468: Fix previous commit, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 85d26f8 065/468: lua-mode-map: initialize as soon as lua-mode is loaded (previously waited for call to lua-mode),
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 3339da6 067/468: lua-prefix-key: auto-convert from/to character, update bindings automagically, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5842703 068/468: Add TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8165775 069/468: Fix lua-set-prefix message, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6b1d389 074/468: lua-calculate-unindentation: skip semicolons as well, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bda4fbd 075/468: lua-calculate-unindentation: update docs, remove extraneous catch, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a20b08e 078/468: lua-indent-line: remove extra variable shift-amt, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c0d6f80 079/468: Add markdown README, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 08cff6e 081/468: Implement basic multiline-aware functionality, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode dfc3b78 083/468: Preserve buffer-modified-p state when (un-)marking multiline delimiters, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7920d17 087/468: lua-mark-all-multiline-literals: if region is active, limit to region boundaries, Philip Kaludercic, 2021/08/05