Function: nndoc-possibly-change-buffer
nndoc-possibly-change-buffer is a byte-compiled function defined in
nndoc.el.gz.
Signature
(nndoc-possibly-change-buffer GROUP SOURCE)
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nndoc.el.gz
;;; Internal functions.
(defun nndoc-possibly-change-buffer (group _source)
(let (buf)
(cond
;; The current buffer is this group's buffer.
((and (buffer-live-p nndoc-current-buffer)
(eq nndoc-current-buffer
(setq buf (cdr (assoc group nndoc-group-alist))))))
;; We change buffers by taking an old from the group alist.
;; `source' is either a string (a file name) or a buffer object.
(buf
(setq nndoc-current-buffer buf))
;; It's a totally new group.
((or (buffer-live-p nndoc-address)
(and (stringp nndoc-address)
(file-exists-p nndoc-address)
(not (file-directory-p nndoc-address))))
(push (cons group (setq nndoc-current-buffer
(gnus-get-buffer-create
(concat " *nndoc " group "*"))))
nndoc-group-alist)
(setq nndoc-dissection-alist nil)
(with-current-buffer nndoc-current-buffer
(erase-buffer)
(set-buffer-multibyte nil)
(condition-case error
(if (and (stringp nndoc-address)
(string-match nndoc-binary-file-names nndoc-address))
(let ((coding-system-for-read 'binary))
(mm-insert-file-contents nndoc-address))
(if (stringp nndoc-address)
(nnheader-insert-file-contents nndoc-address)
(insert-buffer-substring nndoc-address))
(run-hooks 'nndoc-open-document-hook))
(file-error
(nnheader-report 'nndoc "Couldn't open %s: %s"
group error))))))
;; Initialize the nndoc structures according to this new document.
(when (and nndoc-current-buffer
(not nndoc-dissection-alist))
(with-current-buffer nndoc-current-buffer
(nndoc-set-delims)
(if (eq nndoc-article-type 'mime-parts)
(nndoc-dissect-mime-parts)
(nndoc-dissect-buffer))))
(unless nndoc-current-buffer
(nndoc-close-server))
;; Return whether we managed to select a file.
nndoc-current-buffer))