* lisp/gnus-namazu.el (gnus-namazu-query-highlight): New option.
authortsuchiya <tsuchiya>
Fri, 4 Jan 2002 16:38:54 +0000 (16:38 +0000)
committertsuchiya <tsuchiya>
Fri, 4 Jan 2002 16:38:54 +0000 (16:38 +0000)
(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.

ChangeLog
lisp/gnus-namazu.el
texi/gnus-ja.texi

index ec47f97..09219c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-01-05  TSUCHIYA Masatoshi  <tsuchiya@namazu.org>
+
+       * 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-21  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * lisp/dgnushack.el (dgnushack-bind-colon-keywords): Ignore
        * lisp/message.el (message-strip-special-text-properties): Default
        to t because of the new function `message-tamago-not-in-use-p'.
 
-2001-11-26  Kai Gro\e.A\eN_johann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+2001-11-26  Kai Gro\eN_johann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 
        * make-x.bat: Use parameter "/copy" rather than "copy" for increased
        dwimishness for old-time DOS users.  From Frank Schmitt
index e0e3eb8..0a5d6bb 100644 (file)
@@ -142,6 +142,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 +280,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 +329,39 @@ 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 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)))))
+           (when (or
+                  (and (looking-at cache-regexp)
+                       (setq file (match-string-no-properties 2)
+                             group (gnus-namazu/check-cache-group
+                                    (match-string-no-properties 1))))
+                  (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))))
          (forward-line 1))
        (nreverse articles)))))
 
@@ -322,8 +380,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 +508,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 +587,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 6304918..a01598a 100644 (file)
@@ -15086,8 +15086,9 @@ Namazu \e$B$r;H$C$F!"%a!<%k$N;3$+$i$"$J$?$N9%$-$J%-!<%o!<%I$r4^$`5-;v$r8+\e(B
 
 \e$B:G=i$KHa$7$$$*CN$i$;$,$R$H$D!#\e(B@file{gnus-namazu.el} \e$B$O!"8=;~E@$G$O!"\e(B
 @code{nnml} \e$B%P%C%/%(%s%I$"$k$$$O\e(B @code{nnmh} \e$B%P%C%/%(%s%I$K$h$C$FJ]B8\e(B
-\e$B$5$l$F$$$k5-;v$7$+!"<h$j07$&$3$H$,$G$-$^$;$s!#\e(B@code{nnimap} \e$B%P%C%/%(%s\e(B
-\e$B%I$d\e(B @code{nnmbox} \e$B%P%C%/%(%s%I$r;H$C$F$$$k?M$O!"$4$a$s$J$5$$!#\e(B
+\e$B$5$l$F$$$k5-;v$H!"\e(B@code{gnus-cache-enter-article} \e$B$K$h$C$F1JB32=$5$l$?\e(B
+\e$B5-;v$7$+!"<h$j07$&$3$H$,$G$-$^$;$s!#\e(B@code{nnimap} \e$B%P%C%/%(%s%I$d\e(B 
+@code{nnmbox} \e$B%P%C%/%(%s%I$r;H$C$F$$$k?M$O!"$4$a$s$J$5$$!#\e(B
 
 \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
@@ -15096,17 +15097,18 @@ Namazu \e$B$r;H$C$F!"%a!<%k$N;3$+$i$"$J$?$N9%$-$J%-!<%o!<%I$r4^$`5-;v$r8+\e(B
   @uref{http://namazu.org/}
 @end example
 
-\e$B<!$K!"$"$J$?$NHkB"$N%a!<%k$N;3$N:w0z$r:n$j$^$9!#$=$N$?$a$K$O!"0J2<$N\e(B2
-\e$B$D$N%3%^%s%I$r<B9T$9$kI,MW$,$"$k$G$7$g$&!#\e(B
+\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
+  % 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$N:w0z\e(B
-\e$B$r:n@.$9$k!"$H$$$&0UL#$G$9!#\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
 
@@ -15121,8 +15123,8 @@ Namazu \e$B$r;H$C$F!"%a!<%k$N;3$+$i$"$J$?$N9%$-$J%-!<%o!<%I$r4^$`5-;v$r8+\e(B
 @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$i$N%a!<%k$+$i$J$k2>A[%0%k!<%W$r:n@.$7$^$9\e(B@xref{Virtual
-Groups}\e$B!#\e(B
+\e$BC5$7=P$7!"$=$l$i$N%a!<%k$+$i$J$k2>A[%0%k!<%W$r:n@.$7$^$9\e(B(@xref{Virtual
+Groups})\e$B!#\e(B
 
 @kbd{C-c C-n}\e$B$K$h$C$F8F$S=P$5$l$kL?Na\e(B @code{gnus-namazu-search} \e$B$O!"\e(B
 gnus \e$B$NDL>o$N?t;z@\F,<-$d!"%W%m%;%9@\F,<-$rM}2r$7$^$9!#$G$9$+$i!"$"$J\e(B
@@ -23032,6 +23034,8 @@ Gnus \e$B$O\e(B Emacs Lisp \e$B$K$h$C$F=q$+$l$F$$$F!"$=$l$O$?$/$5$s$NC`<!2r<a<B9T$5
 @c Local Variables:
 @c mode: texinfo
 @c coding: iso-2022-7bit
+@c use-kuten-for-period: t
+@c use-touten-for-comma: t
 @c End:
 % LocalWords:  BNF mucho detailmenu cindex kindex kbd
 % LocalWords:  findex Gnusae vindex dfn dfn samp nntp setq nnspool nntpserver