From 060d31cacd89bf7db64b14dcbd6b11747bb8755c Mon Sep 17 00:00:00 2001 From: tsuchiya Date: Sat, 5 Jan 2002 15:30:20 +0000 Subject: [PATCH] Merge changes on t-gnus-6_15-quimby. --- ChangeLog | 27 +++++++++ lisp/gnus-namazu.el | 156 +++++++++++++++++++++++++++++++++++++++++---------- lisp/nnshimbun.el | 24 +++++--- texi/gnus-ja.texi | 79 ++++++++++++++++++++++++++ 4 files changed, 248 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 938a0f0..51f8a67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2002-01-06 TSUCHIYA Masatoshi + + * 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 + + * 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 * lisp/gnus-namazu.el (gnus-namazu-summary-buffer-name): Changed diff --git a/lisp/gnus-namazu.el b/lisp/gnus-namazu.el index e0e3eb8..ea9d338 100644 --- a/lisp/gnus-namazu.el +++ b/lisp/gnus-namazu.el @@ -1,12 +1,10 @@ ;;; gnus-namazu.el --- Search mail with Namazu. -;; Copyright (C) 2000,2001 Tsuchiya Masatoshi +;; Copyright (C) 2000,2001,2002 Tsuchiya Masatoshi ;; Author: Tsuchiya Masatoshi ;; 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 @@ -27,9 +25,10 @@ ;;; 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/ @@ -39,7 +38,11 @@ ;; 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 diff --git a/lisp/nnshimbun.el b/lisp/nnshimbun.el index aaa5a3f..a4c8400 100644 --- a/lisp/nnshimbun.el +++ b/lisp/nnshimbun.el @@ -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))))) diff --git a/texi/gnus-ja.texi b/texi/gnus-ja.texi index c9de762..26116f0 100644 --- a/texi/gnus-ja.texi +++ b/texi/gnus-ja.texi @@ -14057,6 +14057,7 @@ Gnus $B$O!"A4$F$N%0%k!<%W$Nl9g$K$O!"FC$K!#$G$b!"BgDq$N>l9g!"2ACM$"$k5-;v$O$4$/>/?t$G!"$=$N(B +$B5-;v$rBgNL$N5-;v$N;3$+$i8+$D$1=P$9$N$O!"$H$F$b:$Fq$J$3$H$G$9!#(B + +$B$3$&$$$C$?$3$H$3$=!"%3%s%T%e!<%?$,$7$F$/$l$k$Y$-;E;v$G$9$h$M!#(BGnus $B$O!"(B +Namazu $B$r;H$C$F!"%a!<%k$N;3$+$i$"$J$?$N9%$-$J%-!<%o!<%I$r4^$`5-;v$r8+(B +$B$D$1=P$9J}K!$rDs6!$7$^$9!#(B + +$B:G=i$KHa$7$$$*CN$i$;$,$R$H$D!#(B@file{gnus-namazu.el} $B$O!"8=;~E@$G$O!"(B +@code{nnml} $B%P%C%/%(%s%I$"$k$$$O(B @code{nnmh} $B%P%C%/%(%s%I$K$h$C$FJ]B8(B +$B$5$l$F$$$k5-;v$H!"(B@code{gnus-cache-enter-article} $B$K$h$C$F1JB32=$5$l$?(B +$B5-;v$7$+!"$7$F!"$^$:!"(BNamazu $B$r;H$($k$h$&$K$7$^$7$g$&!#>\$7$$(B +$B$3$H$O!"A[%0%k!<%W$r:n@.$7$^$9(B(@xref{Virtual +Groups})$B!#(B + +@kbd{C-c C-n}$B$K$h$C$F8F$S=P$5$l$kL?Na(B @code{gnus-namazu-search} $B$O!"(B +gnus $B$NDL>o$N?t;z@\F,<-$d!"%W%m%;%9@\F,<-$rM}2r$7$^$9!#$G$9$+$i!"$"$J(B +$B$?$,!"$"$k%0%k!<%W$@$1$rBP>]$H$7$F8!:w$rl9g!"8!:w(B +$BBP>]$O!"<+F0E*$K$=$N%0%k!<%W$K8BDj$5$l$^$9!#Nc$($P!"$"$J$?$,$"$k%0%k!<(B +$B%W$r1\MwCf$K!"$=$N%0%k!<%W$K$*$1$k<+J,$N2a5n$r?6$jJV$j$?$/$J$C$?$i!"