From: Tom Tromey <tromey@redhat.com>
To: Michael Olson <mwolson@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: RFC: status icon support
Date: Sun, 13 Jan 2008 18:01:40 -0700 [thread overview]
Message-ID: <m3k5mdi5jf.fsf@fleche.redhat.com> (raw)
In-Reply-To: <87lk6t2p7b.fsf@grepfind.mwolson.org> (Michael Olson's message of "Sun\, 13 Jan 2008 20\:03\:36 -0500")
>>>>> "Michael" == Michael Olson <mwolson@gnu.org> writes:
Michael> [ ... excellent bug report ]
Michael> I suspect a race condition.
Yes, I think you are right. I am not sure but maybe the answer is to
call gtk_main_iteration to flush the gtk event queue. I am testing
that. If that doesn't work, I guess I'll have to learn more about the
Emacs event stuff... scary. I may need help.
Michael> Once this issue is fixed, I'd love to see this feature hit
Michael> Emacs CVS. It will be particularly nice for ERC once your
Michael> erc-status.el is adapted to work with the new code.
I've appended my updated erc-status.el. I haven't tried it at all, I
just rewrote it to the new API.
Michael> ;; => "Couldn't connect to notification server"
Michael> ;; => libnotify-Message: Unable to get session bus: Failed to
Michael> ;; execute dbus-launch to autolaunch D-Bus session
Michael> ;; => Does not show "foo" popup
Are you running dbus? And do you have a system tray in your panel?
I'm not an expert here, either, but I would only expect these errors
if one of those answers is "no".
FWIW I do see the racy behavior you pointed out, but I don't see this
error. I'm running a rather standard Gnome desktop -- whatever is in
Fedora Core 6. My panel does have a system tray.
The notification stuff is cross-desktop, so it should also work if you
are a KDE user. I have not tested that with the Emacs-based code, but
I have tried out other system-tray-using Gnome applications on KDE.
Thanks for taking the time to try this out.
Tom
;;; erc-status.el --- notification area support for ERC
;; Copyright (C) 2007, 2008 Tom Tromey <tromey@redhat.com>
;; Author: Tom Tromey <tromey@redhat.com>
;; Version: 0.2
;; Keywords: comm
;; This file is not (yet) part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; This provides nice support for the notification area to ERC. In
;; particular it:
;; * Will blink the icon when you get a private message or are paged
;; in a channel.
;; * Left-click on the blinking icon will show the appropriate channel
;; buffer in some frame (which is then raised). If there are
;; multiple pages at once, it will show one and you can click again
;; to go to the next one.
;; * Will pop up notification bubbles when you connect to or
;; disconnect from a server.
;; This is regular erc module named 'status'; you can enable it as you
;; would any other module.
;; TO DO:
;; - make tool tip show some kind of real status ...?
;; - use a nicer icon
;; - add a menu
;; - integrate with auto-query a bit better
;; - let left click use specified frame or make a new frame?
;; - when last server connection is closed, remove icon
(require 'systray)
(require 'erc)
;; The status icon object.
(defvar erc-status-status-icon nil)
;; List of ERC buffers that caused the status icon to blink.
(defvar erc-status-buffer-list nil)
(defun erc-status-remove-buffer (buffer)
;; If the list is not empty, and removing an element makes the list
;; empty, stop blinking.
(and erc-status-buffer-list
(not (setq erc-status-buffer-list (delq buffer erc-status-buffer-list)))
(modify-status-icon erc-status-status-icon '((blinking . nil)))))
(defun erc-status-add-buffer (buffer)
(and (not (erc-buffer-visible buffer))
(progn
(modify-status-icon erc-status-status-icon '((blinking . t)))
(or (memq buffer erc-status-buffer-list)
(setq erc-status-buffer-list (cons buffer
erc-status-buffer-list))))))
(defun erc-status-match-hook (match-type nick message)
;; Look for user's nick and make the icon blink.
(if (eq match-type 'current-nick)
(erc-status-add-buffer (current-buffer))))
(defun erc-status-buffer-killed ()
;; If one of our buffers was killed, remove it.
(erc-status-remove-buffer (current-buffer)))
(defun erc-status-window-configuration-changed ()
(let ((new-list)
(iter erc-status-buffer-list))
(while iter
(or (erc-buffer-visible (car iter))
(setq new-list (cons (car iter) new-list)))
(setq iter (cdr iter)))
(or (setq erc-status-buffer-list new-list)
(modify-status-icon erc-status-status-icon '((blinking . nil))))))
(defun erc-status-disconnected (nick ip reason)
;; FIXME: should mention the server from which we were disconnected.
;; FIXME: add a :action to reconnect.
(show-status-icon-message erc-status-status-icon
(concat "Disconnected: " reason)))
(defun erc-status-after-connect (server nick)
(show-status-icon-message erc-status-status-icon
(concat "Connected to " server " as " nick)))
(defun erc-status-select-first-buffer ()
"Switch to the first ERC buffer requiring your attention.
If there is no such buffer, do nothing."
(when erc-status-buffer-list
(switch-to-buffer (car erc-status-buffer-list))
(raise-frame)))
\f
;; From: http://www.emacswiki.org/cgi-bin/wiki/ErcPageMe
;; Then modified to suit.
(defun erc-status-PRIVMSG (proc parsed)
(let* ((nick (car (erc-parse-user (erc-response.sender parsed))))
(target (car (erc-response.command-args parsed)))
(msg (erc-response.contents parsed))
(query (if (not erc-query-on-unjoined-chan-privmsg)
nick
(if (erc-current-nick-p target)
nick
target))))
(when (and (erc-current-nick-p target)
(not (erc-is-message-ctcp-and-not-action-p msg)))
;; Note: assumes you are using auto-query.
(erc-status-add-buffer (erc-get-buffer query proc))))
;; Always return nil.
nil)
\f
(define-erc-module status nil
"Notification area support for ERC."
;; Enable.
((unless erc-status-status-icon
(setq erc-status-status-icon
(make-status-icon '((help-echo . "ERC - IRC client for Emacs")
(click-callback . #'erc-status-select-first-buffer)))))
(add-hook 'erc-text-matched-hook 'erc-status-match-hook)
(add-hook 'kill-buffer-hook 'erc-status-buffer-killed)
(add-hook 'window-configuration-change-hook
'erc-status-window-configuration-changed)
(add-hook 'erc-after-connect 'erc-status-after-connect)
(add-hook 'erc-disconnected-hook 'erc-status-disconnected)
;; FIXME: Must come *after* erc-auto-query. Some sort of
;; auto-query hook or the like would be good here.
(add-hook 'erc-server-PRIVMSG-functions 'erc-status-PRIVMSG t))
;; Disable.
((when erc-status-status-icon
(delete-status-icon erc-status-status-icon)
(setq erc-status-status-icon nil))
(remove-hook 'erc-text-matched-hook 'erc-status-match-hook)
(remove-hook 'kill-buffer-hook 'erc-status-buffer-killed)
(remove-hook 'window-configuration-change-hook
'erc-status-window-configuration-changed)
(remove-hook 'erc-after-connect 'erc-status-after-connect)
(remove-hook 'erc-disconnected-hook 'erc-status-disconnected)
(remove-hook 'erc-server-PRIVMSG-functions 'erc-status-PRIVMSG)))
;;; erc-status.el ends here
next prev parent reply other threads:[~2008-01-14 1:01 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-11 23:28 RFC: status icon support Tom Tromey
2008-01-12 1:57 ` Dan Nicolaescu
2008-01-12 1:28 ` Tom Tromey
2008-01-12 1:38 ` Tom Tromey
2008-01-12 8:45 ` Ulrich Mueller
2008-01-12 17:45 ` Tom Tromey
2008-01-14 2:01 ` Richard Stallman
2008-01-14 1:35 ` Tom Tromey
2008-01-14 17:26 ` Richard Stallman
2008-01-19 5:18 ` Tom Tromey
2008-01-20 6:14 ` Richard Stallman
2008-01-23 4:00 ` Michael Olson
2008-01-14 1:41 ` Tom Tromey
2008-01-14 1:03 ` Michael Olson
2008-01-14 1:01 ` Tom Tromey [this message]
2008-01-14 7:03 ` Jan Djärv
2008-01-15 6:01 ` Michael Olson
2008-01-16 1:10 ` Tom Tromey
2008-01-16 4:10 ` Michael Olson
2008-01-12 11:11 ` Richard Stallman
2008-01-12 11:25 ` David Kastrup
2008-01-12 11:27 ` Andreas Schwab
2008-01-12 11:46 ` David Kastrup
2008-01-12 14:10 ` Andreas Schwab
2008-01-12 14:19 ` David Kastrup
2008-01-12 17:33 ` Andreas Schwab
2008-01-14 2:00 ` Richard Stallman
2008-01-14 2:25 ` Stefan Monnier
2008-01-14 7:05 ` Jan Djärv
2008-01-12 13:52 ` Dan Nicolaescu
2008-01-12 14:13 ` Andreas Schwab
2008-01-12 14:26 ` Dan Nicolaescu
2008-01-12 17:36 ` Andreas Schwab
2008-01-12 18:59 ` Dan Nicolaescu
2008-01-12 14:33 ` David Kastrup
2008-01-12 17:45 ` Andreas Schwab
2008-01-12 18:07 ` David Kastrup
2008-01-12 18:16 ` Andreas Schwab
2008-01-14 2:01 ` Richard Stallman
2008-01-14 2:47 ` Dan Nicolaescu
2008-01-14 17:26 ` Richard Stallman
2008-01-14 9:14 ` David Kastrup
2008-01-14 17:26 ` Richard Stallman
2008-01-14 3:47 ` YAMAMOTO Mitsuharu
2008-01-14 3:49 ` Tom Tromey
2008-01-14 13:35 ` Stefan Monnier
2008-01-14 21:40 ` YAMAMOTO Mitsuharu
2008-01-16 1:17 ` Tom Tromey
2008-01-16 11:55 ` YAMAMOTO Mitsuharu
2008-01-14 17:26 ` Richard Stallman
2008-01-14 17:10 ` Tom Tromey
2008-01-16 2:42 ` Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2007-12-30 19:56 Tom Tromey
2007-12-31 17:18 ` Dan Nicolaescu
2007-12-31 18:29 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3k5mdi5jf.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=emacs-devel@gnu.org \
--cc=mwolson@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.