summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2015-05-05 04:54:01 +0300
committerDmitry Gutov <dgutov@yandex.ru>2015-05-05 05:14:01 +0300
commit46c94cd599374556d65daffa173e7028df69bc1c (patch)
treea9234f6ae2c7c4fc63f76072adf0e5d1d6802f0a
parent201f91e5ad9619d71e1dfed327f47cb6923edd16 (diff)
downloademacs-46c94cd599374556d65daffa173e7028df69bc1c.tar.gz
Make sure we're inside the let bindings
* lisp/progmodes/elisp-mode.el (elisp-completion-at-point): Make sure we're inside the let bindings. * test/automated/elisp-mode-tests.el (elisp-completes-functions-after-let-bindings): New test.
-rw-r--r--lisp/progmodes/elisp-mode.el14
-rw-r--r--test/automated/elisp-mode-tests.el10
2 files changed, 16 insertions, 8 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 9b7bc219923..40561515ed2 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -544,13 +544,13 @@ It can be quoted, or be inside a quoted form."
(< (point) beg)))))
(list t obarray
:predicate (lambda (sym) (get sym 'error-conditions))))
- ((or `let `let*
- (and ?\(
- (guard (save-excursion
- (goto-char (1- beg))
- (up-list -1)
- (forward-symbol -1)
- (looking-at "\\_<let\\*?\\_>")))))
+ ((and (or ?\( `let `let*)
+ (guard (save-excursion
+ (goto-char (1- beg))
+ (when (eq parent ?\()
+ (up-list -1))
+ (forward-symbol -1)
+ (looking-at "\\_<let\\*?\\_>"))))
(list t obarray
:predicate #'boundp
:company-doc-buffer #'elisp--company-doc-buffer
diff --git a/test/automated/elisp-mode-tests.el b/test/automated/elisp-mode-tests.el
index 26f903dbd0c..bfecfe7dc6b 100644
--- a/test/automated/elisp-mode-tests.el
+++ b/test/automated/elisp-mode-tests.el
@@ -84,7 +84,7 @@
(should (member "bar" comps))
(should (member "baz" comps)))))
-(ert-deftest completest-variables-in-let-bindings ()
+(ert-deftest elisp-completest-variables-in-let-bindings ()
(dolist (text '("(let (ba" "(let* ((ba"))
(with-temp-buffer
(emacs-lisp-mode)
@@ -93,5 +93,13 @@
(should (member "backup-inhibited" comps))
(should-not (member "backup-buffer" comps))))))
+(ert-deftest elisp-completes-functions-after-let-bindings ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert "(let ((bar 1) (baz 2)) (ba")
+ (let ((comps (elisp--test-completions)))
+ (should (member "backup-buffer" comps))
+ (should-not (member "backup-inhibited" comps)))))
+
(provide 'elisp-mode-tests)
;;; elisp-mode-tests.el ends here