]> code.delx.au - gnu-emacs-elpa/commitdiff
company-elisp-locals: Skip current varlist
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 29 Mar 2013 08:08:43 +0000 (12:08 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 29 Mar 2013 08:08:43 +0000 (12:08 +0400)
company-elisp.el
company-tests.el

index 42e3fef849d653341af1abe138c3ea83058ce8a3..52126bd43331d669143649bd419ac63ce00649d9 100644 (file)
@@ -80,30 +80,29 @@ Functions are offered for completion only after ' and \(."
             (save-excursion
               (when (eq (char-after) ?\()
                 (forward-char 1)
-                (skip-chars-forward " \t\n")
-                (cond
-                 ((looking-at (if functions-p
-                                  company-elisp-fun-binding-regexp
-                                company-elisp-var-binding-regexp))
-                  (down-list 1)
-                  (condition-case nil
-                      (dotimes (i company-elisp-parse-limit)
-                        (save-excursion
-                          (when (looking-at "[ \t\n]*(")
-                            (down-list 1))
-                          (and (looking-at regexp)
-                               ;; Don't add incomplete text as candidate.
-                               (not (eq (match-end 0) pos))
-                               (pushnew (match-string-no-properties 1) res)))
-                        (forward-sexp))
-                    (scan-error nil)))
-                 ((unless functions-p
-                    (looking-at company-elisp-var-binding-regexp-1))
-                  (down-list 1)
-                  (and (looking-at regexp)
-                       ;; Don't add incomplete text as candidate.
-                       (not (eq (match-end 0) pos))
-                       (pushnew (match-string-no-properties 1) res))))))))
+                (when (ignore-errors
+                        (save-excursion (forward-list)
+                                        (<= (point) pos)))
+                  (skip-chars-forward " \t\n")
+                  (cond
+                   ((looking-at (if functions-p
+                                    company-elisp-fun-binding-regexp
+                                  company-elisp-var-binding-regexp))
+                    (down-list 1)
+                    (condition-case nil
+                        (dotimes (i company-elisp-parse-limit)
+                          (save-excursion
+                            (when (looking-at "[ \t\n]*(")
+                              (down-list 1))
+                            (when (looking-at regexp)
+                              (pushnew (match-string-no-properties 1) res)))
+                          (forward-sexp))
+                      (scan-error nil)))
+                   ((unless functions-p
+                      (looking-at company-elisp-var-binding-regexp-1))
+                    (down-list 1)
+                    (when (looking-at regexp)
+                      (pushnew (match-string-no-properties 1) res)))))))))
       (scan-error nil))
     res))
 
index 77ccee7e7f192dd35ef1dce2725d1b914f7cc589..c9e52cbdc2163697c56b87838944c71c166104ef 100644 (file)
          (f| )))"
     (should (equal '("fee" "foo")
                    (sort (company-elisp-locals "f" t) 'string<)))))
+
+(ert-deftest company-elisp-locals-skips-current-varlist ()
+  (company-elisp-with-buffer
+    "(let ((foo 1)
+           (f| )))"
+    (should (null (company-elisp-locals "f" nil)))))