summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README14
-rw-r--r--elisp/geiser-completion.el37
-rw-r--r--elisp/geiser-mode.el13
-rw-r--r--elisp/geiser-repl.el3
4 files changed, 60 insertions, 7 deletions
diff --git a/README b/README
index b489e37..26f917e 100644
--- a/README
+++ b/README
@@ -19,8 +19,6 @@
|---------------+-------------------------------------------------|
| M-. | Edit symbol at point |
| M-, | Go back to where M-. was last invoked |
- | M-TAB | Complete symbol at point |
- | C-uM-TAB | Complete module name at point |
|---------------+-------------------------------------------------|
| C-M-x, C-cC-e | Eval definition around point |
| C-cMe | Eval definition around point and switch to REPL |
@@ -35,6 +33,18 @@
| C-cC-a | Toggle autodoc mode |
|---------------+-------------------------------------------------|
+ If `geiser-mode-smart-tab-p' is nil
+ |----------+-------------------------------|
+ | M-TAB | Complete symbol at point |
+ | C-uM-TAB | Complete module name at point |
+ |----------+-------------------------------|
+
+ If `geiser-mode-smart-tab-p' is t
+ |-------+-----------------------------------------|
+ | TAB | Complete symbol at point or indent |
+ | M-TAB | Complete module name at point or indent |
+ |-------+-----------------------------------------|
+
*** In the REPL
|--------------+-----------------------------------------|
diff --git a/elisp/geiser-completion.el b/elisp/geiser-completion.el
index 2f1aa36..814a587 100644
--- a/elisp/geiser-completion.el
+++ b/elisp/geiser-completion.el
@@ -215,6 +215,43 @@ With prefix, complete module name."
(geiser-completion--display-or-scroll completions
partial)))))))
+(defun geiser-completion--complete-module ()
+ (interactive)
+ (geiser-completion--complete-symbol t))
+
+
+;;; Smart tab mode:
+
+(make-variable-buffer-local
+ (defvar geiser-smart-tab-mode-string " SmartTab"
+ "Modeline indicator for geiser-smart-tab-mode"))
+
+(defun geiser-completion--maybe-complete ()
+ "Indent if at beginning of line or after a white space or
+closing parenthesis, try completion otherwise."
+ (interactive)
+ (let ((indent (or (bolp) (memq (syntax-class (syntax-after (1- (point))))
+ '(0 5)))))
+ (if indent (indent-according-to-mode) (geiser-completion--complete-symbol))))
+
+(define-minor-mode geiser-smart-tab-mode
+ "Toggle smart tab mode.
+With no argument, this command toggles the mode.
+Non-null prefix argument turns on the mode.
+Null prefix argument turns off the mode.
+
+When this mode is enable, TAB will indent if at point is at
+beginning of line or after a white space or closing parenthesis,
+and will try completing symbol at point otherwise. In addition,
+M-TAB will try module name completion."
+ :init-value nil
+ :lighter geiser-smart-tab-mode-string
+ :group 'geiser-mode
+ :keymap `((,(kbd "TAB") . geiser-completion--maybe-complete)
+ (,(kbd "M-TAB") . geiser-completion--complete-module)))
+
+
+
(provide 'geiser-completion)
;;; geiser-completion.el ends here
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index d58de1e..84455e7 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -43,11 +43,16 @@
:group 'geiser)
(defcustom geiser-mode-autodoc-p t
- "Whether `geiser-autodoc-mode' gets enabled by default in factor buffers."
+ "Whether `geiser-autodoc-mode' gets enabled by default in Scheme buffers."
:group 'geiser-mode
:group 'geiser-autodoc
:type 'boolean)
+(defcustom geiser-mode-smart-tab-p t
+ "Whether `geiser-smart-tab-mode' gets enabled by default in Scheme buffers."
+ :group 'geiser-mode
+ :type 'boolean)
+
;;; Auxiliary functions:
@@ -132,10 +137,12 @@ interacting with the Geiser REPL is at your disposal.
\\{geiser-mode-map}"
:init-value nil
:lighter geiser-mode-string
- :group 'geiser
+ :group 'geiser-mode
:keymap geiser-mode-map
(setq geiser-autodoc-mode-string "/A")
- (when geiser-mode-autodoc-p (geiser-autodoc-mode geiser-mode)))
+ (setq geiser-smart-tab-mode-string "/T")
+ (when geiser-mode-autodoc-p (geiser-autodoc-mode geiser-mode))
+ (when geiser-mode-smart-tab-p (geiser-smart-tab-mode geiser-mode)))
;;; Keys:
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index e9a0eb0..dbf277a 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -156,8 +156,7 @@ REPL buffer."
(define-key geiser-repl-mode-map "\C-c\M-n" 'comint-next-input)
(define-key geiser-repl-mode-map (kbd "TAB") 'geiser-completion--complete-symbol)
-(define-key geiser-repl-mode-map (kbd "M-TAB")
- '(lambda () (interactive) (geiser-completion--complete-symbol t)))
+(define-key geiser-repl-mode-map (kbd "M-TAB") 'geiser-completion--complete-module)
(define-key geiser-repl-mode-map "\M-." 'geiser-edit-symbol-at-point)
(define-key geiser-repl-mode-map "\M-," 'geiser-edit-pop-edit-symbol-stack)