Function: erc-cmd-QUIT

erc-cmd-QUIT is a byte-compiled function defined in erc.el.gz.

Signature

(erc-cmd-QUIT REASON)

Documentation

Disconnect from the current server.

If REASON is omitted, display a default quit message, otherwise display the message given by REASON.

Aliases

erc-cmd-EXIT erc-cmd-SIGNOFF erc-cmd-BYE

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-cmd-QUIT (reason)
  "Disconnect from the current server.
If REASON is omitted, display a default quit message, otherwise display
the message given by REASON."
  (unless reason
    (setq reason ""))
  (cond
   ((string-match "^\\s-*\\(.*\\)$" reason)
    (let* ((s (match-string 1 reason))
           (buffer (erc-server-buffer))
           (reason (funcall erc-quit-reason (if (equal s "") nil s)))
           server-proc)
      (with-current-buffer (if (and buffer
                                    (bufferp buffer))
                               buffer
                             (current-buffer))
        (erc-log (format "cmd: QUIT: %s" reason))
        (setq erc-server-quitting t)
        (erc-set-active-buffer (erc-server-buffer))
        (setq server-proc erc-server-process)
        (erc-server-send (format "QUIT :%s" reason)))
      (run-hook-with-args 'erc-quit-hook server-proc)
      (when erc-kill-queries-on-quit
        (erc-kill-query-buffers server-proc))
      ;; if the process has not been killed within 4 seconds, kill it
      (run-at-time 4 nil
                   (lambda (proc)
                     (when (and (processp proc)
                                (memq (process-status proc) '(run open)))
                       (delete-process proc)))
                   server-proc))
    t)
   (t nil)))