   (setq olm-folder-id (assoc-default olm-folder-name olm-folder-alist))
   (olm-scan))
 
-(defun olm-summary-refile ()
-  (interactive)
-  (let* ((from (olm-summary-message-entry-id))
-         (folder-name (completing-read "Refile to: "
-                                       (olm-folder-names)
-                                       nil
-                                       t))
-         (to (assoc-default folder-name olm-folder-alist))
-         (n (line-number-at-pos)))
+(defun olm-summary-refile (&optional to mark)
+  (interactive)
+  (let ((from (olm-summary-message-entry-id))
+        (to (or to
+                (assoc-default (completing-read "Refile to: "
+                                               (olm-folder-names)
+                                               nil
+                                               t)
+                              olm-folder-alist)))
+        (mark (or mark "o"))
+        (n (line-number-at-pos)))
     ;; insert the destination entry id into the org-ids buffer
     (with-current-buffer (olm-buf-entry-ids)
       (goto-line n)

    (beginning-of-line)
    (setq-local buffer-read-only nil)
    (delete-char 1)
    (insert "o")
    (setq-local buffer-read-only t)))

;;; A helper function for olm-summary-mode functions.
(defun olm-summary-message-entry-id ()

    (olm-do-command "Olm.default_folder_id" (current-buffer))
    (buffer-substring-no-properties (point-min) (1- (point-max)))))

(defun olm-deleted-items-folder-id ()
  (with-current-buffer (get-buffer-create "*olm-deleted-items-folder-id*")
    (erase-buffer)
    (olm-do-command "Olm.deleted_items_folder_id" (current-buffer))
    (buffer-substring-no-properties (point-min) (1- (point-max)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; buffers
