Function: nnmairix-request-group

nnmairix-request-group is a byte-compiled function defined in nnmairix.el.gz.

Signature

(nnmairix-request-group GROUP &optional SERVER FAST INFO)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nnmairix.el.gz
(deffoo nnmairix-request-group (group &optional server fast _info)
  ;; Call mairix and request group on back end server
  (when server (nnmairix-open-server server))
  (let* ((qualgroup (if server
			(gnus-group-prefixed-name group (list 'nnmairix server))
		      group))
	 (folder (gnus-group-get-parameter qualgroup 'folder))
	 (allowfast (gnus-group-get-parameter qualgroup 'allow-fast))
	 (query (gnus-group-get-parameter qualgroup 'query t))
	 (threads (gnus-group-get-parameter qualgroup 'threads))
	 (backendmethod (gnus-server-to-method
			 (format "%s:%s" (symbol-name nnmairix-backend)
				 nnmairix-backend-server)))
	 rval mfolder folderpath) ;; args
    (cond
     ((not folder)
      ;; No folder parameter -> error
      (nnheader-report 'nnmairix "Check folder parameter for group %s" group)
      nil)
     ((not query)
      ;; No query -> return empty group
      (with-current-buffer nntp-server-buffer
	(erase-buffer)
	(insert (concat "211 0 1 0 " group))
	t))
     (t
      ;; For maildir++ folders: create a hidden directory (prepend dot)
      (setq mfolder (if (and nnmairix-hidden-folders
			     (not (string-match "^\\." folder)))
			(concat "." folder)
		      folder))
      ;; For nnml and nnmaildir, precede mfolder with directory where mail
      ;; is actually stored so that it's independent of 'base' setting
      ;; in .mairixrc.
      (when (eq nnmairix-backend 'nnml)
	(setq folderpath (cadr (assoc 'nnml-directory backendmethod)))
	;; if nnml-directory is not explicitly set, use global value
	(when (not folderpath)
	  (setq folderpath nnml-directory)))
      (when (eq nnmairix-backend 'nnmaildir)
	(setq folderpath
	      (cadr (assoc 'directory backendmethod))))
      (when folderpath
	(setq mfolder
	      (concat
	       (file-name-as-directory
		(expand-file-name
		 folderpath))
	       mfolder)))
      ;; If (not fast), call Mairix binary
      ;; recreate underlying folder on the back end
      (setq rval
	    (if (and fast allowfast)
		0
	      (nnmairix-call-mairix-binary
	       (split-string nnmairix-mairix-command)
	       mfolder query threads)))
      ;; Check return value
      (cond
       ((zerop rval)			; call was successful
	(nnmairix-call-backend
	 "open-server" nnmairix-backend-server)
	;; If we're dealing with nnml, rename files
	;; consecutively and make new active file for this
	;; group
	(when (eq nnmairix-backend 'nnml)
	  (when nnmairix-rename-files-for-nnml
	    (nnmairix-rename-files-consecutively mfolder))
	  (nnml-generate-nov-databases-directory mfolder nil t))
	(nnmairix-call-backend
	 "request-scan" folder nnmairix-backend-server)
	(if (and fast allowfast)
	    t
	  (nnmairix-request-group-with-article-number-correction
	   folder qualgroup)))
       ((and (= rval 1)
	     (with-current-buffer nnmairix-mairix-output-buffer
	       (goto-char (point-min))
	       (looking-at "^Matched 0 messages")))
	;; No messages found -> return empty group
	(nnheader-message 5 "Mairix: No matches found.")
	(set-buffer nntp-server-buffer)
	(erase-buffer)
	(insert (concat "211 0 1 0 " group))
	t)
       ;; Everything else is an error
       (t
	(nnheader-report
	 'nnmairix "Error running mairix. See buffer %s for details"
	 nnmairix-mairix-output-buffer)
	nil))))))