* read-event and unexpected buffer changes
@ 2013-04-28 20:41 Julien Danjou
2013-05-23 17:31 ` Stefan Monnier
2013-05-27 11:59 ` read-event and unexpected buffer changes Michael Albinus
0 siblings, 2 replies; 9+ messages in thread
From: Julien Danjou @ 2013-04-28 20:41 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]
Hi there,
I'm having a nasty bug and just spent an hour tracking it down.
I'm using `erc-desktop-notifications' to get IRC messages sent with my
nickname over D-Bus using `notifications-notify'. This function calls
`dbus-call-method' which contains the following snippet at the end:
(with-timeout ((if timeout (/ timeout 1000.0) 25))
(while (eq (gethash key dbus-return-values-table :ignore) :ignore)
(let ((event (let (unread-command-events) (read-event nil nil 0.1))))
(when (and event (not (ignore-errors (dbus-check-event event))))
(setq unread-command-events
(append unread-command-events (list event)))))))
This `read-event' call causes me trouble. Basically what happens, is
that it changes the ERC buffer in a very subtle way so that the last
line is then on top. Basically, the buffer is supposed to be shown as:
/-----
| <jd> ohla
| <foo> hey
| <foo> how are you jd?
| [#bar]
\-----
But because of this `read-event' call, the buffer is "recentered to the
top" and I finally see this instead:
/-----
| <foo> how are you jd?
| [#bar]
|
|
\-----
Which is utterly inconvenient. I've tried adding `save-excursion' around
(read-event), but that doesn't change anything. I wonder what this
function can do that changes the buffer, and in any way, that doesn't
look like an expected and right side effect.
Hint?
--
Julien Danjou
# Free Software hacker # freelance consultant
# http://julien.danjou.info
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: read-event and unexpected buffer changes
2013-04-28 20:41 read-event and unexpected buffer changes Julien Danjou
@ 2013-05-23 17:31 ` Stefan Monnier
2013-05-24 12:22 ` Michael Albinus
2013-05-27 11:59 ` read-event and unexpected buffer changes Michael Albinus
1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2013-05-23 17:31 UTC (permalink / raw)
To: emacs-devel
> (let ((event (let (unread-command-events) (read-event nil nil 0.1))))
> (when (and event (not (ignore-errors (dbus-check-event event))))
> (setq unread-command-events
> (append unread-command-events (list event)))))))
Why not use sit-for?
> But because of this `read-event' call, the buffer is "recentered to the
> top" and I finally see this instead:
The only expected side-effect is a redisplay (which could also trigger
things like jit-lock).
> Hint?
Sorry,
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: read-event and unexpected buffer changes
2013-04-28 20:41 read-event and unexpected buffer changes Julien Danjou
2013-05-23 17:31 ` Stefan Monnier
@ 2013-05-27 11:59 ` Michael Albinus
2013-05-27 12:28 ` Julien Danjou
1 sibling, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2013-05-27 11:59 UTC (permalink / raw)
To: emacs-devel
Julien Danjou <julien@danjou.info> writes:
> Hi there,
Hi,
> I'm using `erc-desktop-notifications' to get IRC messages sent with my
> nickname over D-Bus using `notifications-notify'. This function calls
> `dbus-call-method' which contains the following snippet at the end:
>
> (with-timeout ((if timeout (/ timeout 1000.0) 25))
> (while (eq (gethash key dbus-return-values-table :ignore) :ignore)
> (let ((event (let (unread-command-events) (read-event nil nil 0.1))))
> (when (and event (not (ignore-errors (dbus-check-event event))))
> (setq unread-command-events
> (append unread-command-events (list event)))))))
>
> This `read-event' call causes me trouble. Basically what happens, is
> that it changes the ERC buffer in a very subtle way so that the last
> line is then on top.
>
> Hint?
Does the following patch suffices?
--8<---------------cut here---------------start------------->8---
*** /home/albinmic/src/emacs/lisp/net/dbus.el.~112739~ 2013-05-27 13:51:51.844960427 +0200
--- /home/albinmic/src/emacs/lisp/net/dbus.el 2013-05-27
13:51:33.992671583 +0200
***************
*** 270,276 ****
;; default 25". Events which are not from D-Bus must be restored.
(with-timeout ((if timeout (/ timeout 1000.0) 25))
(while (eq (gethash key dbus-return-values-table :ignore) :ignore)
! (let ((event (let (unread-command-events) (read-event nil nil 0.1))))
(when (and event (not (ignore-errors (dbus-check-event event))))
(setq unread-command-events
(append unread-command-events (list event)))))))
--- 270,277 ----
;; default 25". Events which are not from D-Bus must be restored.
(with-timeout ((if timeout (/ timeout 1000.0) 25))
(while (eq (gethash key dbus-return-values-table :ignore) :ignore)
! (let ((event (let ((inhibit-redisplay t) unread-command-events)
! (read-event nil nil 0.1))))
(when (and event (not (ignore-errors (dbus-check-event event))))
(setq unread-command-events
(append unread-command-events (list event)))))))
--8<---------------cut here---------------end--------------->8---
Best regards, Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: read-event and unexpected buffer changes
2013-05-27 11:59 ` read-event and unexpected buffer changes Michael Albinus
@ 2013-05-27 12:28 ` Julien Danjou
2013-05-27 12:42 ` Michael Albinus
0 siblings, 1 reply; 9+ messages in thread
From: Julien Danjou @ 2013-05-27 12:28 UTC (permalink / raw)
To: Michael Albinus; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 269 bytes --]
On Mon, May 27 2013, Michael Albinus wrote:
Hi Michael,
> Does the following patch suffices?
Yes indeed, it fixes the problem as far as I can tell!
Thanks!
--
Julien Danjou
// Free Software hacker / freelance consultant
// http://julien.danjou.info
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: read-event and unexpected buffer changes
2013-05-27 12:28 ` Julien Danjou
@ 2013-05-27 12:42 ` Michael Albinus
0 siblings, 0 replies; 9+ messages in thread
From: Michael Albinus @ 2013-05-27 12:42 UTC (permalink / raw)
To: emacs-devel
Julien Danjou <julien@danjou.info> writes:
> Hi Michael,
Hi Julien,
>> Does the following patch suffices?
>
> Yes indeed, it fixes the problem as far as I can tell!
Thanks for confirmation. I don't use erc myself, so I couldn't check.
The patch is committed to the trunk. I'll continue to investigate
Stefan's proposal about changed D-Bus event handling.
> Thanks!
Best regards, Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-05-27 12:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-28 20:41 read-event and unexpected buffer changes Julien Danjou
2013-05-23 17:31 ` Stefan Monnier
2013-05-24 12:22 ` Michael Albinus
2013-05-24 15:48 ` DBus events processing (was: read-event and unexpected buffer changes) Stefan Monnier
2013-05-24 22:08 ` DBus events processing Michael Albinus
2013-05-25 1:54 ` Stefan Monnier
2013-05-27 11:59 ` read-event and unexpected buffer changes Michael Albinus
2013-05-27 12:28 ` Julien Danjou
2013-05-27 12:42 ` Michael Albinus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).