[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-commit] [commit][emacs22] erc-autoaway: Add user idle method and re
From: |
mwolson |
Subject: |
[Erc-commit] [commit][emacs22] erc-autoaway: Add user idle method and re-organize. |
Date: |
Sun, 14 Oct 2007 00:48:14 -0400 |
commit 61b416429317b0384e6c552ff09ea01506018fa2
Author: Michael Olson <address@hidden>
Date: Sat Jun 3 18:25:39 2006 +0000
erc-autoaway: Add user idle method and re-organize.
* erc-autoaway.el: Thanks to Mark Plaksin for the ideas and patch.
(erc-autoaway-idle-method): Renamed from
`erc-autoaway-use-emacs-idle'. We have more than two choices for how to
do this, so it's best to make this take symbol values. Improve
documentation. Remove warning against Emacs idle-time; the point is
moot now that we get user idle time via a different method. Make sure
we disable and re-enable the module when changing this value.
(autoaway): Conditionalize on the above option. If using the idle timer
or user idle methods, don't add anything to the send-completed or
server-001 hooks, since it is unnecessary.
(erc-autoaway-reestablish-idletimer, erc-autoaway-message): Docfix.
(erc-autoaway-idle-seconds): Use erc-autoaway-idle-method.
(erc-autoaway-reset-idletime): Make the first argument optional so that
we can safely add this to post-command-hook.
git-archimport-id: address@hidden/erc--main--0--patch-4
diff --git a/CREDITS b/CREDITS
index 5172ffc..9e8e910 100644
--- a/CREDITS
+++ b/CREDITS
@@ -131,6 +131,9 @@ Aravind Gottipati <address@hidden>:
* Made /quote work with lines that don't have leading whitespace (1
line changed).
+Mark Plaksin (happy AT mcplaksin DOT org):
+ * Made a last-keystroke method for erc-autoaway.el.
+
----
P.S.: Many people contributed small bits to ERC whose names I probably
diff --git a/ChangeLog b/ChangeLog
index 1dcc503..c5af6a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2006-06-03 Michael Olson <address@hidden>
+ * erc-autoaway.el: Thanks to Mark Plaksin for the ideas and patch.
+ (erc-autoaway-idle-method): Renamed from
+ `erc-autoaway-use-emacs-idle'. We have more than two choices for
+ how to do this, so it's best to make this take symbol values.
+ Improve documentation. Remove warning against Emacs idle-time;
+ the point is moot now that we get user idle time via a different
+ method. Make sure we disable and re-enable the module when
+ changing this value.
+ (autoaway): Conditionalize on the above option. If using the idle
+ timer or user idle methods, don't add anything to the
+ send-completed or server-001 hooks, since it is unnecessary.
+ (erc-autoaway-reestablish-idletimer, erc-autoaway-message):
+ Docfix.
+ (erc-autoaway-idle-seconds): Use erc-autoaway-idle-method.
+ (erc-autoaway-reset-idletime): Make the first argument optional so
+ that we can safely add this to post-command-hook.
+
* Makefile (upload): Make this work for Savannah uploads.
* AUTHORS: Update for Savannah move. No old entries have been
diff --git a/erc-autoaway.el b/erc-autoaway.el
index 810f0b6..518005d 100644
--- a/erc-autoaway.el
+++ b/erc-autoaway.el
@@ -1,6 +1,6 @@
;;; erc-autoaway.el --- Provides autoaway for ERC
-;; Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
;; Author: Jorgen Schaefer <address@hidden>
;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcAutoAway
@@ -43,18 +43,24 @@ yourself back when you type something."
"The Emacs idletimer.
This is only used when `erc-autoaway-use-emacs-idle' is non-nil.")
-(defcustom erc-autoaway-use-emacs-idle nil
- "*If non-nil, the idle time refers to idletime in Emacs.
-If nil, the idle time refers to idletime on IRC only.
+(defcustom erc-autoaway-idle-method 'user
+ "*The method used to determine how long you have been idle.
+If 'user, the time of the last command sent to Emacs is used.
+If 'emacs, the idle time in Emacs is used.
+If 'irc, the time of the last IRC command is used.
+
The time itself is specified by `erc-autoaway-idle-seconds'.
-See `erc-autoaway-mode' for more information on the various
-definitions of being idle.
-Note that using Emacs idletime is currently broken for most versions,
-since process activity (as happens all the time on IRC) makes Emacs
-non-idle. Emacs idle-time and user idle-time are just not the same."
+See `erc-autoaway-mode' for more information on the various
+definitions of being idle."
:group 'erc-autoaway
- :type 'boolean)
+ :type '(choice (const :tag "User idle time" user)
+ (const :tag "Emacs idle time" emacs)
+ (const :tag "Last IRC action" irc))
+ :set (lambda (sym val)
+ (erc-autoaway-disable)
+ (set-default sym val)
+ (erc-autoaway-enable)))
;;;###autoload (autoload 'erc-autoaway-mode "erc-autoaway")
(define-erc-module autoaway nil
@@ -64,35 +70,40 @@ the number of seconds specified in
`erc-autoaway-idle-seconds'.
There are several kinds of being idle:
-IRC idle time measures how long since you last sent something (see
-`erc-autoaway-last-sent-time'). This is the default.
+User idle time measures how long you have not been sending any
+commands to Emacs. This is the default.
Emacs idle time measures how long Emacs has been idle. This is
currently not useful, since Emacs is non-idle when it handles
-ping-pong with IRC servers. See `erc-autoaway-use-emacs-idle' for
-more information.
+ping-pong with IRC servers. See `erc-autoaway-idle-method'
+for more information.
-User idle time measures how long you have not been sending any
-commands to Emacs, or to your system. Emacs currently provides no way
-to measure user idle time.
+IRC idle time measures how long since you last sent something (see
+`erc-autoaway-last-sent-time').
If `erc-auto-discard-away' is set, then typing anything, will
set you no longer away.
Related variables: `erc-public-away-p' and `erc-away-nickname'."
;; Enable:
- ((add-hook 'erc-send-completed-hook 'erc-autoaway-reset-idletime)
- (add-hook 'erc-server-001-functions 'erc-autoaway-reset-idletime)
- (add-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away)
- (when erc-autoaway-use-emacs-idle
- (erc-autoaway-reestablish-idletimer)))
+ ((cond ((eq erc-autoaway-idle-method 'irc)
+ (add-hook 'erc-send-completed-hook 'erc-autoaway-reset-idletime)
+ (add-hook 'erc-server-001-functions 'erc-autoaway-reset-idletime))
+ ((eq erc-autoaway-idle-method 'user)
+ (add-hook 'post-command-hook 'erc-autoaway-reset-idletime))
+ ((eq erc-autoaway-idle-method 'emacs)
+ (erc-autoaway-reestablish-idletimer)))
+ (add-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away))
;; Disable:
- ((remove-hook 'erc-send-completed-hook 'erc-autoaway-reset-idletime)
- (remove-hook 'erc-server-001-functions 'erc-autoaway-reset-idletime)
- (remove-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away)
- (when erc-autoaway-idletimer
- (erc-cancel-timer erc-autoaway-idletimer)
- (setq erc-autoaway-idletimer nil))))
+ ((cond ((eq erc-autoaway-idle-method 'irc)
+ (remove-hook 'erc-send-completed-hook 'erc-autoaway-reset-idletime)
+ (remove-hook 'erc-server-001-functions 'erc-autoaway-reset-idletime))
+ ((eq erc-autoaway-idle-method 'user)
+ (remove-hook 'post-command-hook 'erc-autoaway-reset-idletime))
+ ((eq erc-autoaway-idle-method 'emacs)
+ (erc-cancel-timer erc-autoaway-idletimer)
+ (setq erc-autoaway-idletimer nil)))
+ (remove-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away)))
(defcustom erc-auto-set-away t
"*If non-nil, set away after `erc-autoaway-idle-seconds' seconds of idling.
@@ -123,8 +134,8 @@ See `erc-auto-discard-away'."
(defun erc-autoaway-reestablish-idletimer ()
"Reestablish the emacs idletimer.
-You have to call this function each time you change
-`erc-autoaway-idle-seconds', if `erc-autoaway-use-emacs-idle' is set."
+If `erc-autoaway-idle-method' is 'emacs, you must call this
+function each time you change `erc-autoaway-idle-seconds'."
(interactive)
(when erc-autoaway-idletimer
(erc-cancel-timer erc-autoaway-idletimer))
@@ -141,22 +152,22 @@ you have to run `erc-autoaway-reestablish-idletimer'
afterwards."
:group 'erc-autoaway
:set (lambda (sym val)
(set-default sym val)
- (when erc-autoaway-use-emacs-idle
+ (when (eq erc-autoaway-idle-method 'emacs)
(erc-autoaway-reestablish-idletimer)))
:type 'number)
(defcustom erc-autoaway-message
"I'm gone (autoaway after %i seconds of idletime)"
- "*Message ERC will use when he sets you automatically away.
-It is used as a `format' string with the argument of the idletime in
-seconds."
+ "*Message ERC will use when setting you automatically away.
+It is used as a `format' string with the argument of the idletime
+in seconds."
:group 'erc-autoaway
:type 'string)
(defvar erc-autoaway-last-sent-time (erc-current-time)
"The last time the user sent something.")
-(defun erc-autoaway-reset-idletime (line &rest stuff)
+(defun erc-autoaway-reset-idletime (&optional line &rest stuff)
"Reset the stored idletime for the user.
This is one global variable since a user talking on one net can talk
on another net too."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-commit] [commit][emacs22] erc-autoaway: Add user idle method and re-organize.,
mwolson <=