(nnoo-define-skeleton nnir)
+(defmacro nnir-add-result (dirnam artno score prefix server artlist)
+ "Ask `nnir-compose-result' to construct a result vector,
+and if it is non-nil, add it to artlist."
+ `(let ((result (nnir-compose-result dirnam artno score prefix server)))
+ (when (not (null result))
+ (push result artlist))))
+
+
;; Helper function currently used by the Swish++ and Namazu backends;
;; perhaps useful for other backends as well
(defun nnir-compose-result (dirnam article score prefix server)
(when (string-match (concat "^" prefix) dirnam)
(setq dirnam (replace-match "" t t dirnam)))
- ;; remove trailing slash and, for nnmaildir, cur/new/tmp
- (setq dirnam (substring dirnam 0 (if (string= server "nnmaildir:") -5 -1)))
+ (if (not (file-readable-p (concat prefix dirnam article)))
+ nil
+ ;; remove trailing slash and, for nnmaildir, cur/new/tmp
+ (setq dirnam
+ (substring dirnam 0 (if (string= server "nnmaildir:") -5 -1)))
- ;; eliminate all ".", "/", "\" from beginning. Always matches.
- (string-match "^[./\\]*\\(.*\\)$" dirnam)
- (setq group (substitute ?. ?/ (match-string 1 dirnam))) ;; "/" -> "."
- (setq group (substitute ?. ?\\ group)) ;; "\\" -> "."
+ ;; eliminate all ".", "/", "\" from beginning. Always matches.
+ (string-match "^[./\\]*\\(.*\\)$" dirnam)
+ (setq group (substitute ?. ?/ (match-string 1 dirnam))) ;; "/" -> "."
+ (setq group (substitute ?. ?\\ group)) ;; "\\" -> "."
- (vector (nnir-group-full-name group server)
- (if (string= server "nnmaildir:")
- (nnmaildir-base-name-to-article-number
- (substring article 0 (string-match ":" article))
- group nil)
- (string-to-int article))
- (string-to-int score)))
+ (vector (nnir-group-full-name group server)
+ (if (string= server "nnmaildir:")
+ (nnmaildir-base-name-to-article-number
+ (substring article 0 (string-match ":" article))
+ group nil)
+ (string-to-int article))
+ (string-to-int score))))
;;; Search Engine Interfaces:
artno (file-name-nondirectory filenam)
dirnam (file-name-directory filenam))
- ;; don't match directories or inexistent/unreadable files
- (when (and (string-match article-pattern artno)
- (file-readable-p (concat prefix filenam)))
+ ;; don't match directories
+ (when (string-match article-pattern artno)
(when (not (null dirnam))
;; maybe limit results to matching groups.
(when (or (not groupspec)
(string-match groupspec dirnam))
- (push (nnir-compose-result dirnam artno score prefix server)
- artlist)))))
+ (nnir-add-result dirnam artno score prefix server artlist)))))
(message "Massaging swish++ output...done")
;; make sure article and group is sane
(when (and (string-match article-pattern article)
(not (null group)))
- (push (nnir-compose-result group article score prefix server)
- artlist)))
+ (nnir-add-result group article score prefix server artlist)))
;; sort artlist by score
(apply 'vector