I am using mu4e-headers view with emails sorted by date in ascending order: the most recently received e-mail is shown on the bottom.

I usually have 20-30 older, read mails in my inbox, with the oldest one on top of the buffer. When I open the mu4e-headers buffer, then point is at the first buffer line, and therefore at my "oldest" e-mail. I would prefer the following behavior:

  1. When the mu4e-headers buffer is opened, then point is automatically moved to (the beginning of) the line of the first unread email
  2. If possible, point is at the same time in the first row of the frame. That is, the buffer is scrolled down, such that initially only the new, unread e-mails are visible, and I have to scroll up to see older ones.

Achieving only 1. would already help me a lot, if 2. turns out to be too difficult. I would appreciate any advice on how to achieve this.

My Elisp programming skills are rather low, but I think I have already figured out that mu4e-headers-mode-hook is the right place where a function that implements the above can be hooked in. But I have no idea how to identify the line of the first unread message, and how to move the cursor there.

1 Answer 1


The mu4e-headers-find-if function moves to the next header for which FUNC returns non-nil, so to address point 1 we have to check if the message has an unread flag. The last line addresses point 2 but let me know if it doesn't.

(add-hook 'mu4e-headers-found-hook
          (lambda ()
             (lambda (msg)
               (let ((flags (mu4e-message-field msg :flags)))
                 (member 'unread flags))))
            (when (get-buffer-window mu4e~headers-buffer-name)
              (switch-to-buffer mu4e~headers-buffer-name))
            (recenter 0)))
  • Works like a charm. Thanks for the help!
    – user64060
    Jul 29, 2019 at 14:28
  • With recent mu4e, mu4e~headers-buffer-name should be mu4e-headers-buffer-name Mar 4 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.