Commit ec179403 authored by Glenn Morris's avatar Glenn Morris
Browse files

(top-level): Don't require cl at run-time.

(nnir-run-waissearch, nnir-run-swish-e, nnir-run-hyrex):
Replace cl-function substitute with gnus-replace-in-string.
(nnir-run-waissearch, nnir-run-swish++, nnir-run-swish-e)
(nnir-run-hyrex, nnir-run-namazu): Replace cl-function sort* with sort.
(nnir-run-find-grep): Replace cl-functions find-if and subseq with
simplified expansions.
parent 91677576
2009-08-25 Glenn Morris <rgm@gnu.org>
* nnir.el (top-level): Don't require cl at run-time.
(nnir-run-waissearch, nnir-run-swish-e, nnir-run-hyrex):
Replace cl-function substitute with gnus-replace-in-string.
(nnir-run-waissearch, nnir-run-swish++, nnir-run-swish-e)
(nnir-run-hyrex, nnir-run-namazu): Replace cl-function sort* with sort.
(nnir-run-find-grep): Replace cl-functions find-if and subseq with
simplified expansions.
2009-08-22 Glenn Morris <rgm@gnu.org> 2009-08-22 Glenn Morris <rgm@gnu.org>
* gnus-art.el (gnus-button-patch): Use forward-line rather than * gnus-art.el (gnus-button-patch): Use forward-line rather than
......
...@@ -336,7 +336,7 @@ ...@@ -336,7 +336,7 @@
(require 'gnus-sum) (require 'gnus-sum)
(require 'message) (require 'message)
(require 'gnus-util) (require 'gnus-util)
(eval-and-compile (eval-when-compile
(require 'cl)) (require 'cl))
(nnoo-declare nnir) (nnoo-declare nnir)
...@@ -916,17 +916,18 @@ pairs (also vectors, actually)." ...@@ -916,17 +916,18 @@ pairs (also vectors, actually)."
(unless (string-match prefix dirnam) (unless (string-match prefix dirnam)
(nnheader-report 'nnir "Dir name %s doesn't contain prefix %s" (nnheader-report 'nnir "Dir name %s doesn't contain prefix %s"
dirnam prefix)) dirnam prefix))
(setq group (substitute ?. ?/ (replace-match "" t t dirnam))) (setq group (gnus-replace-in-string
(replace-match "" t t dirnam) "/" "."))
(push (vector (nnir-group-full-name group server) (push (vector (nnir-group-full-name group server)
(string-to-number artno) (string-to-number artno)
(string-to-number score)) (string-to-number score))
artlist)) artlist))
(message "Massaging waissearch output...done") (message "Massaging waissearch output...done")
(apply 'vector (apply 'vector
(sort* artlist (sort artlist
(function (lambda (x y) (function (lambda (x y)
(> (nnir-artitem-rsv x) (> (nnir-artitem-rsv x)
(nnir-artitem-rsv y))))))))) (nnir-artitem-rsv y)))))))))
;; IMAP interface. ;; IMAP interface.
;; todo: ;; todo:
...@@ -1235,10 +1236,10 @@ Windows NT 4.0." ...@@ -1235,10 +1236,10 @@ Windows NT 4.0."
;; Sort by score ;; Sort by score
(apply 'vector (apply 'vector
(sort* artlist (sort artlist
(function (lambda (x y) (function (lambda (x y)
(> (nnir-artitem-rsv x) (> (nnir-artitem-rsv x)
(nnir-artitem-rsv y))))))))) (nnir-artitem-rsv y)))))))))
;; Swish-E interface. ;; Swish-E interface.
(defun nnir-run-swish-e (query server &optional group) (defun nnir-run-swish-e (query server &optional group)
...@@ -1316,9 +1317,9 @@ Tested with swish-e-2.0.1 on Windows NT 4.0." ...@@ -1316,9 +1317,9 @@ Tested with swish-e-2.0.1 on Windows NT 4.0."
;; eliminate all ".", "/", "\" from beginning. Always matches. ;; eliminate all ".", "/", "\" from beginning. Always matches.
(string-match "^[./\\]*\\(.*\\)$" dirnam) (string-match "^[./\\]*\\(.*\\)$" dirnam)
;; "/" -> "." ;; "/" -> "."
(setq group (substitute ?. ?/ (match-string 1 dirnam))) (setq group (gnus-replace-in-string (match-string 1 dirnam) "/" "."))
;; Windows "\\" -> "." ;; Windows "\\" -> "."
(setq group (substitute ?. ?\\ group)) (setq group (gnus-replace-in-string group "\\\\" "."))
(push (vector (nnir-group-full-name group server) (push (vector (nnir-group-full-name group server)
(string-to-number artno) (string-to-number artno)
...@@ -1329,10 +1330,10 @@ Tested with swish-e-2.0.1 on Windows NT 4.0." ...@@ -1329,10 +1330,10 @@ Tested with swish-e-2.0.1 on Windows NT 4.0."
;; Sort by score ;; Sort by score
(apply 'vector (apply 'vector
(sort* artlist (sort artlist
(function (lambda (x y) (function (lambda (x y)
(> (nnir-artitem-rsv x) (> (nnir-artitem-rsv x)
(nnir-artitem-rsv y))))))))) (nnir-artitem-rsv y)))))))))
;; HyREX interface ;; HyREX interface
(defun nnir-run-hyrex (query server &optional group) (defun nnir-run-hyrex (query server &optional group)
...@@ -1397,19 +1398,20 @@ Tested with swish-e-2.0.1 on Windows NT 4.0." ...@@ -1397,19 +1398,20 @@ Tested with swish-e-2.0.1 on Windows NT 4.0."
score (match-string 3)) score (match-string 3))
(when (string-match prefix dirnam) (when (string-match prefix dirnam)
(setq dirnam (replace-match "" t t dirnam))) (setq dirnam (replace-match "" t t dirnam)))
(push (vector (nnir-group-full-name (substitute ?. ?/ dirnam) server) (push (vector (nnir-group-full-name
(gnus-replace-in-string dirnam "/" ".") server)
(string-to-number artno) (string-to-number artno)
(string-to-number score)) (string-to-number score))
artlist)) artlist))
(message "Massaging hyrex-search output...done.") (message "Massaging hyrex-search output...done.")
(apply 'vector (apply 'vector
(sort* artlist (sort artlist
(function (lambda (x y) (function (lambda (x y)
(if (string-lessp (nnir-artitem-group x) (if (string-lessp (nnir-artitem-group x)
(nnir-artitem-group y)) (nnir-artitem-group y))
t t
(< (nnir-artitem-number x) (< (nnir-artitem-number x)
(nnir-artitem-number y))))))) (nnir-artitem-number y)))))))
))) )))
;; Namazu interface ;; Namazu interface
...@@ -1476,10 +1478,10 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." ...@@ -1476,10 +1478,10 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
;; sort artlist by score ;; sort artlist by score
(apply 'vector (apply 'vector
(sort* artlist (sort artlist
(function (lambda (x y) (function (lambda (x y)
(> (nnir-artitem-rsv x) (> (nnir-artitem-rsv x)
(nnir-artitem-rsv y))))))))) (nnir-artitem-rsv y)))))))))
(defun nnir-run-find-grep (query server &optional group) (defun nnir-run-find-grep (query server &optional group)
"Run find and grep to obtain matching articles." "Run find and grep to obtain matching articles."
...@@ -1505,11 +1507,14 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." ...@@ -1505,11 +1507,14 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
"." "."
;; Try accessing the group literally as well as ;; Try accessing the group literally as well as
;; interpreting dots as directory separators so the ;; interpreting dots as directory separators so the
;; engine works with plain nnml as well as the Gnus ;; engine works with plain nnml as well as the Gnus Cache.
;; Cache. (let ((group (gnus-group-real-name group)))
(find-if 'file-directory-p ;; Replace cl-func find-if.
(let ((group (gnus-group-real-name group))) (if (file-directory-p group)
(list group (gnus-replace-in-string group "\\." "/" t))))))) group
(if (file-directory-p
(setq group (gnus-replace-in-string group "\\." "/" t)))
group))))))
(unless group (unless group
(error "Cannot locate directory for group")) (error "Cannot locate directory for group"))
(save-excursion (save-excursion
...@@ -1532,7 +1537,14 @@ Tested with Namazu 2.0.6 on a GNU/Linux system." ...@@ -1532,7 +1537,14 @@ Tested with Namazu 2.0.6 on a GNU/Linux system."
(art (string-to-number (car (last path))))) (art (string-to-number (car (last path)))))
(while (string= "." (car path)) (while (string= "." (car path))
(setq path (cdr path))) (setq path (cdr path)))
(let ((group (mapconcat 'identity (subseq path 0 -1) "."))) (let ((group (mapconcat 'identity
;; Replace cl-func: (subseq path 0 -1)
(let ((end (1- (length path)))
res)
(while (>= (setq end (1- end)) 0)
(push (pop path) res))
(nreverse res))
".")))
(push (vector (nnir-group-full-name group server) art 0) (push (vector (nnir-group-full-name group server) art 0)
artlist)) artlist))
(forward-line 1))) (forward-line 1)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment