emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

erc and notify-via-dbus breaks scroll position in channel buffers


From: Barry Warsaw
Subject: erc and notify-via-dbus breaks scroll position in channel buffers
Date: Thu, 13 Jun 2013 14:57:38 -0400

I recently upgraded to Emacs 24.3 from 24.2 in Ubuntu 13.10 and I noticed a
weird regression in erc.  When someone pinged my nick, the channel buffer
would scroll the current line to the top, so I'd have to manually recenter the
buffer to read the scrollback.

After a lengthy debugging session, I traced the problem down to
notify-via-dbus.  AFAICT, here's what's happening.

I add a hook to erc-text-matched-hook so that when my nick appears in a
channel, I get a notification in the on-screen display (osd).  This was
working beautifully in 24.2.  It calls (notify) which in turn calls whatever
notify-method is set too.  In 24.3 and 24.2 this is set by default to
notify-via-dbus.  e.g:

(defun baw-notify-erc (match-type nickuserhost message)
  "Notify when a message to my nick is received"
  (notify (format "%s in %s"
                  ;; Username of sender
                  (car (split-string nickuserhost "!"))
                  ;; Channel
                  (or (erc-default-target) "#unknown"))
          ;; Remove duplicate spaces.
          (replace-regexp-in-string " +" " " message)
          :icon "emacs-snapshot"
          :timeout -1))
(add-hook 'erc-text-matched-hook 'baw-notify-erc t)

The problem is that it seems like something in notify-via-dbus is causing a
non-local exit, such that the (save-excursion (save-restriction ...)) in
erc-match-message is not able to restore the buffer's scroll position.  This
obviously worked fine in 24.2, and when I switch notify-method to
notify-via-libnotify, proper behavior is restored in 24.3.

OTOH, notify-via-dbus isn't throwing an error that I can find, either when I
toggle-debug-on-error, or look in *Messages*, or edebug my way through
erc-match-message.  Also, when I run (notify-via-dbus "title" "body")
everything seems fine too.

The one weird thing I've seen is when notify-method is set to notify-via-dbus
and I run this little test in an erc buffer with a bunch of output:

(defun baw-test ()
  (save-excursion
    (save-restriction
      (widen)
      (goto-char 409)
      (save-restriction
        (narrow-to-region 409 438)
        (notify "hello" "there")
        :icon "emacs-snapshot"
        :timeout -1)
      )))

I see a couple of seconds of flashing in the erc buffer, but it does seem like
the buffer's scroll state eventually gets restored.  When it's set to
notify-via-libnotify, there's no flashing.

Anyway, this seems highly weird, but at least now I have a workaround.  I'm
wondering if anybody has any further ideas about what could be going on.

Cheers,
-Barry

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]