Function: imap-send-command
imap-send-command is a byte-compiled function defined in imap.el.gz.
Signature
(imap-send-command COMMAND &optional BUFFER)
Source Code
;; Defined in /usr/src/emacs/lisp/net/imap.el.gz
(defun imap-send-command (command &optional buffer)
(with-current-buffer (or buffer (current-buffer))
(setq command (ensure-list command))
(let ((tag (setq imap-tag (1+ imap-tag)))
cmd cmdstr)
(setq cmdstr (concat (number-to-string imap-tag) " "))
(while (setq cmd (pop command))
(cond ((stringp cmd)
(setq cmdstr (concat cmdstr cmd)))
((bufferp cmd)
(let ((eol imap-client-eol)
(calcfirst imap-calculate-literal-size-first)
size)
(with-current-buffer cmd
(if calcfirst
(setq size (buffer-size)))
(when (not (equal eol "\r\n"))
;; XXX modifies buffer!
(goto-char (point-min))
(while (search-forward "\r\n" nil t)
(replace-match eol)))
(if (not calcfirst)
(setq size (buffer-size))))
(setq cmdstr
(concat cmdstr (format "{%d}" size))))
(unwind-protect
(progn
(imap-send-command-1 cmdstr)
(setq cmdstr nil)
(if (not (eq (imap-wait-for-tag tag) 'INCOMPLETE))
(setq command nil) ;; abort command if no cont-req
(let ((process imap-process))
(with-current-buffer cmd
(imap-log cmd)
(process-send-region process (point-min)
(point-max)))
(process-send-string process imap-client-eol))))
(setq imap-continuation nil)))
((functionp cmd)
(imap-send-command-1 cmdstr)
(setq cmdstr nil)
(unwind-protect
(setq command
(if (not (eq (imap-wait-for-tag tag) 'INCOMPLETE))
nil ;; abort command if no cont-req
(cons (funcall cmd imap-continuation)
command)))
(setq imap-continuation nil)))
(t
(error "Unknown command type"))))
(if cmdstr
(imap-send-command-1 cmdstr))
tag)))