MB13が摂取したもの

読んだもの、見たもの、食べたものなど、外から取り入れたもの全般についての感想を書いておくチラシの裏

emacs jabberをnotify.elでnotification

Gmailは極力開かなくても済む環境を作り、emacsだけで色々済ませようという計画が着々と進行中。
その一環として、とりあえずはGoogle talkemacsから見られるようにしたのだが、やはりメッセージが来たらnotificationが欲しい。
EmacsWiki: Jabber Elを見るとXmessageでやる方法

(add-hook 'jabber-alert-message-hooks 'jabber-message-xmessage) 

が普通のようだが、twittering-modeのnotifyがnotify.elなので、そちらで統一することに

(defun notify-jabber-notify (from buf text proposed-alert)
  "(jabber.el hook) Notify of new Jabber chat messages via notify.el"
  (when (or jabber-message-alert-same-buffer
            (not (memq (selected-window) (get-buffer-window-list buf))))
    (if (jabber-muc-sender-p from)
        (notify (format "(PM) %s"
                       (jabber-jid-displayname (jabber-jid-user from)))
               (format "%s: %s" (jabber-jid-resource from) text)))
      (notify (format "%s" (jabber-jid-displayname from))
             text)))

(add-hook 'jabber-alert-message-hooks 'notify-jabber-notify)