summaryrefslogtreecommitdiff
path: root/elisp/geiser-completion.el
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-15 18:41:04 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-15 18:41:04 +0100
commit8d137f9e77811f16d536f73cc1c059a77782f7de (patch)
tree27f53c14da484987ff9c5093dcf098a75040e0c3 /elisp/geiser-completion.el
parent5f34ef433af9deb412f29fb509de8f5d1082526d (diff)
downloadgeiser-8d137f9e77811f16d536f73cc1c059a77782f7de.tar.gz
geiser-8d137f9e77811f16d536f73cc1c059a77782f7de.tar.bz2
Smart tab completion mode.
Diffstat (limited to 'elisp/geiser-completion.el')
-rw-r--r--elisp/geiser-completion.el37
1 files changed, 37 insertions, 0 deletions
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