Function: gnus-score-check-syntax

gnus-score-check-syntax is a byte-compiled function defined in gnus-score.el.gz.

Signature

(gnus-score-check-syntax ALIST FILE)

Documentation

Check the syntax of the score ALIST.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-score.el.gz
(defun gnus-score-check-syntax (alist file)
  "Check the syntax of the score ALIST."
  (cond
   ((null alist)
    nil)
   ((not (consp alist))
    (gnus-message 1 "Score file is not a list: %s" file)
    (ding)
    nil)
   (t
    (let ((a alist)
	  sr err s type)
      (while (and a (not err))
	(setq
	 err
	 (cond
	  ((not (listp (car a)))
	   (format "Invalid score element %s in %s" (car a) file))
	  ((stringp (caar a))
	   (cond
	    ((not (listp (setq sr (cdar a))))
	     (format "Invalid header match %s in %s" (nth 1 (car a)) file))
	    (t
	     (setq type (caar a))
	     (while (and sr (not err))
	       (setq s (pop sr))
	       (setq
		err
		(cond
		 ((cond ((member (downcase type) '("lines" "chars"))
			 (not (numberp (car s))))
			((string= (downcase type) "date")
			 (not (or (numberp (car s))
				  (stringp (car s)))))
			(t (not (stringp (car s)))))
		  (format "Invalid match %s in %s" (car s) file))
		 ((and (cadr s) (not (integerp (cadr s))))
		  (format "Non-integer score %s in %s" (cadr s) file))
		 ((and (caddr s) (not (integerp (caddr s))))
		  (format "Non-integer date %s in %s" (caddr s) file))
		 ((and (cadddr s) (not (symbolp (cadddr s))))
		  (format "Non-symbol match type %s in %s" (cadddr s) file)))))
	     err)))))
	(setq a (cdr a)))
      (if err
	  (progn
	    (ding)
	    (gnus-message 3 "%s" err)
	    (sit-for 2)
	    nil)
	alist)))))