[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 22a7372 31/39: Flymake uses proper idle timers
From: |
João Távora |
Subject: |
[Emacs-diffs] emacs-26 22a7372 31/39: Flymake uses proper idle timers |
Date: |
Tue, 3 Oct 2017 10:04:53 -0400 (EDT) |
branch: emacs-26
commit 22a7372faba317a3589c49fef912e542f3197f0d
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Flymake uses proper idle timers
Also, flymake-no-changes-timeout can be set to nil to disable
automatic periodic checks. But even in that situation the idle timer
still runs at a reduced rate to detect changes in the variable and
revert that decision.
* lisp/progmodes/flymake.el (flymake-no-changes-timeout): Improve doc.
(flymake-last-change-time): Delete.
(flymake--schedule-timer-maybe): New helper.
(flymake-after-change-function): Use it.
(flymake-on-timer-event): Delete
(flymake-mode): Don't scheduler timer.
---
lisp/progmodes/flymake.el | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 88a305a..1068b38 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -101,7 +101,8 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
:type 'boolean)
(defcustom flymake-no-changes-timeout 0.5
- "Time to wait after last change before starting compilation."
+ "Time to wait after last change before automatically checking buffer.
+If nil, never start checking buffer automatically like this."
:type 'number)
(defcustom flymake-gui-warnings-enabled t
@@ -147,9 +148,6 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
(defvar-local flymake-timer nil
"Timer for starting syntax check.")
-(defvar-local flymake-last-change-time nil
- "Time of last buffer change.")
-
(defvar-local flymake-check-start-time nil
"Time at which syntax check was started.")
@@ -491,19 +489,6 @@ associated `flymake-category' return DEFAULT."
(overlay-put ov 'flymake t)
(overlay-put ov 'flymake--diagnostic diagnostic)))
-(defun flymake-on-timer-event (buffer)
- "Start a syntax check for buffer BUFFER if necessary."
- (when (buffer-live-p buffer)
- (with-current-buffer buffer
- (when (and (not (flymake-is-running))
- flymake-last-change-time
- (> (- (float-time) flymake-last-change-time)
- flymake-no-changes-timeout))
-
- (setq flymake-last-change-time nil)
- (flymake-log :debug "starting syntax check after no changes for some
time")
- (flymake-start)))))
-
;; Nothing in flymake uses this at all any more, so this is just for
;; third-party compatibility.
(define-obsolete-function-alias 'flymake-display-warning 'message-box "26.1")
@@ -651,8 +636,6 @@ backends."
(add-hook 'after-save-hook 'flymake-after-save-hook nil t)
(add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
- (setq flymake-timer
- (run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
(setq flymake--diagnostics-table (make-hash-table))
(when flymake-start-syntax-check-on-find-file
@@ -671,6 +654,28 @@ backends."
(cancel-timer flymake-timer)
(setq flymake-timer nil)))))
+(defun flymake--schedule-timer-maybe ()
+ "(Re)schedule an idle timer for checking the buffer.
+Do it only if `flymake-no-changes-timeout' is non-nil."
+ (when flymake-timer (cancel-timer flymake-timer))
+ (when flymake-no-changes-timeout
+ (setq
+ flymake-timer
+ (run-with-idle-timer
+ (seconds-to-time flymake-no-changes-timeout)
+ nil
+ (lambda (buffer)
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (when (and flymake-mode
+ flymake-no-changes-timeout)
+ (flymake-log
+ :debug "starting syntax check after idle for %s seconds"
+ flymake-no-changes-timeout)
+ (flymake-start))
+ (setq flymake-timer nil))))
+ (current-buffer)))))
+
;;;###autoload
(defun flymake-mode-on ()
"Turn flymake mode on."
@@ -690,7 +695,7 @@ backends."
(when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
(flymake-log :debug "starting syntax check as new-line has been seen")
(flymake-start 'deferred))
- (setq flymake-last-change-time (float-time))))
+ (flymake--schedule-timer-maybe)))
(defun flymake-after-save-hook ()
(when flymake-mode
- [Emacs-diffs] emacs-26 6954270 03/39: Completely rewrite Flymake's subprocess output processing, (continued)
- [Emacs-diffs] emacs-26 6954270 03/39: Completely rewrite Flymake's subprocess output processing, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 f930963 18/39: Simplify Flymake logging and erroring, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 734aa88 09/39: Flymake's flymake-proc.el parses column numbers from gcc/javac errors, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 9f8ad13 07/39: Refactor Flymake tests in preparation for more tests, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 491cc4a 13/39: Flymake checks file names before considering diagnostics, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 7787988 10/39: Flymake warning face easier to distinguish, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 5ec7d73 19/39: Flymake's flymake-proc.el backend slightly easier to debug, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 9a629a7 23/39: Add interactive flymake-start function, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 b0bb181 15/39: Protect Flymake's eager checks against commands like fill-paragraph, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 b2f8b8b 16/39: More Flymake cleanup before advancing to backend redesign, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 22a7372 31/39: Flymake uses proper idle timers,
João Távora <=
- [Emacs-diffs] emacs-26 87993cd 28/39: Explicitly add a(n empty) keymap for Flymake, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 bb8b663 04/39: Move symbols in flymake-proc.el to separate namespace, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 483f1e8 22/39: A couple of Flymake backends for emacs-lisp-mode, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 5235eaf 25/39: Treat Flymake errors as just another type of diagnostic, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 8118f0f 24/39: Fix three Flymake bugs when checking C header files, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 e0df7b9 21/39: Fancy Flymake mode-line construct displays status, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 cd39edb 26/39: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 2e84179 34/39: Tweak Flymake autoloads and dependencies, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 7360178 20/39: Tweak Flymake commands flymake-goto-[next/prev]-error, João Távora, 2017/10/03
- [Emacs-diffs] emacs-26 1b271ad 27/39: Flymake uses some new fringe bitmaps, João Távora, 2017/10/03