+(defvar company-elisp-defuns-regexp
+ (concat "([ \t\n]*"
+ (apply #'company-elisp--fns-regexp company-elisp-defun-names)))
+
+(defun company-elisp--should-complete ()
+ (let ((start (point))
+ (depth (car (syntax-ppss))))
+ (not
+ (when (> depth 0)
+ (save-excursion
+ (up-list (- depth))
+ (when (looking-at company-elisp-defuns-regexp)
+ (forward-char)
+ (forward-sexp 1)
+ (unless (= (point) start)
+ (condition-case nil
+ (let ((args-end (scan-sexps (point) 2)))
+ (or (null args-end)
+ (> args-end start)))
+ (scan-error
+ t)))))))))
+
+(defun company-elisp--locals (prefix functions-p)