+ (let* ((orig (gnus-group-prefixed-name group method))
+ (name (downcase orig)))
+ (catch 'found-group
+ (mapatoms (lambda (sym)
+ (when (string= name (downcase (symbol-name sym)))
+ (throw 'found-group (symbol-name sym))))
+ gnus-newsrc-hashtb)
+ orig))))
+
+(defun gnus-namazu/check-cache-group (str)
+ "Get the news group from the partial path STR of the cached article."
+ (if (gnus-use-long-file-name 'not-cache)
+ str
+ (catch 'found-group
+ (dolist (group (gnus-namazu/cache-group-candidates
+ (nnheader-replace-chars-in-string str ?/ ?.)))
+ (when (gnus-gethash group gnus-newsrc-hashtb)
+ (throw 'found-group group))))))
+
+(defun gnus-namazu/cache-group-candidates (str)
+ "Regard the string STR as the partial path of the cached article and
+generate possible group names from it."
+ (if (string-match "_\\(_\\(_\\)?\\)?" str)
+ (let ((prefix (substring str 0 (match-beginning 0)))
+ (suffix (substring str (match-end 0))))
+ (cond
+ ((match-beginning 2) ;; The number of discoverd underscores = 3
+ (nconc
+ (gnus-namazu/cache-group-candidates (concat prefix "/__" suffix))
+ (gnus-namazu/cache-group-candidates (concat prefix ".._" suffix))))
+ ((match-beginning 1) ;; The number of discoverd underscores = 2
+ (nconc
+ (gnus-namazu/cache-group-candidates (concat prefix "//" suffix))
+ (gnus-namazu/cache-group-candidates (concat prefix ".." suffix))))
+ (t ;; The number of discoverd underscores = 1
+ (gnus-namazu/cache-group-candidates (concat prefix "/" suffix)))))
+ (if (string-match "\\." str)
+ ;; Handle the first occurence of period.
+ (list (concat (substring str 0 (match-beginning 0))
+ ":"
+ (substring str (match-end 0)))
+ str)
+ (list str))))