emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 153/352: Siirretään ajastimen käynnistys ja sammutus omiin funkt


From: Stefan Monnier
Subject: [elpa] 153/352: Siirretään ajastimen käynnistys ja sammutus omiin funktioihinsa
Date: Mon, 07 Jul 2014 14:03:26 +0000

monnier pushed a commit to branch master
in repository elpa.

commit a5a30ebd843e624f02472cfbb94c64c230391e42
Author: Teemu Likonen <address@hidden>
Date:   Fri Mar 12 08:28:45 2010 +0000

    Siirretään ajastimen käynnistys ja sammutus omiin funktioihinsa
---
 wcheck-mode.el |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/wcheck-mode.el b/wcheck-mode.el
index cca70a9..1642b47 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -470,13 +470,9 @@ or skip in a buffer."
         ;; Add this buffer to buffer database.
         (wcheck-update-buffer-data (current-buffer) wcheck-language)
 
-        ;; Start idle timer if it's not already started. The timer runs
-        ;; a function which updates buffers which have requested for
-        ;; that.
-        (unless wcheck-timer
-          (setq wcheck-timer
-                (run-with-idle-timer wcheck-timer-idle t
-                                     #'wcheck-timer-read-event)))
+        ;; Ensure that the idle timer is running. The timer runs a
+        ;; function which updates buffers which have requested for that.
+        (wcheck-timer-start)
 
         ;; Request update for this buffer.
         (wcheck-timer-add-read-request (current-buffer))))
@@ -492,10 +488,8 @@ or skip in a buffer."
     ;; If there are no buffers using wcheck-mode anymore, stop the idle
     ;; timer and remove global hooks.
     (when (null (wcheck-get-all-data :buffer))
-      (wcheck-remove-global-hooks)
-      (when wcheck-timer
-        (cancel-timer wcheck-timer)
-        (setq wcheck-timer nil)))
+      (wcheck-timer-stop)
+      (wcheck-remove-global-hooks))
 
     ;; Remove buffer-local hooks.
     (wcheck-remove-local-hooks (current-buffer))))
@@ -505,6 +499,21 @@ or skip in a buffer."
 ;;; Timers
 
 
+(defun wcheck-timer-start ()
+  "Start `wcheck-mode' idle timer if it's not running already."
+  (unless wcheck-timer
+    (setq wcheck-timer
+          (run-with-idle-timer wcheck-timer-idle t
+                               #'wcheck-timer-read-event))))
+
+
+(defun wcheck-timer-stop ()
+  "Stop `wcheck-mode' idle timer."
+  (when wcheck-timer
+    (cancel-timer wcheck-timer)
+    (setq wcheck-timer nil)))
+
+
 (defun wcheck-timer-add-read-request (buffer)
   (add-to-list 'wcheck-timer-read-requested buffer))
 (defun wcheck-timer-remove-read-request (buffer)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]