Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make change timeout configurable, don't run typecheck if not needed #19

Merged
merged 2 commits into from
Oct 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions dhall-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ If specified, this should be the complete path to your dhall-format executable,
:group 'dhall
:safe t)

(defcustom dhall-type-check-inactivity-timeout 1
"How long to wait in seconds between inactivity in the buffer before evaluating the buffer type. You can try increasing this if type checking is slowing things down. You can also disable type-checking entirely by setting dhall-use-header-line to nil."
:type 'number
:group 'dhall
:safe 'numberp)

(defun dhall-buffer-type ()
"Return the type of the expression in the current buffer."
(interactive)
Expand Down Expand Up @@ -262,9 +268,10 @@ STRING-TYPE type of string based off of Emacs syntax table types"

(defun dhall-after-change (&optional _beg _end _length)
"Called after any change in the buffer."
(when dhall-buffer-type-compute-timer
(when dhall-use-header-line
(when dhall-buffer-type-compute-timer
(cancel-timer dhall-buffer-type-compute-timer))
(setq dhall-buffer-type-compute-timer (run-at-time 1 nil 'dhall-buffer-type-compute)))
(setq dhall-buffer-type-compute-timer (run-at-time dhall-type-check-inactivity-timeout nil 'dhall-buffer-type-compute))))

;; The main mode functions
;;;###autoload
Expand Down