Fix the auto-away timeouts properly this time.
authorSteve Youngs <steve@emchat.org>
Thu, 22 Aug 2013 14:38:26 +0000 (00:38 +1000)
committerSteve Youngs <steve@emchat.org>
Thu, 22 Aug 2013 14:38:26 +0000 (00:38 +1000)
* emchat.el (emchat-auto-away-timeout-set): The args aren't
optional.  Actually set `emchat-auto-away-timeout'.

* emchat.el (emchat-change-idle-timeout): Call
#'emchat-auto-away-timeout-set correctly with 2 args.

Signed-off-by: Steve Youngs <steve@emchat.org>
emchat.el

index 06352d3..89df916 100644 (file)
--- a/emchat.el
+++ b/emchat.el
@@ -1807,7 +1807,7 @@ Need to relogin afterwards."
        nil
      password)))
 
-(defun emchat-auto-away-timeout-set (&optional symbol value)
+(defun emchat-auto-away-timeout-set (symbol value)
   "Set timer for auto-away.  See `emchat-auto-away-timeout'."
   ;; delete the previous itimers
   (when (itimerp (get-itimer "emchat auto-away"))
@@ -1815,28 +1815,25 @@ Need to relogin afterwards."
   (when (itimerp (get-itimer "emchat auto-na"))
     (delete-itimer (get-itimer "emchat auto-na")))
   (unless (zerop value)
-    (start-itimer
-     "emchat auto-away"
-     (lambda ()
-       ;; auto away for first idle
-       (when (member emchat-user-status '("online" "ffc"))
-        (emchat-log-system "Auto away.")
-        (emchat-change-status "away")
-        (setq emchat-user-auto-away-p t)))
-     value value
-     'is-idle)
-    (start-itimer
-     "emchat auto-na"
-     (lambda ()
-       ;; auto na for second idle
-       (when (and emchat-user-auto-away-p
-                 (equal emchat-user-status "away"))
-        (emchat-log-system "Auto na.")
-        (emchat-change-status "na")
-        ;; emchat-change-status resets this flag
-        (setq emchat-user-auto-away-p t)))
-     (* 2 value) (* 2 value)
-     nil)))
+    (start-itimer "emchat auto-away"
+                 #'(lambda ()
+                     ;; auto away for first idle
+                     (when (member emchat-user-status '("online" "ffc"))
+                       (emchat-log-system "Auto away.")
+                       (emchat-change-status "away")
+                       (setq emchat-user-auto-away-p t)))
+                 value value 'idle)
+    (start-itimer "emchat auto-na"
+                 #'(lambda ()
+                     ;; auto na for second idle
+                     (when (and emchat-user-auto-away-p
+                                (equal emchat-user-status "away"))
+                       (emchat-log-system "Auto na.")
+                       (emchat-change-status "na")
+                       ;; emchat-change-status resets this flag
+                       (setq emchat-user-auto-away-p t)))
+                 (* 2 value) (* 2 value)))
+  (set (intern (symbol-name symbol)) value))
 
 (defcustom emchat-auto-away-timeout 300
   "*Seconds of inactivity in Emacs before auto-away.
@@ -1847,7 +1844,7 @@ See `emchat-auto-away'.
 Setting this to zero disables the timeout.
 
 If you set this outside of the custom buffer you _MUST_ use
-`customize-set-value' and _NOT_ `setq'."
+`customize-set-variable' and _NOT_ `setq'."
   :type 'number
   :set 'emchat-auto-away-timeout-set
   :initialize 'custom-initialize-default
@@ -1864,7 +1861,7 @@ To do that, customise the variable, `emchat-auto-away-timeout'."
   (interactive
    (list (read-number "Idle timeout in seconds (0 to disable): "
                      nil (number-to-string emchat-auto-away-timeout))))
-  (emchat-auto-away-timeout-set nil seconds)
+  (emchat-auto-away-timeout-set 'emchat-auto-away-timeout seconds)
   (if (zerop seconds)
       (emchat-log-system "Auto-away disabled.")
     (emchat-log-system "Auto-away timeout set to: %d seconds." seconds)))
@@ -2529,7 +2526,8 @@ See `emchat-buddy-select-all-in-view'."
 (byte-compile 'emchat-pack-contact-list)
 
 ;; Start the idle timer
-(emchat-auto-away-timeout-set nil emchat-auto-away-timeout)
+(emchat-auto-away-timeout-set
+ 'emchat-auto-away-timeout emchat-auto-away-timeout)
 ;; Install bindings
 (emchat-install-bindings 'emchat-prefix-key emchat-prefix-key)
 ;; Add our button to the default toolbar