[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode b2860f1 062/468: lua-setup-keymap: improve readab
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode b2860f1 062/468: lua-setup-keymap: improve readability |
Date: |
Thu, 5 Aug 2021 04:58:08 -0400 (EDT) |
branch: elpa/lua-mode
commit b2860f183eebead2e9d046d69d1bb44372634e21
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
lua-setup-keymap: improve readability
---
lua-mode.el | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 96750a8..160209e 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -286,8 +286,7 @@ The following keys are bound:
(setq local-abbrev-table lua-mode-abbrev-table)
(abbrev-mode 1)
(make-local-variable 'lua-default-eval)
- (or lua-mode-map
- (lua-setup-keymap))
+ (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 ?+ ".")
@@ -330,28 +329,26 @@ The following keys are bound:
(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'."
- (setq lua-mode-map (make-sparse-keymap))
- (define-key lua-mode-map [menu-bar lua-mode]
- (cons "Lua" lua-mode-menu))
- (define-key lua-mode-map "}" 'lua-electric-match)
- (define-key lua-mode-map "]" 'lua-electric-match)
- (define-key lua-mode-map ")" 'lua-electric-match)
- (define-key lua-mode-map (kbd "C-M-a") 'lua-beginning-of-proc)
- (define-key lua-mode-map (kbd "C-M-e") 'lua-end-of-proc)
- (define-key lua-mode-map (kbd "C-M-<home>") 'lua-beginning-of-proc)
- (define-key lua-mode-map (kbd "C-M-<end>") 'lua-end-of-proc)
- (let ((map (if lua-prefix-key
- (make-sparse-keymap)
- lua-mode-map)))
-
- ;; communication
- (define-key map "\C-l" 'lua-send-buffer)
- (define-key map "\C-f" 'lua-search-documentation)
- (if lua-prefix-key
- (define-key lua-mode-map lua-prefix-key map))
- ))
+ (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 de08e4b 028/468: Added version comment for Tom Tromeys package.el, (continued)
- [nongnu] elpa/lua-mode de08e4b 028/468: Added version comment for Tom Tromeys package.el, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 676f0a6 045/468: Sync with reality., Philip Kaludercic, 2021/08/05
- [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 <=
- [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, 2021/08/05
- [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