From: Dmitry Gutov Date: Sun, 31 Mar 2013 15:58:49 +0000 (+0400) Subject: company-grab-lisp-symbol -> company-elisp--prefix; mark other privates X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/0259e7b94c7c6c00072454ade0716cb5d3646dbc company-grab-lisp-symbol -> company-elisp--prefix; mark other privates --- diff --git a/company-elisp.el b/company-elisp.el index a27edaede..53b48855c 100644 --- a/company-elisp.el +++ b/company-elisp.el @@ -44,7 +44,7 @@ first in the candidates list." :type '(choice (const :tag "Off" nil) (const :tag "On" t))) -(defun company-grab-lisp-symbol () +(defun company-elisp--prefix () (let ((prefix (company-grab-symbol))) (if prefix (unless (and (company-in-string-or-comment) @@ -52,7 +52,7 @@ first in the candidates list." prefix) 'stop))) -(defun company-elisp-predicate (symbol) +(defun company-elisp--predicate (symbol) (or (boundp symbol) (fboundp symbol) (facep symbol) @@ -75,7 +75,7 @@ first in the candidates list." (concat "\\_<\\(?:cl-\\)?" (regexp-opt '("flet" "labels")) "\\*?\\_>") "Regular expression matching head of a function bindings form.") -(defun company-elisp-locals (prefix functions-p) +(defun company-elisp--locals (prefix functions-p) (let ((regexp (concat "[ \t\n]*\\(\\_<" (regexp-quote prefix) "\\(?:\\sw\\|\\s_\\)*\\_>\\)")) (pos (point)) @@ -114,9 +114,9 @@ first in the candidates list." res)) (defun company-elisp-candidates (prefix) - (let* ((predicate (company-elisp-candidates-predicate prefix)) - (locals (company-elisp-locals prefix (eq predicate 'fboundp))) - (globals (company-elisp-globals prefix predicate)) + (let* ((predicate (company-elisp--candidates-predicate prefix)) + (locals (company-elisp--locals prefix (eq predicate 'fboundp))) + (globals (company-elisp--globals prefix predicate)) (locals (loop for local in locals when (not (member local globals)) collect local))) @@ -125,10 +125,10 @@ first in the candidates list." (sort globals 'string<)) (append locals globals)))) -(defun company-elisp-globals (prefix predicate) +(defun company-elisp--globals (prefix predicate) (all-completions prefix obarray predicate)) -(defun company-elisp-candidates-predicate (prefix) +(defun company-elisp--candidates-predicate (prefix) (let* ((completion-ignore-case nil) (before (char-before (- (point) (length prefix))))) (if (and company-elisp-detect-function-context @@ -146,9 +146,9 @@ first in the candidates list." (looking-at company-elisp-var-binding-regexp)))))) 'fboundp 'boundp) - 'company-elisp-predicate))) + 'company-elisp--predicate))) -(defun company-elisp-doc (symbol) +(defun company-elisp--doc (symbol) (let* ((symbol (intern symbol)) (doc (if (fboundp symbol) (documentation symbol t) @@ -164,10 +164,10 @@ first in the candidates list." (case command (interactive (company-begin-backend 'company-elisp)) (prefix (and (eq (derived-mode-p 'emacs-lisp-mode) 'emacs-lisp-mode) - (company-grab-lisp-symbol))) + (company-elisp--prefix))) (candidates (company-elisp-candidates arg)) (sorted company-elisp-show-locals-first) - (meta (company-elisp-doc arg)) + (meta (company-elisp--doc arg)) (doc-buffer (let ((symbol (intern arg))) (save-window-excursion (ignore-errors diff --git a/company-tests.el b/company-tests.el index d053965c4..011b67fb7 100644 --- a/company-tests.el +++ b/company-tests.el @@ -221,24 +221,24 @@ (company-elisp-with-buffer "(foo ba|)" (should (eq (let ((company-elisp-detect-function-context t)) - (company-elisp-candidates-predicate "ba")) + (company-elisp--candidates-predicate "ba")) 'boundp)) (should (eq (let (company-elisp-detect-function-context) - (company-elisp-candidates-predicate "ba")) - 'company-elisp-predicate))) + (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")) + (company-elisp--candidates-predicate "foo")) 'fboundp)) (should (eq (let (company-elisp-detect-function-context) - (company-elisp-candidates-predicate "foo")) - 'company-elisp-predicate))) + (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")) - 'company-elisp-predicate)))) + (company-elisp--candidates-predicate "b")) + 'company-elisp--predicate)))) ;; This one's also an integration test. (ert-deftest company-elisp-candidates-recognizes-binding-form () @@ -262,21 +262,21 @@ (bar t) (baz t)) (should (equal '("bar" "baz") - (company-elisp-globals "ba" 'boundp))))) + (company-elisp--globals "ba" 'boundp))))) (ert-deftest company-elisp-finds-functions () (let ((obarray [when what whelp]) (what t) (whelp t)) (should (equal '("when") - (company-elisp-globals "wh" 'fboundp))))) + (company-elisp--globals "wh" 'fboundp))))) (ert-deftest company-elisp-finds-things () (let ((obarray [when what whelp]) (what t) (whelp t)) (should (equal '("what" "whelp" "when") - (sort (company-elisp-globals "wh" 'company-elisp-predicate) + (sort (company-elisp--globals "wh" 'company-elisp--predicate) 'string<))))) (ert-deftest company-elisp-locals-vars () @@ -286,7 +286,7 @@ (lambda (boo baz) b|)))" (should (equal '("bar" "baz" "boo") - (company-elisp-locals "b" nil))))) + (company-elisp--locals "b" nil))))) (ert-deftest company-elisp-locals-single-var () (company-elisp-with-buffer @@ -294,7 +294,7 @@ (dolist (item items) it|))" (should (equal '("itk" "item") - (company-elisp-locals "it" nil))))) + (company-elisp--locals "it" nil))))) (ert-deftest company-elisp-locals-funs () (company-elisp-with-buffer @@ -303,13 +303,13 @@ (let ((fun 4)) (f| )))" (should (equal '("fee" "foo") - (sort (company-elisp-locals "f" t) 'string<))))) + (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))))) + (should (null (company-elisp--locals "f" nil))))) (ert-deftest company-elisp-show-locals-first () (company-elisp-with-buffer