;;; gnus-kill.el --- kill commands for Gnus
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;; Code:
(require 'gnus)
-
-(defvar gnus-kill-file-mode-hook nil
- "*A hook for Gnus kill file mode.")
-
-(defvar gnus-kill-expiry-days 7
- "*Number of days before expiring unused kill file entries.")
-
-(defvar gnus-kill-save-kill-file nil
- "*If non-nil, will save kill files after processing them.")
-
-(defvar gnus-winconf-kill-file nil)
+(require 'gnus-art)
+(require 'gnus-range)
+
+(defcustom gnus-kill-file-mode-hook nil
+ "Hook for Gnus kill file mode."
+ :group 'gnus-score-kill
+ :type 'hook)
+
+(defcustom gnus-kill-expiry-days 7
+ "*Number of days before expiring unused kill file entries."
+ :group 'gnus-score-kill
+ :group 'gnus-score-expire
+ :type 'integer)
+
+(defcustom gnus-kill-save-kill-file nil
+ "*If non-nil, will save kill files after processing them."
+ :group 'gnus-score-kill
+ :type 'boolean)
+
+(defcustom gnus-winconf-kill-file nil
+ "What does this do, Lars?"
+ :group 'gnus-score-kill
+ :type 'sexp)
+
+(defcustom gnus-kill-killed t
+ "*If non-nil, Gnus will apply kill files to already killed articles.
+If it is nil, Gnus will never apply kill files to articles that have
+already been through the scoring process, which might very well save lots
+of time."
+ :group 'gnus-score-kill
+ :type 'boolean)
\f
(defmacro gnus-raise (field expression level)
- (` (gnus-kill (, field) (, expression)
- (function (gnus-summary-raise-score (, level))) t)))
+ `(gnus-kill ,field ,expression
+ (function (gnus-summary-raise-score ,level)) t))
(defmacro gnus-lower (field expression level)
- (` (gnus-kill (, field) (, expression)
- (function (gnus-summary-raise-score (- (, level)))) t)))
+ `(gnus-kill ,field ,expression
+ (function (gnus-summary-raise-score (- ,level))) t))
;;;
;;; Gnus Kill File Mode
(defvar gnus-kill-file-mode-map nil)
-(if gnus-kill-file-mode-map
- nil
- (setq gnus-kill-file-mode-map (copy-keymap emacs-lisp-mode-map))
- (define-key gnus-kill-file-mode-map
- "\C-c\C-k\C-s" 'gnus-kill-file-kill-by-subject)
- (define-key gnus-kill-file-mode-map
- "\C-c\C-k\C-a" 'gnus-kill-file-kill-by-author)
- (define-key gnus-kill-file-mode-map
- "\C-c\C-k\C-t" 'gnus-kill-file-kill-by-thread)
- (define-key gnus-kill-file-mode-map
- "\C-c\C-k\C-x" 'gnus-kill-file-kill-by-xref)
- (define-key gnus-kill-file-mode-map
- "\C-c\C-a" 'gnus-kill-file-apply-buffer)
- (define-key gnus-kill-file-mode-map
- "\C-c\C-e" 'gnus-kill-file-apply-last-sexp)
- (define-key gnus-kill-file-mode-map
- "\C-c\C-c" 'gnus-kill-file-exit))
+(unless gnus-kill-file-mode-map
+ (gnus-define-keymap (setq gnus-kill-file-mode-map
+ (copy-keymap emacs-lisp-mode-map))
+ "\C-c\C-k\C-s" gnus-kill-file-kill-by-subject
+ "\C-c\C-k\C-a" gnus-kill-file-kill-by-author
+ "\C-c\C-k\C-t" gnus-kill-file-kill-by-thread
+ "\C-c\C-k\C-x" gnus-kill-file-kill-by-xref
+ "\C-c\C-a" gnus-kill-file-apply-buffer
+ "\C-c\C-e" gnus-kill-file-apply-last-sexp
+ "\C-c\C-c" gnus-kill-file-exit))
(defun gnus-kill-file-mode ()
"Major mode for editing kill files.
does this easily for non-Lisp programmers.
The `gnus-kill' function executes commands available in Summary Mode
-by their key sequences. `gnus-kill' should be called with FIELD,
+by their key sequences. `gnus-kill' should be called with FIELD,
REGEXP and optional COMMAND and ALL. FIELD is a string representing
the header field or an empty string. If FIELD is an empty string, the
entire article body is searched for. REGEXP is a string which is
-compared with FIELD value. COMMAND is a string representing a valid
-key sequence in Summary mode or Lisp expression. COMMAND defaults to
+compared with FIELD value. COMMAND is a string representing a valid
+key sequence in Summary mode or Lisp expression. COMMAND defaults to
'(gnus-summary-mark-as-read nil \"X\"). Make sure that COMMAND is
executed in the Summary buffer. If the second optional argument ALL
is non-nil, the COMMAND is applied to articles which are already
(gnus-kill-file-mode)
(bury-buffer buffer)))
-(defun gnus-kill-file-enter-kill (field regexp)
+(defun gnus-kill-file-enter-kill (field regexp &optional dont-move)
;; Enter kill file entry.
;; FIELD: String containing the name of the header field to kill.
;; REGEXP: The string to kill.
(save-excursion
(let (string)
- (or (eq major-mode 'gnus-kill-file-mode)
- (gnus-kill-set-kill-buffer))
- (current-buffer)
- (goto-char (point-max))
+ (unless (eq major-mode 'gnus-kill-file-mode)
+ (gnus-kill-set-kill-buffer))
+ (unless dont-move
+ (goto-char (point-max)))
(insert (setq string (format "(gnus-kill %S %S)\n" field regexp)))
(gnus-kill-file-apply-string string))))
-
+
(defun gnus-kill-file-kill-by-subject ()
"Kill by subject."
(interactive)
(gnus-kill-file-enter-kill
- "Subject"
+ "Subject"
(if (vectorp gnus-current-headers)
- (regexp-quote
+ (regexp-quote
(gnus-simplify-subject (mail-header-subject gnus-current-headers)))
- "")))
-
+ "")
+ t))
+
(defun gnus-kill-file-kill-by-author ()
"Kill by author."
(interactive)
(gnus-kill-file-enter-kill
- "From"
+ "From"
(if (vectorp gnus-current-headers)
(regexp-quote (mail-header-from gnus-current-headers))
- "")))
-
+ "") t))
+
(defun gnus-kill-file-kill-by-thread ()
"Kill by author."
- (interactive "p")
+ (interactive)
(gnus-kill-file-enter-kill
- "References"
+ "References"
(if (vectorp gnus-current-headers)
(regexp-quote (mail-header-id gnus-current-headers))
"")))
-
+
(defun gnus-kill-file-kill-by-xref ()
"Kill by Xref."
(interactive)
- (let ((xref (and (vectorp gnus-current-headers)
+ (let ((xref (and (vectorp gnus-current-headers)
(mail-header-xref gnus-current-headers)))
(start 0)
group)
(if xref
(while (string-match " \\([^ \t]+\\):" xref start)
(setq start (match-end 0))
- (if (not (string=
- (setq group
- &nbs