-;; Namazu interface
-(defun nnir-run-namazu (query &optional group)
- "Run given query against namazu. Returns a vector of (group name, file name)
-pairs (also vectors, actually)."
- (save-excursion
- (let ((artlist nil)
- (groupspec (cdr (assq 'group query)))
- (qstring (cdr (assq 'query query)))
- (coding-system-for-read 'euc-japan)
- (coding-system-for-write 'euc-japan))
- (when (and group groupspec)
- (error (concat "It does not make sense to use a group spec"
- " with process-marked groups.")))
- (when group
- (setq groupspec (gnus-group-real-name group)))
- (set-buffer (get-buffer-create nnir-tmp-buffer))
- (erase-buffer)
- (if groupspec
- (message "Doing namazu query %s on %s..." query groupspec)
- (message "Doing namazu query %s..." query))
- (let* ((cp-list
- `( ,nnir-namazu-program
- nil ; input from /dev/null
- t ; output
- nil ; don't redisplay
- "--all" "--list" "--early"
- ,(if groupspec
- (format "+uri:%s %s" groupspec qstring)
- (format "%s" qstring))
- ,nnir-namazu-index ; index
- ))
- (exitstatus
- (progn
- (message "%s args: %s" nnir-namazu-program
- (mapconcat 'identity (cddddr cp-list) " "))
- (apply 'call-process cp-list))))
- (unless (or (null exitstatus)
- (zerop exitstatus))
- (nnheader-report "Couldn't run namazu: %s" exitstatus)
- ;; Namazu failure reason is in this buffer, show it if
- ;; the user wants it.
- (when (> gnus-verbose 6)
- (display-buffer nnir-tmp-buffer))))
- (if groupspec
- (message "Doing namazu query %s on %s..." query groupspec)
- (message "Doing namazu query %s...done" query))
- (sit-for 0)
- ;; CCC: The following work of extracting group name and article
- ;; number from the Namazu output can probably better be done by
- ;; just going through the buffer once, and plucking out the
- ;; right information from each line.
- ;; remove superfluous stuff from namazu output
- (goto-char (point-min))
- (delete-non-matching-lines "/[0-9]+$")
- ;;(delete-matching-lines "\\.overview~?$")
- (goto-char (point-min))
- (while (re-search-forward (concat "^" nnir-namazu-remove-prefix) nil t)
- (replace-match ""))
- ;; separate group name from article number with \t
- ;; XEmacs compatible version
- (goto-char (point-max))
- (while (re-search-backward "/[0-9]+$" nil t)
- (delete-char 1 nil)
- (insert-char ?\t 1))
-; Emacs compatible version
-; (goto-char (point-min))
-; (while (re-search-forward "\\(/\\)[0-9]+$" nil t)
-; (replace-match "\t" t t nil 1))
- ;; replace / with . in group names
- (subst-char-in-region (point-min) (point-max) ?/ ?. t)
- ;; massage buffer to contain some Lisp;
- ;; this depends on the artlist encoding internals
- ;; maybe this dependency should be removed?
- (goto-char (point-min))
- (while (not (eobp))
- (insert "(\"")
- (skip-chars-forward "^\t")
- (insert "\" ")
- (end-of-line)
- (insert " 1000 )") ; 1000 = score
- (forward-line 1))
- (insert "))\n")
- (goto-char (point-min))
- (insert "(setq artlist '(\n")
- (eval-buffer)
- artlist
- )))
-