          (msg-window (split-window-below 12))
          (entry-id (progn
                      (goto-line ln0)
-                     (olm-mail-item-entry-id-at))))
+                     (olm-summary-message-entry-id))))
     (olm-open-message entry-id msg-window))
   (olm-summary-mark-message-as-read))
 
 (defun olm-summary-mark-message-as-read ()
   (interactive)
-  (olm-do-command (format "Olm.mark_as_read %S" (olm-mail-item-entry-id-at))))
+  (olm-do-command (format "Olm.mark_as_read %S" (olm-summary-message-entry-id))))
 
 (defun olm-summary-scroll-message-forward ()
   (interactive)


(defun olm-summary-refile ()
  (interactive)
  (let* ((from (olm-mail-item-entry-id-at))
         (folder-name (completing-read "Refile to: "
                                       (olm-folder-names)
                                       nil

    (olm-summary-open-message)))

;;; A helper function for olm-summary-mode functions.
(defun olm-summary-message-entry-id (&optional at)
  (interactive)
  (let ((n (line-number-at-pos)))
    (with-current-buffer (olm-buf-entry-ids)
