Function: imap-mailbox-close

imap-mailbox-close is a byte-compiled function defined in imap.el.gz.

Signature

(imap-mailbox-close &optional ASYNCH BUFFER)

Documentation

Expunge articles and close current folder in BUFFER.

If ASYNCH, do not wait for successful completion of the command. If BUFFER is nil the current buffer is assumed.

Source Code

;; Defined in /usr/src/emacs/lisp/net/imap.el.gz
(defun imap-mailbox-close (&optional asynch buffer)
  "Expunge articles and close current folder in BUFFER.
If ASYNCH, do not wait for successful completion of the command.
If BUFFER is nil the current buffer is assumed."
  (with-current-buffer (or buffer (current-buffer))
    (when imap-current-mailbox
      (if asynch
	  (imap-add-callback (imap-send-command "CLOSE")
			     (let ((cmb imap-current-mailbox))
			       (lambda (_tag status)
				 (message "IMAP mailbox `%s' closed... %s"
					  imap-current-mailbox status)
				 (when (eq cmb imap-current-mailbox)
				   ;; Don't wipe out data if another mailbox
				   ;; was selected...
				   (setq imap-current-mailbox nil
					 imap-message-data nil
					 imap-state 'auth)))))
	(when (imap-ok-p (imap-send-command-wait "CLOSE"))
	  (setq imap-current-mailbox nil
		imap-message-data nil
		imap-state 'auth)))
      t)))