: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)
prefix)
'stop)))
-(defun company-elisp-predicate (symbol)
+(defun company-elisp--predicate (symbol)
(or (boundp symbol)
(fboundp symbol)
(facep symbol)
(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))
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)))
(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
(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)
(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
(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 ()
(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 ()
(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
(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
(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