Function: nnmairix-get-group-from-file-path
nnmairix-get-group-from-file-path is a byte-compiled function defined
in nnmairix.el.gz.
Signature
(nnmairix-get-group-from-file-path FILE)
Documentation
Get group by parsing the message location FILE.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nnmairix.el.gz
(defun nnmairix-get-group-from-file-path (file)
"Get group by parsing the message location FILE."
(let (path filename serverbase group maildirflag allgroups)
(string-match "^\\(.*\\)/\\(.*?\\)$" file)
(setq path (expand-file-name (match-string 1 file)))
(setq filename (match-string 2 file))
;; when we deal with maildir, remove cur/new/tmp from path
(setq maildirflag (string-match ".+\\..+\\..+" filename))
(when maildirflag
(setq path
(replace-regexp-in-string
".*\\(/cur\\|/new\\|/tmp\\)$" "" path t t 1)))
;; we first check nnml and nnmaildir servers
(setq
group
(catch 'found
(dolist (cur gnus-opened-servers)
(when (or (and (not maildirflag)
(eq (caar cur) 'nnml))
(and maildirflag
(eq (caar cur) 'nnmaildir)))
;; get base path from server
(if maildirflag
(setq serverbase (cadr (assoc 'directory (car cur))))
(setq serverbase (cadr (assoc 'nnml-directory (car cur))))
(unless serverbase
(setq serverbase nnml-directory)))
(setq serverbase (file-name-as-directory
(expand-file-name serverbase)))
(when (string-match (concat serverbase "\\(.*\\)") path)
;; looks good - rest of the path should be the group
(setq group (match-string 1 path))
(when (string-match "/$" group)
(setq group (replace-match "" t t group)))
(unless maildirflag
;; for nnml: convert slashes to dots
(while (string-match "/" group)
(setq group (replace-match "." t t group))))
(setq group (gnus-group-prefixed-name group (car cur)))
;; check whether this group actually exists
(when (gnus-group-entry group)
(throw 'found group)))))))
(unless group
;; we haven't found it yet --> look for nnimap groups. Assume
;; last element of the path is the group. This might fail since
;; IMAP servers may present groups to the client in arbitrary
;; ways...
(string-match "^.*/\\.?\\(.*\\)$" path)
(setq group (match-string 1 path))
;; convert dots to slashes (nested group)
(while (string-match "\\." group)
(setq group (replace-match "/" t t group)))
(dolist (cur gnus-opened-servers)
(when (eq (caar cur) 'nnimap)
(when (gnus-group-entry
(gnus-group-prefixed-name group (car cur)))
(push
(gnus-group-prefixed-name group (car cur))
allgroups))))
(if (> (length allgroups) 1)
(setq group (gnus-completing-read
"Group %s exists on more than one IMAP server. Choose"
allgroups t))
(setq group (car allgroups))))
group))