-(defsubst elsp-bsfilter-list-spam-files (targets)
- (apply
- #'call-process
- elmo-spam-bsfilter-shell-program
- nil
- (list t (if elmo-spam-bsfilter-debug
- (get-buffer-create "*Debug ELMO Bsfilter*")))
- nil
- (append (if elmo-spam-bsfilter-shell-switch
- (list elmo-spam-bsfilter-shell-switch))
- (list elmo-spam-bsfilter-program "--list-spam")
- elmo-spam-bsfilter-args
- (if elmo-spam-bsfilter-database-directory
- (list "--homedir" elmo-spam-bsfilter-database-directory))
- targets)))
+(defun elsp-bsfilter-list-spam-filter (process output)
+ (when (buffer-live-p (process-buffer process))
+ (with-current-buffer (process-buffer process)
+ (save-excursion
+ (goto-char (process-mark process))
+ (insert output)
+ (set-marker (process-mark process) (point)))
+ (while (re-search-forward "^combined probability.+\r?\n" nil t)
+ (delete-region (match-beginning 0) (match-end 0))
+ (elmo-progress-notify 'elmo-spam-check-spam))
+ (when elmo-spam-bsfilter-debug
+ (with-current-buffer (get-buffer-create "*Debug ELMO Bsfilter*")
+ (goto-char (point-max))
+ (insert output))))))
+
+(defsubst elsp-bsfilter-start-list-spam (targets)
+ (let ((process
+ (apply #'start-process
+ "elsp-bsfilter"
+ (current-buffer)
+ elmo-spam-bsfilter-shell-program
+ (append (if elmo-spam-bsfilter-shell-switch
+ (list elmo-spam-bsfilter-shell-switch))
+ (if elmo-spam-bsfilter-program
+ (list elmo-spam-bsfilter-program))
+ elmo-spam-bsfilter-args
+ (list "--list-spam")
+ (if elmo-spam-bsfilter-database-directory
+ (list "--homedir"
+ elmo-spam-bsfilter-database-directory))
+ targets))))
+ (set-process-filter process #'elsp-bsfilter-list-spam-filter)
+ process))
+
+(defsubst elsp-bsfilter-read-list-spam (results hash)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (let* ((filename (buffer-substring (point) (save-excursion
+ (end-of-line)
+ (point))))
+ (number (elmo-get-hash-val filename hash)))
+ (when number
+ (setq results (cons number results)))
+ (forward-line)))
+ results)