summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-25 18:26:07 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-25 18:26:07 +0100
commitca4761af930caef19427863af75b576ce611d2e4 (patch)
treeb28cc9ee10d503124132ed3429c3eb3fa2027c5a /elisp
parent310f00bbea4b70a25bd0e7d2337a589433f14b31 (diff)
downloadgeiser-chez-ca4761af930caef19427863af75b576ce611d2e4.tar.gz
geiser-chez-ca4761af930caef19427863af75b576ce611d2e4.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')
-rw-r--r--elisp/geiser-completion.el26
-rw-r--r--elisp/geiser-mode.el3
-rw-r--r--elisp/geiser-repl.el5
3 files changed, 15 insertions, 19 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)
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 9ef568e..9759c7b 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -242,6 +242,7 @@ interacting with the Geiser REPL is at your disposal.
(setq geiser-autodoc-mode-string "/A")
(setq geiser-smart-tab-mode-string "/T")
(geiser-company--setup (and geiser-mode geiser-mode-company-p))
+ (geiser-completion--setup geiser-mode)
(when geiser-mode-autodoc-p
(geiser-autodoc-mode (if geiser-mode 1 -1)))
(when geiser-mode-smart-tab-p
@@ -295,7 +296,7 @@ interacting with the Geiser REPL is at your disposal.
("Edit symbol at point" "\M-." geiser-edit-symbol-at-point
:enable (symbol-at-point))
("Go to previous definition" "\M-," geiser-pop-symbol-stack)
- ("Complete symbol" ((kbd "M-TAB")) geiser-completion--complete-symbol
+ ("Complete symbol" ((kbd "M-TAB")) completion-at-point
:enable (symbol-at-point))
("Complete module name" ((kbd "M-`") (kbd "C-."))
geiser-completion--complete-module)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 7308a6e..7c89df2 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -480,7 +480,7 @@ there's no symbol at point). Otherwise, go to next error in the REPL
buffer."
(interactive "p")
(if (> (point) (geiser-repl--last-prompt-end))
- (geiser-completion--maybe-complete)
+ (completion-at-point)
(compilation-next-error n)))
(defun geiser-repl--previous-error (n)
@@ -501,6 +501,9 @@ buffer."
(set (make-local-variable 'comint-input-ignoredups)
geiser-repl-history-no-dups-p)
(setq geiser-eval--get-module-function 'geiser-repl--module-function)
+ (geiser-completion--setup t)
+ (setq geiser-smart-tab-mode-string "")
+ (geiser-smart-tab-mode t)
(geiser-company--setup geiser-repl-company-p)
;; enabling compilation-shell-minor-mode without the annoying highlighter
(compilation-setup t))