Function: gnus-start-news-server

gnus-start-news-server is a byte-compiled function defined in gnus-int.el.gz.

Signature

(gnus-start-news-server &optional CONFIRM)

Documentation

Open a method for getting news.

If CONFIRM is non-nil, the user will be asked for an NNTP server.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-int.el.gz
;;;
;;; Server Communication
;;;

(defun gnus-start-news-server (&optional confirm)
  "Open a method for getting news.
If CONFIRM is non-nil, the user will be asked for an NNTP server."
  (let (how)
    (if gnus-current-select-method
	;; Stream is already opened.
	nil
      ;; Open NNTP server.
      (when confirm
	;; Read server name with completion.
	(setq gnus-nntp-server
	      (gnus-completing-read "NNTP server"
                                    (cons gnus-nntp-server
					  (if (boundp 'gnus-secondary-servers)
					      gnus-secondary-servers))
                                    nil gnus-nntp-server)))

      (when (and gnus-nntp-server
		 (stringp gnus-nntp-server)
		 (not (string= gnus-nntp-server "")))
	(setq gnus-select-method
	      (cond ((or (string= gnus-nntp-server "")
			 (string= gnus-nntp-server "::"))
		     (list 'nnspool (system-name)))
		    ((string-match "^:" gnus-nntp-server)
		     (list 'nnmh gnus-nntp-server
			   (list 'nnmh-directory
				 (file-name-as-directory
				  (expand-file-name
				   (substring gnus-nntp-server 1) "~/")))
			   (list 'nnmh-get-new-mail nil)))
		    (t
		     (list 'nntp gnus-nntp-server)))))

      (setq how (car gnus-select-method))
      (cond
       ((eq how 'nnspool)
	(require 'nnspool)
	(gnus-message 5 "Looking up local news spool..."))
       ((eq how 'nnmh)
	(require 'nnmh)
	(gnus-message 5 "Looking up mh spool..."))
       (t
	(require 'nntp)))
      (setq gnus-current-select-method gnus-select-method)
      (gnus-run-hooks 'gnus-open-server-hook)

      ;; Partially validate agent covered methods now that the
      ;; gnus-select-method is known.

      (if gnus-agent
          ;; NOTE: This is here for one purpose only.  By validating
          ;; the current select method, it converts the old 5.10.3,
          ;; and earlier, format to the current format.  That enables
          ;; the agent code within gnus-open-server to function
          ;; correctly.
          (gnus-agent-read-servers-validate-native gnus-select-method))

      (or
       ;; gnus-open-server-hook might have opened it
       (gnus-server-opened gnus-select-method)
       (gnus-open-server gnus-select-method)
       gnus-batch-mode
       (gnus-y-or-n-p
	(format-message
	 "%s (%s) open error: `%s'.  Continue? "
	 (car gnus-select-method) (cadr gnus-select-method)
	 (gnus-status-message gnus-select-method)))
       (gnus-error 1 "Couldn't open server on %s"
		   (nth 1 gnus-select-method))))))