Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New mail notifications in Gnus for Emacs

Tags:

email

emacs

gnus

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

like image 531
Ryan E Avatar asked Jun 27 '09 17:06

Ryan E


3 Answers

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.

like image 118
zpinter Avatar answered Nov 07 '22 11:11

zpinter


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 ;)

like image 37
Michael Markert Avatar answered Nov 07 '22 11:11

Michael Markert


  • 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.

like image 37
yPhil Avatar answered Nov 07 '22 12:11

yPhil