New mail notifications in Gnus for Emacs
Asked Answered
W

3

12

I am using Gnus within Emacs as my mail client. I have my .gnus.el configured to check for mail periodically [1] but, right now, I have no way of knowing if I have received new mail short of switching to the Group buffer. I would like to receive some type of notification when I have new mail in a specific group or groups. I found gnus-notify.el [2] but I have been unsuccessful in getting it to work (admittedly probably due to my lack of understanding as to how to configure it properly - I am new to Emacs and Gnus). Can anyone provide the steps I need to take to get gnus-notify working correctly or provide another way to get some type of new mail indicator using Gnus?

[1]

(gnus-demon-add-handler 'gnus-group-get-new-news 2 t)
(gnus-demon-init)

[2] http://www.emacswiki.org/cgi-bin/wiki/gnus-notify.el

Weighbridge answered 27/6, 2009 at 17:27 Comment(0)
G
6

There's some extra detail here:

http://www.emacswiki.org/emacs/GnusBiff

If you're on a mac, you can probably just use the growlnotify command to get a nice alert of new mail. The updated mac-biff-update function would probably look something like this:

(defun mac-biff-update ()
  "Read the mail count from Gnus."
  (let ((buffer (get-buffer "*Group*"))
        (count 0))
    (when buffer
      (with-current-buffer buffer
        (goto-char (point-min))
        (while (re-search-forward mac-biff-mail-re nil t)
          (setq count (+ count (string-to-number (match-string 1)))))))
    (if (> count 0)
          (shell-command
            (format "/usr/local/bin/growlnotify -a Emacs.app -m 'You have %d new messages!'" count)))))

The growlnotify command is an optional package that can be installed from the full growl .dmg file.

Gopak answered 29/6, 2009 at 3:38 Comment(1)
Nice. I was able to get growl notifications working with the above code and some help from the emacswiki page. Thanks.Weighbridge
K
4

I can recommend gnus-desktop-notify

There's also an example for configuring growl/Mac setup.

Note also, that you are checking every 2 minutes (2 * 60s, see gnus-demon-timestep), just for the case you don't want to be interrupted every 2 minutes ;)

Kaila answered 24/7, 2011 at 22:18 Comment(1)
This should be the accepted answer. M-x package-install <gnus-desktop-notify> RET is standard nowadays.Kinesiology
K
3
  • Download gnus-notify.el here and put it where emacs can find it (I could not for the life of me make el-get-installed verion work. Oh well, I had to hack it anyway, read on) .
  • Put this in your .gnus.el :
(setq gnus-parameters
 '(("INBOX"
    (gnus-use-adaptive-scoring nil)
    (gnus-use-scoring nil)
    (visible . t)
    (display . all)
    (modeline-notify . t)
    )))

then try M-x gnus-mst-show-groups-with-new-messages to see if it's correctly installed.

(If you have other gnus-parameters definitions, let this one be the last one)

Normally you're supposed to use this parameter on a per-group basis, by going to the *groups* buffer, put the cursor over a group, press G p, enter (modeline-notify t) (yes, without the dot this time, and surrounded by another pair of parens if it's the only parameter for the group - and yes, delete that trailing 'nil') and exit and save by C-c C-c, but I find this solution more flexible and portable.

You may have to tweak the regexp that displays the name of the group, as it's designed to present alt.comp.sys.amiga as [a.c.s.a 2] (yeah, it's really dead now) to say something like [perso 12] [work 8] as I do. And you can click the label to jump to the group. Very nifty.

Kinesiology answered 8/3, 2012 at 0:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.