fix(emacs/lean-company.el): set timeout for company-lean--import-candidates

Custom variable lean-company-import-timeout is added (default: 1sec).

Close #766
This commit is contained in:
Soonho Kong 2015-08-06 22:53:49 -04:00
parent a4014fb532
commit f9b069b6a5
2 changed files with 14 additions and 4 deletions

View file

@ -57,10 +57,13 @@
(let* ((target-ext (pcase (lean-choose-minor-mode-based-on-extension)
(`hott "hlean")
(`standard "lean")))
(lean-files (f-files root-dir
(lambda (file) (equal (f-ext file) target-ext))
t))
;; Relative to project root-dir
(dummy (message "finding files under %s..." root-dir))
(lean-files (with-timeout (lean-company-import-timeout
(message "finding files under %s... timeout (%S sec)"
root-dir lean-company-import-timeout) nil)
(lean-find-files root-dir
(lambda (file) (equal (f-ext file) target-ext))
t)))
(lean-files-r (--map (f-relative it root-dir) lean-files))
(candidates
(--map (s-replace-all `((,(f-path-separator) . "."))

View file

@ -176,6 +176,13 @@ false (nil)."
:group 'lean
:type 'number)
(defcustom lean-company-import-timeout 1
"After lean-company-import-timeout (seconds) passed,
company-lean--import stops collecting files.
See the body of company-lean--import-candidates-main"
:group 'lean
:type 'number)
(defcustom lean-keybinding-std-exe1 (kbd "C-c C-x")
"Lean Keybinding for std-exe #1"
:group 'lean-keybinding :type 'key-sequence)