Summary: I use it all the time
> == ErcManualAway ==
> If you want a quick toggle between some default away message and "back", you can use a function like this:
> (defun erc-global-away ()
> (let ((msg "coffee"))
> (if (member nil (erc-with-all-buffers-of-server nil
> ;; then: at least one is not away, set new away:
> (and (erc-cmd-GAWAY msg) (message "Set as away: %s" msg))
> ;; else: all servers are away, set back:
> (and (erc-cmd-GAWAY "") (message "Set as back" msg)))))
> (global-set-key (kbd "<pause>") #'erc-global-away)
Auto away is not enabled by default. To enable it use M-x customize-variable RET erc-modules.
ERC used to have a feature to set yourself back as soon as you send something to the server. This functionality has been moved to erc-autoaway.el.
Add the following to your .emacs to enable it:
(setq erc-auto-discard-away t)
You can configure the auto-away mechanism using the following two variables.
(setq erc-autoaway-idle-seconds 600)
tells erc-autoaway.el to set you away after 600 seconds (10 minutes) of idletime. The default is 1800 seconds (30 minutes).
contains a format string which will be used as an away reason. You can insert the number of seconds being idle using %i. The default is
"I'm gone (autoaway after %i seconds of idletime)"
To set yourself away after some idletime in ERC, add the following:
(setq erc-auto-set-away t)
To set yourself away after Emacs has been idle for some time, add the following:
(setq erc-autoaway-use-emacs-idle t)
This is only buggy at the moment, since the emacs idle timer gets reset from time to time and I have no idea why.
The following will print meep in the minibuffer each time the idletimer gets reset. It seems to happen sometimes when stuff arrives through a process with a process filter attached. If you find out more, please write me an email! mailto:firstname.lastname@example.org
(setq fc-idle-timer nil) (defun fc-idle-test () (interactive) (when fc-idle-timer (cancel-timer fc-idle-timer)) (setq fc-idle-num 0) (setq fc-idle-timer (run-with-idle-timer 1 t 'fc-idle-meep))) (defun fc-idle-meep () (message "meep %i." fc-idle-num) (setq fc-idle-num (+ fc-idle-num 1)))
The following function is uses the external xprintidle program to get the xorg idle time (same method as used by xscreensaver) and set away status in Bitlbee based on that. This emulates the functionality of most traditional IM clients and could be modified to work for other IRC servers and channels.
I have not been able to think of a way to do this without a polling loop, so any suggestions and improvements are welcome.
(defvar am-here-p t) (setq timeout 300) (setq erc-away-status "I am away.")
(defun custom-auto-set-away () "Set away message to erc-away-status and clear it if already away." (interactive) (if (> (/ (string-to-number (shell-command-to-string "/usr/bin/xprintidle")) 1000.0) timeout) (when am-here-p (message "Going Away") (set-buffer "&bitlbee") (setq am-here-p nil) (erc-cmd-AWAY erc-away-status)) (unless am-here-p (set-buffer "&bitlbee") (setq am-here-p t) (erc-cmd-AWAY ""))))
(run-at-time t 60 'custom-auto-set-away)
am-here-p is kept track of so as to not spam the channel/server with status updates.
If you want a quick toggle between some default away message and “back”, you can use a function like this:
(defun erc-global-away () (interactive) (let ((msg "coffee")) (if (member nil (erc-with-all-buffers-of-server nil #'erc-open-server-buffer-p (erc-away-time))) ;; then: at least one is not away, set new away: (and (erc-cmd-GAWAY msg) (message "Set as away: %s" msg)) ;; else: all servers are away, set back: (and (erc-cmd-GAWAY "") (message "Set as back" msg))))) (global-set-key (kbd "<pause>") #'erc-global-away)