summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2020-10-02 15:07:00 +0200
committerjao <jao@gnu.org>2020-12-02 19:27:20 +0000
commit887cefb5cec2a8f86907339158431514c1e519e1 (patch)
tree40979c6f3642e30bbc3bbd0ad48ddb01d03fb5bc
parent701aab2db64690e1f42725d6163291e4e0878ad2 (diff)
downloadgeiser-887cefb5cec2a8f86907339158431514c1e519e1.tar.gz
geiser-887cefb5cec2a8f86907339158431514c1e519e1.tar.bz2
Declare keymaps using defvar explicitly
This makes it possible to re-evaluate the containing buffers without user customizations being clobbered.
-rw-r--r--elisp/geiser-log.el9
-rw-r--r--elisp/geiser-mode.el129
-rw-r--r--elisp/geiser-repl.el123
3 files changed, 134 insertions, 127 deletions
diff --git a/elisp/geiser-log.el b/elisp/geiser-log.el
index e542042..6444335 100644
--- a/elisp/geiser-log.el
+++ b/elisp/geiser-log.el
@@ -53,6 +53,12 @@
;;; Log buffer and mode:
+(defvar geiser-messages-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "c" 'geiser-log-clear)
+ (define-key map "Q" 'geiser-log--deactivate)
+ map))
+
(define-derived-mode geiser-messages-mode fundamental-mode "Geiser Messages"
"Simple mode for Geiser log messages buffer."
(buffer-disable-undo)
@@ -126,8 +132,5 @@ With prefix, activates all logging levels."
(setq geiser-log-verbose-p nil)
(when (eq (current-buffer) (geiser-log--buffer)) (View-quit)))
-(define-key geiser-messages-mode-map "c" 'geiser-log-clear)
-(define-key geiser-messages-mode-map "Q" 'geiser-log--deactivate)
-
(provide 'geiser-log)
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 303489d..61a9813 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -274,6 +274,70 @@ With prefix, try to enter the current buffer's module."
(pop-to-buffer b)))
+;;; Keys:
+
+(defvar geiser-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [menu-bar scheme] 'undefined)
+ ;; (geiser-mode--triple-chord ?x ?m 'geiser-xref-generic-methods)
+
+ (geiser-menu--defmenu geiserm map
+ ("Eval sexp before point" "\C-x\C-e" geiser-eval-last-sexp)
+ ("Eval definition" ("\M-\C-x" "\C-c\C-c") geiser-eval-definition)
+ ("Eval definition and go" ("\C-c\M-e" "\C-c\M-e")
+ geiser-eval-definition-and-go)
+ ("Eval region" "\C-c\C-r" geiser-eval-region :enable mark-active)
+ ("Eval region and go" "\C-c\M-r" geiser-eval-region-and-go
+ geiser-eval-region :enable mark-active)
+ ("Eval buffer" "\C-c\C-b" geiser-eval-buffer)
+ ("Eval buffer and go" "\C-c\M-b" geiser-eval-buffer-and-go)
+ ("Load scheme file..." "\C-c\C-l" geiser-load-file)
+ (menu "Macroexpand"
+ ("Sexp before point" ("\C-c\C-m\C-e" "\C-c\C-me")
+ geiser-expand-last-sexp)
+ ("Region" ("\C-c\C-m\C-r" "\C-c\C-mr") geiser-expand-region)
+ ("Definition" ("\C-c\C-m\C-x" "\C-c\C-mx") geiser-expand-definition))
+ --
+ ("Symbol documentation" ("\C-c\C-d\C-d" "\C-c\C-dd")
+ geiser-doc-symbol-at-point :enable (geiser--symbol-at-point))
+ ("Short symbol documentation" ("\C-c\C-d\C-s" "\C-c\C-ds")
+ geiser-autodoc-show :enable (geiser--symbol-at-point))
+ ("Module documentation" ("\C-c\C-d\C-m" "\C-c\C-dm") geiser-doc-module)
+ ("Symbol manual lookup" ("\C-c\C-d\C-i" "\C-c\C-di")
+ geiser-doc-look-up-manual :enable (geiser-doc--manual-available-p))
+ (mode "Autodoc mode" ("\C-c\C-d\C-a" "\C-c\C-da") geiser-autodoc-mode)
+ --
+ ("Compile buffer" "\C-c\C-k" geiser-compile-current-buffer)
+ ("Switch to REPL" "\C-c\C-z" geiser-mode-switch-to-repl)
+ ("Switch to REPL and enter module" "\C-c\C-a"
+ geiser-mode-switch-to-repl-and-enter)
+ ("Set Scheme..." "\C-c\C-s" geiser-set-scheme)
+ --
+ ("Edit symbol at point" "\M-." geiser-edit-symbol-at-point
+ :enable (geiser--symbol-at-point))
+ ("Go to previous definition" "\M-," geiser-pop-symbol-stack)
+ ("Complete symbol" ((kbd "M-TAB")) completion-at-point
+ :enable (geiser--symbol-at-point))
+ ("Complete module name" ((kbd "M-`") (kbd "C-."))
+ geiser-completion--complete-module)
+ ("Edit module" ("\C-c\C-e\C-m" "\C-c\C-em") geiser-edit-module)
+ ("Add to load path..." ("\C-c\C-e\C-l" "\C-c\C-el") geiser-add-to-load-path)
+ ("Toggle ()/[]" ("\C-c\C-e\C-[" "\C-c\C-e[") geiser-squarify)
+ ("Insert λ" ("\C-c\\" "\C-c\C-\\") geiser-insert-lambda)
+ --
+ ("Callers" ((kbd "C-c <")) geiser-xref-callers
+ :enable (and (geiser-eval--supported-p 'callers)
+ (geiser--symbol-at-point)))
+ ("Callees" ((kbd "C-c >")) geiser-xref-callees
+ :enable (and (geiser-eval--supported-p 'callees)
+ (geiser--symbol-at-point)))
+ --
+ (mode "Smart TAB mode" nil geiser-smart-tab-mode)
+ --
+ (custom "Customize Geiser mode" geiser-mode))
+ map))
+
+
;;; Geiser mode:
(make-variable-buffer-local
@@ -284,8 +348,6 @@ With prefix, try to enter the current buffer's module."
(or geiser-mode-string
(format " %s" (or (geiser-impl--impl-str) "G"))))
-(defvar geiser-mode-map (make-sparse-keymap))
-
(define-minor-mode geiser-mode
"Toggle Geiser's mode.
@@ -299,7 +361,6 @@ interacting with the Geiser REPL is at your disposal.
:init-value nil
:lighter (:eval (geiser-mode--lighter))
:group 'geiser-mode
- :keymap geiser-mode-map
(when geiser-mode (geiser-impl--set-buffer-implementation nil t))
(setq geiser-autodoc-mode-string "/A")
(setq geiser-smart-tab-mode-string "/T")
@@ -331,68 +392,6 @@ interacting with the Geiser REPL is at your disposal.
(turn-on-geiser-mode)))
-;;; Keys:
-
-(geiser-menu--defmenu geiserm geiser-mode-map
- ("Eval sexp before point" "\C-x\C-e" geiser-eval-last-sexp)
- ("Eval definition" ("\M-\C-x" "\C-c\C-c") geiser-eval-definition)
- ("Eval definition and go" ("\C-c\M-e" "\C-c\M-e")
- geiser-eval-definition-and-go)
- ("Eval region" "\C-c\C-r" geiser-eval-region :enable mark-active)
- ("Eval region and go" "\C-c\M-r" geiser-eval-region-and-go
- geiser-eval-region :enable mark-active)
- ("Eval buffer" "\C-c\C-b" geiser-eval-buffer)
- ("Eval buffer and go" "\C-c\M-b" geiser-eval-buffer-and-go)
- ("Load scheme file..." "\C-c\C-l" geiser-load-file)
- (menu "Macroexpand"
- ("Sexp before point" ("\C-c\C-m\C-e" "\C-c\C-me")
- geiser-expand-last-sexp)
- ("Region" ("\C-c\C-m\C-r" "\C-c\C-mr") geiser-expand-region)
- ("Definition" ("\C-c\C-m\C-x" "\C-c\C-mx") geiser-expand-definition))
- --
- ("Symbol documentation" ("\C-c\C-d\C-d" "\C-c\C-dd")
- geiser-doc-symbol-at-point :enable (geiser--symbol-at-point))
- ("Short symbol documentation" ("\C-c\C-d\C-s" "\C-c\C-ds")
- geiser-autodoc-show :enable (geiser--symbol-at-point))
- ("Module documentation" ("\C-c\C-d\C-m" "\C-c\C-dm") geiser-doc-module)
- ("Symbol manual lookup" ("\C-c\C-d\C-i" "\C-c\C-di")
- geiser-doc-look-up-manual :enable (geiser-doc--manual-available-p))
- (mode "Autodoc mode" ("\C-c\C-d\C-a" "\C-c\C-da") geiser-autodoc-mode)
- --
- ("Compile buffer" "\C-c\C-k" geiser-compile-current-buffer)
- ("Switch to REPL" "\C-c\C-z" geiser-mode-switch-to-repl)
- ("Switch to REPL and enter module" "\C-c\C-a"
- geiser-mode-switch-to-repl-and-enter)
- ("Set Scheme..." "\C-c\C-s" geiser-set-scheme)
- --
- ("Edit symbol at point" "\M-." geiser-edit-symbol-at-point
- :enable (geiser--symbol-at-point))
- ("Go to previous definition" "\M-," geiser-pop-symbol-stack)
- ("Complete symbol" ((kbd "M-TAB")) completion-at-point
- :enable (geiser--symbol-at-point))
- ("Complete module name" ((kbd "M-`") (kbd "C-."))
- geiser-completion--complete-module)
- ("Edit module" ("\C-c\C-e\C-m" "\C-c\C-em") geiser-edit-module)
- ("Add to load path..." ("\C-c\C-e\C-l" "\C-c\C-el") geiser-add-to-load-path)
- ("Toggle ()/[]" ("\C-c\C-e\C-[" "\C-c\C-e[") geiser-squarify)
- ("Insert λ" ("\C-c\\" "\C-c\C-\\") geiser-insert-lambda)
- --
- ("Callers" ((kbd "C-c <")) geiser-xref-callers
- :enable (and (geiser-eval--supported-p 'callers)
- (geiser--symbol-at-point)))
- ("Callees" ((kbd "C-c >")) geiser-xref-callees
- :enable (and (geiser-eval--supported-p 'callees)
- (geiser--symbol-at-point)))
- --
- (mode "Smart TAB mode" nil geiser-smart-tab-mode)
- --
- (custom "Customize Geiser mode" geiser-mode))
-
-(define-key geiser-mode-map [menu-bar scheme] 'undefined)
-
-;; (geiser-mode--triple-chord ?x ?m 'geiser-xref-generic-methods)
-
-
;;; Reload support:
(defun geiser-mode--buffers ()
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index c41f05d..3907455 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -822,6 +822,70 @@ buffer."
(goto-char (geiser-repl--last-prompt-end)))
(recenter t)))
+(defvar geiser-repl-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map comint-mode-map)
+
+ (define-key map "\C-d" 'delete-char)
+ (define-key map "\C-m" 'geiser-repl--maybe-send)
+ (define-key map [return] 'geiser-repl--maybe-send)
+ (define-key map "\C-j" 'geiser-repl--newline-and-indent)
+ (define-key map (kbd "TAB") 'geiser-repl-tab-dwim)
+ (define-key map [backtab] 'geiser-repl--previous-error)
+
+ (define-key map "\C-a" 'geiser-repl--bol)
+ (define-key map (kbd "<home>") 'geiser-repl--bol)
+
+ (geiser-menu--defmenu repl map
+ ("Complete symbol" ((kbd "M-TAB"))
+ completion-at-point :enable (geiser--symbol-at-point))
+ ("Complete module name" ((kbd "C-.") (kbd "M-`"))
+ geiser-completion--complete-module :enable (geiser--symbol-at-point))
+ ("Edit symbol" "\M-." geiser-edit-symbol-at-point
+ :enable (geiser--symbol-at-point))
+ --
+ ("Load scheme file..." "\C-c\C-l" geiser-load-file)
+ ("Switch to module..." "\C-c\C-m" switch-to-geiser-module)
+ ("Import module..." "\C-c\C-i" geiser-repl-import-module)
+ ("Add to load path..." "\C-c\C-r" geiser-add-to-load-path)
+ --
+ ("Previous matching input" "\M-p" comint-previous-matching-input-from-input
+ "Previous input matching current")
+ ("Next matching input" "\M-n" comint-next-matching-input-from-input
+ "Next input matching current")
+ ("Previous prompt" "\C-c\C-p" geiser-repl-previous-prompt)
+ ("Next prompt" "\C-c\C-n" geiser-repl-next-prompt)
+ ("Previous input" "\C-c\M-p" comint-previous-input)
+ ("Next input" "\C-c\M-n" comint-next-input)
+ --
+ ("Interrupt evaluation" ("\C-c\C-k" "\C-c\C-c")
+ geiser-repl-interrupt)
+ --
+ (mode "Autodoc mode" ("\C-c\C-da" "\C-c\C-d\C-a") geiser-autodoc-mode)
+ ("Symbol documentation" ("\C-c\C-dd" "\C-c\C-d\C-d")
+ geiser-doc-symbol-at-point
+ "Documentation for symbol at point" :enable (geiser--symbol-at-point))
+ ("Lookup symbol in manual" ("\C-c\C-di" "\C-c\C-d\C-i")
+ geiser-doc-look-up-manual
+ "Documentation for symbol at point" :enable (geiser--symbol-at-point))
+ ("Module documentation" ("\C-c\C-dm" "\C-c\C-d\C-m") geiser-repl--doc-module
+ "Documentation for module at point" :enable (geiser--symbol-at-point))
+ --
+ ("Clear buffer" "\C-c\M-o" geiser-repl-clear-buffer
+ "Clean up REPL buffer, leaving just a lonely prompt")
+ ("Toggle ()/[]" ("\C-c\C-e\C-[" "\C-c\C-e[") geiser-squarify)
+ ("Insert λ" ("\C-c\\" "\C-c\C-\\") geiser-insert-lambda)
+ --
+ ("Kill Scheme interpreter" "\C-c\C-q" geiser-repl-exit
+ :enable (geiser-repl--live-p))
+ ("Restart" "\C-c\C-z" switch-to-geiser :enable (not (geiser-repl--live-p)))
+
+ --
+ (custom "REPL options" geiser-repl))
+
+ (define-key map [menu-bar completion] 'undefined)
+ map))
+
(define-derived-mode geiser-repl-mode comint-mode "REPL"
"Major mode for interacting with an inferior scheme repl process.
\\{geiser-repl-mode-map}"
@@ -853,65 +917,6 @@ buffer."
;; enabling compilation-shell-minor-mode without the annoying highlighter
(compilation-setup t))
-(define-key geiser-repl-mode-map "\C-d" 'delete-char)
-(define-key geiser-repl-mode-map "\C-m" 'geiser-repl--maybe-send)
-(define-key geiser-repl-mode-map [return] 'geiser-repl--maybe-send)
-(define-key geiser-repl-mode-map "\C-j" 'geiser-repl--newline-and-indent)
-(define-key geiser-repl-mode-map (kbd "TAB") 'geiser-repl-tab-dwim)
-(define-key geiser-repl-mode-map [backtab] 'geiser-repl--previous-error)
-
-(define-key geiser-repl-mode-map "\C-a" 'geiser-repl--bol)
-(define-key geiser-repl-mode-map (kbd "<home>") 'geiser-repl--bol)
-
-(geiser-menu--defmenu repl geiser-repl-mode-map
- ("Complete symbol" ((kbd "M-TAB"))
- completion-at-point :enable (geiser--symbol-at-point))
- ("Complete module name" ((kbd "C-.") (kbd "M-`"))
- geiser-completion--complete-module :enable (geiser--symbol-at-point))
- ("Edit symbol" "\M-." geiser-edit-symbol-at-point
- :enable (geiser--symbol-at-point))
- --
- ("Load scheme file..." "\C-c\C-l" geiser-load-file)
- ("Switch to module..." "\C-c\C-m" switch-to-geiser-module)
- ("Import module..." "\C-c\C-i" geiser-repl-import-module)
- ("Add to load path..." "\C-c\C-r" geiser-add-to-load-path)
- --
- ("Previous matching input" "\M-p" comint-previous-matching-input-from-input
- "Previous input matching current")
- ("Next matching input" "\M-n" comint-next-matching-input-from-input
- "Next input matching current")
- ("Previous prompt" "\C-c\C-p" geiser-repl-previous-prompt)
- ("Next prompt" "\C-c\C-n" geiser-repl-next-prompt)
- ("Previous input" "\C-c\M-p" comint-previous-input)
- ("Next input" "\C-c\M-n" comint-next-input)
- --
- ("Interrupt evaluation" ("\C-c\C-k" "\C-c\C-c")
- geiser-repl-interrupt)
- --
- (mode "Autodoc mode" ("\C-c\C-da" "\C-c\C-d\C-a") geiser-autodoc-mode)
- ("Symbol documentation" ("\C-c\C-dd" "\C-c\C-d\C-d")
- geiser-doc-symbol-at-point
- "Documentation for symbol at point" :enable (geiser--symbol-at-point))
- ("Lookup symbol in manual" ("\C-c\C-di" "\C-c\C-d\C-i")
- geiser-doc-look-up-manual
- "Documentation for symbol at point" :enable (geiser--symbol-at-point))
- ("Module documentation" ("\C-c\C-dm" "\C-c\C-d\C-m") geiser-repl--doc-module
- "Documentation for module at point" :enable (geiser--symbol-at-point))
- --
- ("Clear buffer" "\C-c\M-o" geiser-repl-clear-buffer
- "Clean up REPL buffer, leaving just a lonely prompt")
- ("Toggle ()/[]" ("\C-c\C-e\C-[" "\C-c\C-e[") geiser-squarify)
- ("Insert λ" ("\C-c\\" "\C-c\C-\\") geiser-insert-lambda)
- --
- ("Kill Scheme interpreter" "\C-c\C-q" geiser-repl-exit
- :enable (geiser-repl--live-p))
- ("Restart" "\C-c\C-z" switch-to-geiser :enable (not (geiser-repl--live-p)))
-
- --
- (custom "REPL options" geiser-repl))
-
-(define-key geiser-repl-mode-map [menu-bar completion] 'undefined)
-
;;; User commands