]> code.delx.au - gnu-emacs-elpa/commitdiff
company: Release 0.6.7
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 4 Apr 2013 20:09:23 +0000 (00:09 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 4 Apr 2013 20:09:23 +0000 (00:09 +0400)
* Two `company-elisp` tweaks.

Git commit 8dceda389115b397de48becc4b68a64f4dc4bbab

packages/company/company-elisp.el
packages/company/company-pkg.el
packages/company/company-tests.el
packages/company/company.el

index faab0b0decd848819210361d7fe40bed914cbe62..338acc544e24068ccbaa3b977833df647aff2f5b 100644 (file)
@@ -157,24 +157,29 @@ first in the candidates list."
 
 (defun company-elisp--candidates-predicate (prefix)
   (let* ((completion-ignore-case nil)
-         (before (char-before (- (point) (length prefix)))))
+         (beg (- (point) (length prefix)))
+         (before (char-before beg)))
     (if (and company-elisp-detect-function-context
-             (not (eq before ?')))
+             (not (memq before '(?' ?`))))
         (if (and (eq before ?\()
                  (not
                   (save-excursion
                     (ignore-errors
-                      (up-list -2)
-                      (and (save-excursion
-                             (forward-char 1)
-                             (looking-at "[ \t\n]*("))
-                           (prog1 (search-backward "(")
-                             (forward-char 1))
-                           (looking-at company-elisp-var-binding-regexp))))))
+                      (goto-char (1- beg))
+                      (or (company-elisp--before-binding-varlist-p)
+                          (progn
+                            (up-list -1)
+                            (company-elisp--before-binding-varlist-p)))))))
             'fboundp
           'boundp)
       'company-elisp--predicate)))
 
+(defun company-elisp--before-binding-varlist-p ()
+  (save-excursion
+    (and (prog1 (search-backward "(")
+           (forward-char 1))
+         (looking-at company-elisp-var-binding-regexp))))
+
 (defun company-elisp--doc (symbol)
   (let* ((symbol (intern symbol))
          (doc (if (fboundp symbol)
index ad69ecebf5af230566858005a1e35a460b2e9e9e..850a71cfbc077c26ff1f5a8e1c01b9ee85e2469f 100644 (file)
@@ -1 +1 @@
-(define-package "company" "0.6.6" "Modular in-buffer completion framework")\r
+(define-package "company" "0.6.7" "Modular in-buffer completion framework")\r
index 33437d8505a7209e6682da8a35924c5dac7f95c2..d4ab0b733bd37cb58bb98ceae6eb3c5229ed6c02 100644 (file)
      (setq major-mode 'emacs-lisp-mode)
      (re-search-backward "|")
      (replace-match "")
-     ,@body))
+     (let ((company-elisp-detect-function-context t))
+       ,@body)))
 
 (ert-deftest company-elisp-candidates-predicate ()
   (company-elisp-with-buffer
     "(foo ba|)"
-    (should (eq (let ((company-elisp-detect-function-context t))
-                  (company-elisp--candidates-predicate "ba"))
+    (should (eq (company-elisp--candidates-predicate "ba")
                 'boundp))
     (should (eq (let (company-elisp-detect-function-context)
                   (company-elisp--candidates-predicate "ba"))
                 'company-elisp--predicate)))
   (company-elisp-with-buffer
     "(foo| )"
-    (should (eq (let ((company-elisp-detect-function-context t))
-                  (company-elisp--candidates-predicate "foo"))
+    (should (eq (company-elisp--candidates-predicate "foo")
                 'fboundp))
     (should (eq (let (company-elisp-detect-function-context)
                   (company-elisp--candidates-predicate "foo"))
                 'company-elisp--predicate)))
   (company-elisp-with-buffer
     "(foo 'b|)"
-    (should (eq (let ((company-elisp-detect-function-context t))
-                  (company-elisp--candidates-predicate "b"))
+    (should (eq (company-elisp--candidates-predicate "b")
                 'company-elisp--predicate))))
 
+(ert-deftest company-elisp-candidates-predicate-in-docstring ()
+  (company-elisp-with-buffer
+   "(def foo () \"Doo be doo `ide|"
+   (should (eq 'company-elisp--predicate
+               (company-elisp--candidates-predicate "ide")))))
+
 ;; This one's also an integration test.
 (ert-deftest company-elisp-candidates-recognizes-binding-form ()
   (let ((company-elisp-detect-function-context t)
       (should (equal '("when")
                      (company-elisp-candidates "wh"))))))
 
+(ert-deftest company-elisp-candidates-predicate-binding-without-value ()
+  (loop for (text prefix predicate) in '(("(let (foo|" "foo" boundp)
+                                         ("(let (foo (bar|" "bar" boundp)
+                                         ("(let (foo) (bar|" "bar" fboundp))
+        do
+        (eval `(company-elisp-with-buffer
+                 ,text
+                 (should (eq ',predicate
+                             (company-elisp--candidates-predicate ,prefix)))))))
+
 (ert-deftest company-elisp-finds-vars ()
   (let ((obarray [boo bar baz backquote])
         (boo t)
index 13c61eecfffc4f79667cc479fe4a0ce6845afa21..cbfa62ffb9facfcb882db91469070ea0a616444c 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Nikolaj Schumacher
 ;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
-;; Version: 0.6.6
+;; Version: 0.6.7
 ;; Keywords: abbrev, convenience, matching
 ;; URL: http://company-mode.github.com/
 ;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x, GNU Emacs 24.x