]> git.eshelyaron.com Git - emacs.git/commitdiff
Make sure we're inside the let bindings
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 5 May 2015 01:54:01 +0000 (04:54 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 5 May 2015 02:14:01 +0000 (05:14 +0300)
* 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.

lisp/progmodes/elisp-mode.el
test/automated/elisp-mode-tests.el

index 9b7bc219923a71573819ec365466293ac2c42ec7..40561515ed2fe87d7c0441e906c5f263ba8629ae 100644 (file)
@@ -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
index 26f903dbd0c6d8c21a250ea33201888c0ce042c6..bfecfe7dc6bd751ee6b2aa2165af17ea79887d13 100644 (file)
@@ -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)
         (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