From: tsuchiya Date: Fri, 4 Jan 2002 16:38:54 +0000 (+0000) Subject: * lisp/gnus-namazu.el (gnus-namazu-query-highlight): New option. X-Git-Tag: t-gnus-6_15_4-09-quimby-last-~3 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8576b2c80f8af5baf0b73cebf1e62038692bea44;p=elisp%2Fgnus.git- * 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. --- diff --git a/ChangeLog b/ChangeLog index ec47f97..09219c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-01-05 TSUCHIYA Masatoshi + + * 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 * lisp/dgnushack.el (dgnushack-bind-colon-keywords): Ignore @@ -140,7 +155,7 @@ * 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.AN_johann +2001-11-26 Kai GroN_johann * make-x.bat: Use parameter "/copy" rather than "copy" for increased dwimishness for old-time DOS users. From Frank Schmitt diff --git a/lisp/gnus-namazu.el b/lisp/gnus-namazu.el index e0e3eb8..0a5d6bb 100644 --- a/lisp/gnus-namazu.el +++ b/lisp/gnus-namazu.el @@ -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 diff --git a/texi/gnus-ja.texi b/texi/gnus-ja.texi index 6304918..a01598a 100644 --- a/texi/gnus-ja.texi +++ b/texi/gnus-ja.texi @@ -15086,8 +15086,9 @@ Namazu $B$r;H$C$F!"%a!<%k$N;3$+$i$"$J$?$N9%$-$J%-!<%o!<%I$r4^$`5-;v$r8+(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$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 +$BC5$7=P$7!"$=$l$i$N%a!<%k$+$i$J$k2>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 @@ -23032,6 +23034,8 @@ Gnus $B$O(B Emacs Lisp $B$K$h$C$F=q$+$l$F$$$F!"$=$l$O$?$/$5$s$NC`