Merge changes on t-gnus-6_15-quimby.
authortsuchiya <tsuchiya>
Sat, 5 Jan 2002 15:30:20 +0000 (15:30 +0000)
committertsuchiya <tsuchiya>
Sat, 5 Jan 2002 15:30:20 +0000 (15:30 +0000)
ChangeLog
lisp/gnus-namazu.el
lisp/nnshimbun.el
texi/gnus-ja.texi

index 938a0f0..51f8a67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2002-01-06  TSUCHIYA Masatoshi  <tsuchiya@namazu.org>
+
+       * lisp/gnus-namazu.el: Update comments.
+       (gnus-namazu/search): Convert `gnus-cache-directory' to absolute
+       before the regular expression which matches paths of persistent
+       articles is generated.  Clean up codes.
+
+2002-01-05  TSUCHIYA Masatoshi  <tsuchiya@namazu.org>
+
+       * lisp/nnshimbun.el (nnshimbun-request-article): Handle the
+       article properly when no group is specified.
+       (nnshimbun-write-nov, nnshimbun-save-nov): Save nov databases only
+       when their sizes are greater than zero.
+
+       * lisp/gnus-namazu.el (gnus-namazu-query-highlight): New option.
+       (gnus-namazu-query-highlight-face): New face.
+       (gnus-namazu/check-cache-group): New function.
+       (gnus-namazu/cache-group-candidates): Ditto.
+       (gnus-namazu/search): Call `gnus-namazu/check-cache-group' to get
+       groups for cached articles.
+       (gnus-namazu/highlight-words): New function.
+       (gnus-namazu-search): Set the group parameter `highlight-words'
+       when `gnus-namazu-query-highlight' is equal to the other value
+       than nil.
+
+       * lisp/gnus-ja.texi (Namazu Groups): Updated.
+
 2001-12-10  TSUCHIYA Masatoshi  <tsuchiya@namazu.org>
 
        * lisp/gnus-namazu.el (gnus-namazu-summary-buffer-name): Changed
index e0e3eb8..ea9d338 100644 (file)
@@ -1,12 +1,10 @@
 ;;; gnus-namazu.el --- Search mail with Namazu.
 
-;; Copyright (C) 2000,2001 Tsuchiya Masatoshi <tsuchiya@namazu.org>
+;; Copyright (C) 2000,2001,2002 Tsuchiya Masatoshi <tsuchiya@namazu.org>
 
 ;; Author: Tsuchiya Masatoshi <tsuchiya@namazu.org>
 ;; Keywords: mail searching namazu
 
-;;; Copyright:
-
 ;; This file is a part of Semi-Gnus.
 
 ;; This program is free software; you can redistribute it and/or modify
 
 ;;; Commentary:
 
-;; This file defines the command to search mails with Namazu and
-;; browse its results with Gnus.  This module requires the external
-;; command Namazu.  Visit the following page for more information.
+;; This file defines the command to search mails and persistent
+;; articles with Namazu and browse its results with Gnus.  This module
+;; requires the external command, Namazu.  Visit the following page
+;; for more information.
 ;;
 ;;     http://namazu.org/
 
 ;; Make index of articles with Namzu before using this module.
 ;;
 ;;      % mkdir ~/News/namazu
-;;       % mknmz -a -h -O ~/News/namazu ~/Mail
+;;       % mknmz -a -h -O ~/News/namazu ~/Mail ~/News/cache
+;;
+;; The first command makes the directory for index files, and the
+;; second command generates index files of mails and persistent
+;; articles.
 ;;
 ;; When you put index files of Namazu into the directory other than
 ;; the default one (~/News/namazu), it is necessary to put this
@@ -142,6 +145,21 @@ options make any sense in this context."
   :type 'boolean
   :group 'gnus-namazu)
 
+(defcustom gnus-namazu-query-highlight t
+  "Non-nil means that queried words is highlighted."
+  :type 'boolean
+  :group 'gnus-namazu)
+
+(defface gnus-namazu-query-highlight-face
+  '((((type tty pc) (class color))
+     (:background "magenta4" :foreground "cyan1"))
+    (((class color) (background light))
+     (:background "magenta4" :foreground "lightskyblue1"))
+    (((class color) (background dark))
+     (:background "palevioletred2" :foreground "brown4"))
+    (t (:inverse-video t)))
+  "Face used for namazu query matching words."
+  :group 'gnus-namazu)
 
 ;;; Internal Variable:
 (defvar gnus-namazu/group-alist nil
@@ -265,6 +283,41 @@ options make any sense in this context."
       (or (cdr (assoc (downcase name) gnus-namazu/group-alist))
          name))))
 
+(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))))
+
 (defun gnus-namazu/search (groups query)
   (with-temp-buffer
     (let ((exit-status (gnus-namazu/call-namazu query)))
@@ -279,31 +332,41 @@ options make any sense in this context."
                         (when (setq dir (gnus-namazu/server-directory s))
                           (cons (file-name-as-directory dir) s)))
                       (gnus-namazu/indexed-servers)))))
-            (topdir-regexp (regexp-opt (mapcar 'car server-alist))))
+            (topdir-regexp (regexp-opt (mapcar 'car server-alist)))
+            (cache-regexp (concat
+                           (regexp-quote
+                            (file-name-as-directory
+                             (expand-file-name gnus-cache-directory)))
+                           "\\(.*\\)/\\([0-9]+\\)$")))
        (gnus-namazu/normalize-results)
        (goto-char (point-min))
        (while (not (eobp))
          (let (server group file)
-           (and (looking-at topdir-regexp)
-                ;; Check a discovered file is managed by Gnus servers.
-                (setq file (buffer-substring-no-properties
-                            (match-end 0) (gnus-point-at-eol))
-                      server (cdr (assoc (match-string-no-properties 0)
-                                         server-alist)))
-                ;; Check validity of the file name.
-                (string-match "/\\([0-9]+\\)\\'" file)
-                (progn
-                  (setq group (substring file 0 (match-beginning 0))
-                        file (match-string 1 file))
-                  (setq group
-                        (gnus-namazu/group-prefixed-name
-                         (nnheader-replace-chars-in-string group ?/ ?.)
-                         server))
-                  (when (or (not groups)
-                            (member group groups))
-                    (push (gnus-namazu/make-article
-                           group (string-to-number file))
-                          articles)))))
+           (and (or
+                 ;; Check the discoverd file is the persistent article.
+                 (and (looking-at cache-regexp)
+                      (setq file (match-string-no-properties 2)
+                            group (gnus-namazu/check-cache-group
+                                   (match-string-no-properties 1))))
+                 ;; Check the discovered file is managed by Gnus servers.
+                 (and (looking-at topdir-regexp)
+                      (setq file (buffer-substring-no-properties
+                                  (match-end 0) (gnus-point-at-eol))
+                            server (cdr (assoc (match-string-no-properties 0)
+                                               server-alist)))
+                      ;; Check validity of the file name.
+                      (string-match "/\\([0-9]+\\)\\'" file)
+                      (progn
+                        (setq group (substring file 0 (match-beginning 0))
+                              file (match-string 1 file))
+                        (setq group
+                              (gnus-namazu/group-prefixed-name
+                               (nnheader-replace-chars-in-string group ?/ ?.)
+                               server)))))
+                (or (not groups)
+                    (member group groups))
+                (push (gnus-namazu/make-article group (string-to-number file))
+                      articles)))
          (forward-line 1))
        (nreverse articles)))))
 
@@ -322,8 +385,9 @@ options make any sense in this context."
     ;; In Summary buffer.
     (if current-prefix-arg
        (list (gnus-read-group "Group: "))
-      (if (and (gnus-ephemeral-group-p gnus-newsgroup-name)
-              (string-match gnus-namazu/group-name-regexp gnus-newsgroup-name))
+      (if (and
+          (gnus-ephemeral-group-p gnus-newsgroup-name)
+          (string-match gnus-namazu/group-name-regexp gnus-newsgroup-name))
          (cadr (assq 'gnus-namazu-target-groups
                      (gnus-info-method (gnus-get-info gnus-newsgroup-name))))
        (list gnus-newsgroup-name))))))
@@ -449,6 +513,35 @@ options make any sense in this context."
     (read-from-minibuffer prompt initial gnus-namazu/read-query-map nil
                          'gnus-namazu/read-query-history)))
 
+(defun gnus-namazu/highlight-words (query)
+  (let ((strings)
+       (start 0))
+    (while (string-match
+           "[ \t\r\f\n]*\\(\\(and\\|or\\|\\(not\\)\\)[ \t\r\f\n]+\\)?\
+\\(\\+[^ \t\r\f\n]+:\\)?\\(/\\([^/]+\\)/\\|\\(\"\\([^\"]+\\)\"\\|\
+{\\([^{}]+\\)}\\)\\|[^ \t\r\f\n]+\\)" query start)
+      (setq start (match-end 0))
+      (or (match-beginning 3)          ; NOT search
+         (match-beginning 4)           ; Field search
+         (match-beginning 6)           ; Regular expression search
+         (if (match-beginning 7)       ; Phrase search
+             (dolist (str (split-string
+                           (if (match-beginning 8)
+                               (match-string 8 query)
+                             (match-string 9 query))))
+               (when (> (length str) 0)
+                 (push str strings)))
+           (push (match-string 5 query) strings))))
+    (and strings
+        (list
+         (list
+          (regexp-opt (mapcar
+                       (lambda (str)
+                         (if (string-match "\\`\\*?\\([^\\*]*\\)\\*?\\'" str)
+                             (match-string 1 str) str))
+                       strings))
+          0 0 'gnus-namazu-query-highlight-face)))))
+
 (defun gnus-namazu/truncate-article-list (articles)
   (let ((hit (length articles)))
     (when (> hit gnus-large-newsgroup)
@@ -499,6 +592,9 @@ and make a virtual group contains its results."
                             (gnus-namazu-target-groups ,groups)
                             (gnus-namazu-current-query ,query))
                 t (cons (current-buffer) (current-window-configuration)) t))
+         (when gnus-namazu-query-highlight
+           (gnus-group-set-parameter vgroup 'highlight-words
+                                     (gnus-namazu/highlight-words query)))
          ;; Generate new summary buffer which contains search results.
          (gnus-group-read-group
           t t vgroup
index aaa5a3f..a4c8400 100644 (file)
@@ -389,7 +389,14 @@ GROUP has a full name."
 (deffoo nnshimbun-request-article (article &optional group server to-buffer)
   (when (nnshimbun-possibly-change-group group server)
     (when (stringp article)
-      (setq article (nnshimbun-search-id group article)))
+      (let ((num (when (or group (setq group nnshimbun-current-group))
+                  (nnshimbun-search-id group article))))
+       (unless num
+         (let ((groups (shimbun-groups (shimbun-open server))))
+           (while (and (not num) groups)
+             (setq group (pop groups)
+                   num (nnshimbun-search-id group article)))))
+       (setq article num)))
     (if (integerp article)
        (nnshimbun-request-article-1 article group server to-buffer)
       (nnheader-report 'nnshimbun "Couldn't retrieve article: %s"
@@ -637,19 +644,20 @@ also be nil."
     (when (buffer-live-p buffer)
       (save-excursion
        (set-buffer buffer)
-       (buffer-modified-p)
-       (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
-                            nil 'nomesg)))))
+       (and (> (buffer-size) 0)
+            (buffer-modified-p)
+            (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
+                                 nil 'nomesg))))))
 
 (defun nnshimbun-save-nov ()
   (save-excursion
     (while nnshimbun-nov-buffer-alist
       (when (buffer-name (cdar nnshimbun-nov-buffer-alist))
        (set-buffer (cdar nnshimbun-nov-buffer-alist))
-       (when (buffer-modified-p)
-         (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
-                              nil 'nomesg))
-       (set-buffer-modified-p nil)
+       (and (> (buffer-size) 0)
+            (buffer-modified-p)
+            (nnmail-write-region 1 (point-max) nnshimbun-nov-buffer-file-name
+                                 nil 'nomesg))
        (kill-buffer (current-buffer)))
       (setq nnshimbun-nov-buffer-alist (cdr nnshimbun-nov-buffer-alist)))))
 
index c9de762..26116f0 100644 (file)
@@ -14057,6 +14057,7 @@ Gnus \e$B$O!"A4$F$N%0%k!<%W$N<oN`$r:.9g$7$F!"Bg$-$J%0%k!<%W$K7k9g$9$k$3$H$,\e(B
 @menu
 * Virtual Groups:: \e$B$?$/$5$s$N%0%k!<%W$N5-;v$r7k9g$9$k\e(B
 * Kibozed Groups:: \e$B%K%e!<%9%9%W!<%k$NCf$+$i$N5-;v$r8!:w$9$k\e(B
+* Namazu Groups::  Namazu \e$B$r;H$C$F%a!<%k$N;3$+$i5-;v$r<h$j=P$9\e(B
 @end menu
 
 @node Virtual Groups
@@ -14189,6 +14190,84 @@ Gnus \e$B$O$=$N\e(B @code{nnkiboze} \e$B%0%k!<%W$N0lIt$H$J$k$Y$-5-;v$,$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
+
+\e$B$=$l$G$O5$$r<h$jD>$7$F!"$^$:!"\e(BNamazu \e$B$r;H$($k$h$&$K$7$^$7$g$&!#>\$7$$\e(B
+\e$B$3$H$O!"<!$N%Z!<%8$GCN$k$3$H$,$G$-$^$9!#\e(B
+
+@example
+  @uref{http://namazu.org/}
+@end example
+
+\e$B<!$K!"$"$J$?$NHkB"$N%a!<%k$H1JB35-;v$N;3$N:w0z$r:n$j$^$9!#$=$N$?$a$K$O!"\e(B
+\e$B0J2<$N\e(B2\e$B$D$N%3%^%s%I$r<B9T$9$kI,MW$,$"$k$G$7$g$&!#\e(B
+
+@example
+  % mkdir ~/News/namazu
+  % mknmz -a -h -O ~/News/namazu ~/Mail ~/News/cache
+@end example
+
+\e$B$3$N%3%^%s%I$O!"\e(B(1) @file{~/News/namazu/} \e$B$H$$$&%G%#%l%/%H%j$r:n@.$9$k!"\e(B
+(2) \e$B$=$N%G%#%l%/%H%j$K\e(B @file{~/Mail/} \e$B0J2<$KJ]B8$5$l$F$$$k%a!<%k$H\e(B 
+@file{~/News/cache/} \e$B0J2<$KJ]B8$5$l$F$$$k1JB35-;v$N:w0z$r:n@.$9$k!"$H\e(B
+\e$B$$$&0UL#$G$9!#\e(B
+
+\e$B$5$"!"$3$l$G=`Hw$,$G$-$^$7$?!#\e(B
+
+@kindex C-c C-n (\e$B%0%k!<%W\e(B)
+@kindex C-c C-n (\e$B35N,\e(B)
+@findex gnus-namazu-search
+\e$B%0%k!<%W%P%C%U%!$G\e(B@kbd{C-c C-n}\e$B$HF~NO$9$k$H!"8!:w<0$r?R$M$i$l$^$9$+$i!"\e(B
+\e$BE,Ev$JC18l$rF~NO$7$F$/$@$5$$!#Nc$($P\e(B:
+
+@example
+  @kbd{C-c C-n gnus namazu RET}
+@end example
+
+\e$B$3$&$9$k$H!"\e(Bgnus \e$B$H\e(B namazu \e$B$NAPJ}$N%-!<%o!<%I$rF1;~$K4^$`%a!<%k$rA4$F\e(B
+\e$BC5$7=P$7!"$=$l$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C$F$b8!:w$5$l$J$$$3$H\e(B
+\e$B$K$J$j$^$9$+$i!"$"$7$+$i$:!#\e(B
+
 @node Gnus Unplugged
 @section Gnus \e$B$N@Z$jN%$7\e(B
 @cindex offline