"Spam ifile configuration."
:group 'spam)
-(defcustom spam-ifile-path (executable-find "ifile")
- "File path of the ifile executable program."
+(defcustom spam-ifile-program (executable-find "ifile")
+ "Name of the ifile program."
:type '(choice (file :tag "Location of ifile")
(const :tag "ifile is not installed"))
:group 'spam-ifile)
+(make-obsolete-variable 'spam-ifile-path 'spam-ifile-program)
+;; "22.1" ;; Gnus 5.10.9
-(defcustom spam-ifile-database-path nil
- "File path of the ifile database."
+(defcustom spam-ifile-database nil
+ "File name of the ifile database."
:type '(choice (file :tag "Location of the ifile database")
(const :tag "Use the default"))
:group 'spam-ifile)
+(make-obsolete-variable 'spam-ifile-database-path 'spam-ifile-database)
+;; "22.1" ;; Gnus 5.10.9
(defcustom spam-ifile-spam-category "spam"
"Name of the spam ifile category."
"Spam bogofilter configuration."
:group 'spam)
-(defcustom spam-bogofilter-path (executable-find "bogofilter")
- "File path of the Bogofilter executable program."
+(defcustom spam-bogofilter-program (executable-find "bogofilter")
+ "Name of the Bogofilter program."
:type '(choice (file :tag "Location of bogofilter")
(const :tag "Bogofilter is not installed"))
:group 'spam-bogofilter)
+(make-obsolete-variable 'spam-bogofilter-path 'spam-bogofilter-program)
+;; "22.1" ;; Gnus 5.10.9
(defvar spam-bogofilter-valid 'unknown "Is the bogofilter version valid?")
:group 'spam-bogofilter)
(defcustom spam-bogofilter-database-directory nil
- "Directory path of the Bogofilter databases."
+ "Location of the Bogofilter database.
+When nil, use the default location."
:type '(choice (directory
:tag "Location of the Bogofilter database directory")
(const :tag "Use the default"))
spam-use-spamassassin-headers
spam-use-regex-headers)
(push 'X-Spam-Status list))
- (when spam-use-bogofilter
+ (when (or spam-use-bogofilter
+ spam-use-regex-headers)
(push 'X-Bogosity list))
+ (when (or spam-use-crm114
+ spam-use-regex-headers)
+ (push 'X-CRM114-Status list))
list))
(defun spam-user-format-function-S (headers)
".*\\b\\(?:score\\|hits\\)=\\(-?[0-9.]+\\)"
"Regexp matching SpamAssassin score header.
The first group must match the number.")
-;; "score" for Spamassassin 3.0 or later:
-;; X-Spam-Status: Yes, score=13.1 required=5.0 tests=DNS_FROM_RFC_ABUSE,
-;; [...],UNDISC_RECIPS autolearn=disabled version=3.0.3
-
(defun spam-extra-header-to-number (header headers)
"Transform an extra HEADER to a number, using list of HEADERS.
Note this has to be fast."
- (if (gnus-extra-header header headers)
- (cond
- ((eq header 'X-Spam-Status)
- (string-to-number (gnus-replace-in-string
- (gnus-extra-header header headers)
- spam-spamassassin-score-regexp
- "\\1")))
- ;; for CRM checking, it's probably faster to just do the string match
- ((and spam-use-crm114 (string-match "( pR: \\([0-9.-]+\\)" header))
- (match-string 1 header))
- ((eq header 'X-Bogosity)
- (string-to-number (gnus-replace-in-string
- (gnus-replace-in-string
- (gnus-extra-header header headers)
- ".*spamicity=" "")
- ",.*" "")))
- (t nil))
- nil))
+ (let ((header-content (gnus-extra-header header headers)))
+ (if header-content
+ (cond
+ ((eq header 'X-Spam-Status)
+ (string-to-number (gnus-replace-in-string
+ header-content
+ spam-spamassassin-score-regexp
+ "\\1")))
+ ;; for CRM checking, it's probably faster to just do the string match
+ ((string-match "( pR: \\([0-9.-]+\\)" header-content)
+ (- (string-to-number (match-string 1 header-content))))
+ ((eq header 'X-Bogosity)
+ (string-to-number (gnus-replace-in-string
+ (gnus-replace-in-string
+ header-content
+ ".*spamicity=" "")
+ ",.*" "")))
+ (t nil))
+ nil)))
(defun spam-summary-score (headers &optional specific-header)
"Score an article for the summary buffer, as fast as possible.
;;; check the ifile backend; return nil if the mail was NOT classified
;;; as spam
+
(defun spam-get-ifile-database-parameter ()
- "Get the command-line parameter for ifile's database from
- spam-ifile-database-path."
- (if spam-ifile-database-path
- (format "--db-file=%s" spam-ifile-database-path)
+ "Return the command-line parameter for ifile's database.
+See `spam-ifile-database'."
+ (if spam-ifile-database
+ (format "--db-file=%s" spam-ifile-database)
nil))
(defun spam-check-ifile ()
(save-excursion
(set-buffer article-buffer-name)
(apply 'call-process-region
- (point-min) (point-max) spam-ifile-path
+ (point-min) (point-max) spam-ifile-program
nil temp-buffer-name nil "-c"
(if db-param `(,db-param "-q") `("-q"))))
;; check the return now (we're back in the temp buffer)
(when (stringp article-string)
(insert article-string))))
(apply 'call-process-region
- (point-min) (point-max) spam-ifile-path
+ (point-min) (point-max) spam-ifile-program
nil nil nil
add-or-delete-option category
(if db `(,db "-h") `("-h"))))))
(setq spam-bogofilter-valid
(not (string-match "^bogofilter version 0\\.\\([0-9]\\|1[01]\\)\\."
(shell-command-to-string
- (format "%s -V" spam-bogofilter-path))))))
+ (format "%s -V" spam-bogofilter-program))))))
spam-bogofilter-valid)
(defun spam-check-bogofilter (&optional score)
(set-buffer article-buffer-name)
(apply 'call-process-region
(point-min) (point-max)
- spam-bogofilter-path
+ spam-bogofilter-program
nil temp-buffer-name nil
(if db `("-d" ,db "-v") `("-v"))))
(setq return (spam-check-bogofilter-headers score))))
(apply 'call-process-region
(point-min) (point-max)
- spam-bogofilter-path
+ spam-bogofilter-program
nil nil nil switch
(if db `("-d" ,db "-v") `("-v")))))))
(gnus-error 5 "`spam.el' doesn't support obsolete bogofilter versions")))