From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mario Lang Newsgroups: gmane.emacs.devel Subject: dbus.el: defvar dbus-event for signal handlers? Date: Sun, 09 Aug 2009 15:46:42 +0200 Message-ID: <87tz0hp0al.fsf@x2.delysid.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1249825660 29748 80.91.229.12 (9 Aug 2009 13:47:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Aug 2009 13:47:40 +0000 (UTC) Cc: Michael Albinus To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 09 15:47:33 2009 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.50) id 1Ma8kG-0000iS-Fa for ged-emacs-devel@m.gmane.org; Sun, 09 Aug 2009 15:47:32 +0200 Original-Received: from localhost ([127.0.0.1]:42565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ma8kF-0003Ql-PB for ged-emacs-devel@m.gmane.org; Sun, 09 Aug 2009 09:47:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ma8kA-0003Q7-Vu for emacs-devel@gnu.org; Sun, 09 Aug 2009 09:47:27 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ma8k6-0003MM-2d for emacs-devel@gnu.org; Sun, 09 Aug 2009 09:47:26 -0400 Original-Received: from [199.232.76.173] (port=39784 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ma8k5-0003M0-U5 for emacs-devel@gnu.org; Sun, 09 Aug 2009 09:47:21 -0400 Original-Received: from viefep20-int.chello.at ([62.179.121.40]:53258) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ma8k4-0005FJ-Bb for emacs-devel@gnu.org; Sun, 09 Aug 2009 09:47:20 -0400 Original-Received: from edge04.upc.biz ([192.168.13.239]) by viefep20-int.chello.at (InterMail vM.7.09.01.00 201-2219-108-20080618) with ESMTP id <20090809134712.VFVJ9018.viefep20-int.chello.at@edge04.upc.biz>; Sun, 9 Aug 2009 15:47:12 +0200 Original-Received: from x2.delysid.org ([84.115.136.207]) by edge04.upc.biz with edge id SDnA1c04j4UfZvY04DnBzr; Sun, 09 Aug 2009 15:47:12 +0200 X-SourceIP: 84.115.136.207 Original-Received: from mlang by x2.delysid.org with local (Exim 4.69) (envelope-from ) id 1Ma8jh-0001Xx-OH; Sun, 09 Aug 2009 15:46:57 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." 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:113850 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi. First of all, thanks for dbus.el. I am writing atspi.el which is heavily based on dbus.el. I noticed a rough bit in the API which I'd like to discuss to see what your opinions are. `dbus-register-signal' allows for SERVICE and PATH to be nil, which is something I need for a group of signals I need to handle. However, to be able to run `dbus-event-service-name' and `dbus-event-path-name' to figure out what SERVICE and PATH actually are during handler execution I somehow need to get to the actual event object when my signal handler is ru= n. Given how elisp works, there is a way to access the event object by just using EVENT, for example: (defun handler () (message "Event on service %s path %s" (dbus-event-service-name event) (dbus-event-path-name event))) which of course looks odd and at least upsets elint: ** function atspi-tree-remove-accessible-handler ** Reference to unbound symbol: event Now I guess one solution is something like the following patch: =2D-- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -349,11 +349,15 @@ not well formed." (functionp (nth 8 event))) (signal 'dbus-error (list "Not a valid D-Bus event" event)))) =20 +(defvar dbus-event nil + "Set by `dbus-handle-event' during handler execution.") + ;;;###autoload (defun dbus-handle-event (event) "Handle events from the D-Bus. EVENT is a D-Bus event, see `dbus-check-event'. HANDLER, being part of the event, is called with arguments ARGS. +During executing of HANDLER, EVENT is bound to `dbus-event'. If the HANDLER returns an `dbus-error', it is propagated as return message= ." (interactive "e") (condition-case err @@ -364,7 +368,8 @@ If the HANDLER returns an `dbus-error', it is propagate= d as return message." (when (=3D dbus-message-type-error (nth 2 event)) (signal 'dbus-error (nthcdr 9 event))) ;; Apply the handler. =2D (setq result (apply (nth 8 event) (nthcdr 9 event))) + (let ((dbus-event event)) + (setq result (apply (nth 8 event) (nthcdr 9 event)))) ;; Return a message when it is a message call. (when (=3D dbus-message-type-method-call (nth 2 event)) (dbus-ignore-errors Which would mean the above example shoudl be rewritten as: (defun handler () (message "Event on service %s path %s" (dbus-event-service-name dbus-even= t) (dbus-event-path-name dbus-event))) Another solution would be to pass EVENT as the first argument to HANDLER, but this would need changing of all existing handler functions, which is probably no good idea at all. Any thoughts? =2D-=20 Thanks, =E2=A1=8D=E2=A0=81=E2=A0=97=E2=A0=8A=E2=A0=95 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iD8DBQFKftND3/wCKmsRPkQRAjkBAJ4iS3VfAktjPxRnFdkXx11lLd4sUwCcCob8 YAFPNJ4jmte8Ycy2Uh2/FCk= =MF6M -----END PGP SIGNATURE----- --=-=-=--