Commit 2ae3bb85 authored by Glenn Morris's avatar Glenn Morris

(check-declare-verify): Skip C files for now. Handle

define-minor-mode, and defalias (with no argument checking).
parent 99c71516
2007-11-21 Glenn Morris <rgm@gnu.org>
* emacs-lisp/check-declare.el (check-declare-verify): Skip C files
for now. Handle define-minor-mode, and defalias (with no argument
checking).
2007-11-21 Dan Nicolaescu <dann@ics.uci.edu> 2007-11-21 Dan Nicolaescu <dann@ics.uci.edu>
* frame.el (msdos-mouse-p): * frame.el (msdos-mouse-p):
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el).
;; 2. Check C files (look in src/)?
;;; Code: ;;; Code:
(defconst check-declare-warning-buffer "*Check Declarations Warnings*" (defconst check-declare-warning-buffer "*Check Declarations Warnings*"
...@@ -80,43 +82,57 @@ found to be true, otherwise a list of errors with elements of the form ...@@ -80,43 +82,57 @@ found to be true, otherwise a list of errors with elements of the form
(let ((m (format "Checking %s..." fnfile)) (let ((m (format "Checking %s..." fnfile))
re fn sig siglist arglist type errlist) re fn sig siglist arglist type errlist)
(message "%s" m) (message "%s" m)
(or (file-exists-p fnfile) (if (string-equal (file-name-extension fnfile) "c")
(setq fnfile (concat fnfile ".el"))) (progn
(if (file-exists-p fnfile) (message "%sskipping C file" m)
(with-temp-buffer nil)
(insert-file-contents fnfile) (or (file-exists-p fnfile)
;; defsubst's don't _have_ to be known at compile time. (setq fnfile (concat fnfile ".el")))
(setq re (format "^[ \t]*(\\(def\\(?:un\\|subst\\|\ (if (file-exists-p fnfile)
ine-derived-mode\\)\\)\[ \t]+%s\\([ \t;]+\\|$\\)" (with-temp-buffer
(regexp-opt (mapcar 'cadr fnlist) t))) (insert-file-contents fnfile)
(while (re-search-forward re nil t) ;; defsubst's don't _have_ to be known at compile time.
(skip-chars-forward " \t\n") (setq re (format "^[ \t]*(\\(def\\(?:un\\|subst\\|\
(setq fn (match-string 2) ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\
sig (if (string-equal "define-derived-mode" \[ \t]*%s\\([ \t;]+\\|$\\)"
(match-string 1)) (regexp-opt (mapcar 'cadr fnlist) t)))
'(0 . 0) (while (re-search-forward re nil t)
(if (looking-at "\\((\\|nil\\)") (skip-chars-forward " \t\n")
(byte-compile-arglist-signature (setq fn (match-string 2)
(read (current-buffer))))) sig (cond ((string-equal (match-string 1)
;; alist of functions and arglist signatures. "define-derived-mode")
siglist (cons (cons fn sig) siglist))))) '(0 . 0))
(dolist (e fnlist) ((string-equal (match-string 1)
(setq arglist (nth 2 e) "define-minor-mode")
type '(0 . 1))
(if re ; re non-nil means found a file ;; Can't easily check alias arguments.
(if (setq sig (assoc (cadr e) siglist)) ((string-equal (match-string 1)
;; Recall we use t to mean no arglist specified, "defalias")
;; to distinguish from an empty arglist. t)
(unless (eq arglist t) (t
(unless (equal (byte-compile-arglist-signature arglist) (if (looking-at "\\((\\|nil\\)")
(cdr sig)) (byte-compile-arglist-signature
"arglist mismatch")) (read (current-buffer))))))
"function not found") ;; alist of functions and arglist signatures.
"file not found")) siglist (cons (cons fn sig) siglist)))))
(when type (dolist (e fnlist)
(setq errlist (cons (list (car e) (cadr e) type) errlist)))) (setq arglist (nth 2 e)
(message "%s%s" m (if errlist "problems found" "OK")) type
errlist)) (if re ; re non-nil means found a file
(if (setq sig (assoc (cadr e) siglist))
;; Recall we use t to mean no arglist specified,
;; to distinguish from an empty arglist.
(unless (or (eq arglist t)
(eq sig t))
(unless (equal (byte-compile-arglist-signature arglist)
(cdr sig))
"arglist mismatch"))
"function not found")
"file not found"))
(when type
(setq errlist (cons (list (car e) (cadr e) type) errlist))))
(message "%s%s" m (if errlist "problems found" "OK"))
errlist)))
(defun check-declare-sort (alist) (defun check-declare-sort (alist)
"Sort a list with elements FILE (FNFILE ...). "Sort a list with elements FILE (FNFILE ...).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment