diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-25 18:26:07 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-11-25 18:26:07 +0100 |
commit | 6131191bca3acfa698e7562d84933fe02422dbd7 (patch) | |
tree | 74081e360dc4e1ec1501fe337e22493b0edbadf1 /elisp/geiser-completion.el | |
parent | 773a5037fa401907ae548c53a165bcb4ba7a4c1d (diff) | |
download | geiser-6131191bca3acfa698e7562d84933fe02422dbd7.tar.gz geiser-6131191bca3acfa698e7562d84933fe02422dbd7.tar.bz2 |
Completion: respecting tab-always-indent
... and actually using it to implement geiser-smart-tab-mode. Always
nice to un-reinvent-the-wheel.
Diffstat (limited to 'elisp/geiser-completion.el')
-rw-r--r-- | elisp/geiser-completion.el | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/elisp/geiser-completion.el b/elisp/geiser-completion.el index b308a6d..c04cc34 100644 --- a/elisp/geiser-completion.el +++ b/elisp/geiser-completion.el @@ -148,12 +148,11 @@ we're looking for a module name.") (defun geiser-completion--for-module (&optional predicate) (geiser-completion--thing-at-point t predicate)) -(defun geiser-completion--complete-symbol () - "Complete the symbol at point." - (interactive) - (let ((completion-at-point-functions '(geiser-completion--for-symbol - geiser-completion--for-module))) - (call-interactively 'completion-at-point))) +(defun geiser-completion--setup (enable) + (set (make-local-variable 'completion-at-point-functions) + (if enable + '(geiser-completion--for-symbol geiser-completion--for-module) + (default-value 'completion-at-point-functions)))) (defun geiser-completion--complete-module () "Complete module name at point." @@ -168,16 +167,6 @@ we're looking for a module name.") (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) - (not (memq (syntax-class (syntax-after (1- (point)))) - '(2 3)))))) - (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. @@ -190,7 +179,10 @@ and will try completing symbol at point otherwise." :init-value nil :lighter geiser-smart-tab-mode-string :group 'geiser-mode - :keymap `((,(kbd "TAB") . geiser-completion--maybe-complete))) + (set (make-local-variable 'tab-always-indent) + (if geiser-smart-tab-mode + 'complete + (default-value 'tab-always-indent)))) (provide 'geiser-completion) |