From: tsuchiya Date: Tue, 8 Jan 2002 07:32:44 +0000 (+0000) Subject: (gnus-namazu/highlight-words): Reimplemented. X-Git-Tag: t-gnus-6_15_4-11~8 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=50d08824478203e736b58ff0c8a39f62efc7f84c;p=elisp%2Fgnus.git- (gnus-namazu/highlight-words): Reimplemented. --- diff --git a/ChangeLog b/ChangeLog index f8e3b4c..fd77355 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-01-08 TSUCHIYA Masatoshi + + * lisp/gnus-namazu.el (gnus-namazu/highlight-words): Reimplemented. + 2002-01-08 Katsumi Yamaoka * lisp/nnheader.el (mail-narrow-to-head): Copy from ietf-drums.el; diff --git a/lisp/gnus-namazu.el b/lisp/gnus-namazu.el index f734338..a577798 100644 --- a/lisp/gnus-namazu.el +++ b/lisp/gnus-namazu.el @@ -1,4 +1,4 @@ -;;; gnus-namazu.el --- Search mail with Namazu. +;;; gnus-namazu.el --- Search mail with Namazu. -*- coding: iso-2022-7bit; -*- ;; Copyright (C) 2000,2001,2002 TSUCHIYA Masatoshi @@ -514,33 +514,34 @@ generate possible group names from it." '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))))) + (with-temp-buffer + (insert " " query) + ;; Remove tokens for NOT search + (goto-char (point-min)) + (while (re-search-forward "[  \t\r\f\n]+not[  \t\r\f\n]+\ +\\([^  \t\r\f\n\"{(/]+\\|\"[^\"]+\"\\|{[^}]+}\\|([^)]+)\\|/[^/]+/\\)+" nil t) + (delete-region (match-beginning 0) (match-end 0))) + ;; Remove tokens for Field search + (goto-char (point-min)) + (while (re-search-forward "[  \t\r\f\n]+\\+[^  \t\r\f\n:]+:\ +\\([^  \t\r\f\n\"{(/]+\\|\"[^\"]+\"\\|{[^}]+}\\|([^)]+)\\|/[^/]+/\\)+" nil t) + (delete-region (match-beginning 0) (match-end 0))) + ;; Remove tokens for Regexp search + (goto-char (point-min)) + (while (re-search-forward "/[^/]+/" nil t) + (delete-region (match-beginning 0) (match-end 0))) + ;; Remove brackets, double quote, asterisk and operators + (goto-char (point-min)) + (while (re-search-forward "\\([(){}\"*]\\|\\b\\(and\\|or\\)\\b\\)" nil t) + (delete-region (match-beginning 0) (match-end 0))) + ;; Collect all keywords + (setq query nil) + (goto-char (point-min)) + (while (re-search-forward "[^  \t\r\f\n]+" nil t) + (push (match-string 0) query)) + (when query + (list (list (regexp-opt query) + 0 0 'gnus-namazu-query-highlight-face))))) (defun gnus-namazu/truncate-article-list (articles) (let ((hit (length articles)))