- (pos (point)))
- (ignore-errors
- (save-excursion
- (dotimes (i company-elisp-parse-depth)
- (up-list -1)
- (save-excursion
- (cond
- ((looking-at company-elisp-binding-regexp)
- (down-list 2)
- (ignore-errors
- (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))
- (add-to-list 'vars (match-string-no-properties 1))))
- (forward-sexp))))
- ((looking-at company-elisp-binding-regexp-1)
- (down-list 2)
- (and (looking-at regexp)
- ;; Don't add incomplete text as candidate.
- (not (eq (match-end 0) pos))
- (add-to-list 'vars (match-string-no-properties 1)))))))))
- vars))
+ (pos (point))
+ res)
+ (condition-case nil
+ (save-excursion
+ (dotimes (_ company-elisp-parse-depth)
+ (up-list -1)
+ (save-excursion
+ (when (eq (char-after) ?\()
+ (forward-char 1)
+ (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 (_ company-elisp-parse-limit)
+ (save-excursion
+ (when (looking-at "[ \t\n]*(")
+ (down-list 1))
+ (when (looking-at regexp)
+ (cl-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)
+ (cl-pushnew (match-string-no-properties 1) res)))))))))
+ (scan-error nil))
+ res))