From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add notifications.el Date: Wed, 9 Jun 2010 21:16:45 +0200 Message-ID: <201006092116.46374.tassilo@member.fsf.org> References: <1275757657-15244-1-git-send-email-julien@danjou.info> <201006092018.10163.tassilo@member.fsf.org> <87ocfkkpgg.fsf@keller.adm.naquadah.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1276111651 14051 80.91.229.12 (9 Jun 2010 19:27:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Jun 2010 19:27:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: Julien Danjou Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 09 21:27:29 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OMQvx-00089S-5r for ged-emacs-devel@m.gmane.org; Wed, 09 Jun 2010 21:27:29 +0200 Original-Received: from localhost ([127.0.0.1]:42797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMQlo-0007rY-H8 for ged-emacs-devel@m.gmane.org; Wed, 09 Jun 2010 15:17:00 -0400 Original-Received: from [140.186.70.92] (port=58081 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMQlf-0007p8-Nc for emacs-devel@gnu.org; Wed, 09 Jun 2010 15:16:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMQle-00024B-5B for emacs-devel@gnu.org; Wed, 09 Jun 2010 15:16:51 -0400 Original-Received: from out5.smtp.messagingengine.com ([66.111.4.29]:37963) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMQle-000245-3S for emacs-devel@gnu.org; Wed, 09 Jun 2010 15:16:50 -0400 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id A490CF806A; Wed, 9 Jun 2010 15:16:49 -0400 (EDT) Original-Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 09 Jun 2010 15:16:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=from:to:subject:date:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:message-id; s=smtpout; bh=MzGuqzFyRln7pjuB3g9+VSD53qM=; b=UqXU8NnzRt0HhChr2lCoiIZtbsLzQk7FdKMkoNlW5pvvNPon8q0RhMh9TzuyqNxQCfXbaYvEBjzoDCoqxZy7EcsOjsIU6JRH5AduxnZRc1iWXQWXY14lJ3NnTUp2SOxc+KSktUJPqzjgiWjNrl5U4hOzoFXrU8CzNAozfqaQ+vQ= X-Sasl-enc: U+qZ1DdR1T0hQ0BZ2qPDsxtaYI0ZJDkhxu0AmF9niSLq 1276111009 Original-Received: from thinkpad.localnet (p54AF1921.dip0.t-ipconnect.de [84.175.25.33]) by mail.messagingengine.com (Postfix) with ESMTPSA id 350AF4DD102; Wed, 9 Jun 2010 15:16:49 -0400 (EDT) User-Agent: KMail/1.13.3 (Linux/2.6.34-gentoo; KDE/4.4.4; x86_64; ; ) In-Reply-To: <87ocfkkpgg.fsf@keller.adm.naquadah.org> X-Face: `TY6r/ws=N5uqO1E`M=Sups<}n%T[E^o_?MJj List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125681 Archived-At: Hi! > > How do I get the id of the closed notification? Wouldn't it be > > better to pass the id to that function, too? > > It'd be possible sure, but I did not think it was worth it nor it > would have a use case. You can passe a lambda/closure to :on-close, > can't you? Not really, cause the ID I need is the return value of the `notifications-notify', so I cannot use it as parameter to that function. And elisp doesn't have closures anyway. > If you have an problematic example maybe we can figure out. Here's my code: --8<---------------cut here---------------start------------->8--- (defvar th-notify-body-to-id-map (make-hash-table :test 'string=) "Maps BODY values of notifications to the last notification ID. If ID is -1, then any further notifications with that body will be skipped.") (defun th-notify (&rest args) "Create a notification popup. For ARGS, see `notifications-notify'. If there was a notification with the same BODY before, that one will be replaced by the current notification." (require 'notifications) (let* ((body (plist-get args :body)) (replace-id (or (gethash body th-notify-body-to-id-map) (plist-get args :replaces-id)))) (unless (eql replace-id -1) (puthash body (apply 'notifications-notify (plist-put (plist-put args :replaces-id replace-id) :timeout 0)) th-notify-body-to-id-map)))) --8<---------------cut here---------------end--------------->8--- So what I want, is that if I delete a notification, there should be a mapping from :body value to -1 in th-notify-body-to-id-map, so that no new notifications are performed for that entry. Bye, Tassilo