Function: message-pop-to-buffer

message-pop-to-buffer is a byte-compiled function defined in message.el.gz.

Signature

(message-pop-to-buffer NAME &optional SWITCH-FUNCTION)

Documentation

Pop to buffer NAME, and warn if it already exists and is modified.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-pop-to-buffer (name &optional switch-function)
  "Pop to buffer NAME, and warn if it already exists and is modified."
  (let ((buffer (get-buffer name)))
    (if (buffer-live-p buffer)
	(let ((window (get-buffer-window buffer 0)))
	  (if window
	      ;; Raise the frame already displaying the message buffer.
	      (progn
		(select-frame-set-input-focus (window-frame window))
		(select-window window))
	    (funcall (or switch-function #'pop-to-buffer) buffer)
	    (set-buffer buffer))
	  (when (and (buffer-modified-p)
		     (not (prog1
			      (y-or-n-p
			       "Message already being composed; erase? ")
			    (message nil))))
	    (error "Message being composed")))
      (funcall (or switch-function 'pop-to-buffer-same-window)
	       name)
      (set-buffer name))
    (erase-buffer)
    (message-mode)))