aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-11-21 09:03:16 +0000
committerGlenn Morris2007-11-21 09:03:16 +0000
commit2ae3bb8564e12902c7bdefe692de5292ea6a423d (patch)
treeb3fb54c4b018bf936738121d6c6b87a018851c47
parent99c715160b5a9907fab928095d445ccc580d81d3 (diff)
downloademacs-2ae3bb8564e12902c7bdefe692de5292ea6a423d.tar.gz
emacs-2ae3bb8564e12902c7bdefe692de5292ea6a423d.zip
(check-declare-verify): Skip C files for now. Handle
define-minor-mode, and defalias (with no argument checking).
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/check-declare.el90
2 files changed, 59 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6a8e8e75186..20a65f205f5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12007-11-21 Glenn Morris <rgm@gnu.org>
2
3 * emacs-lisp/check-declare.el (check-declare-verify): Skip C files
4 for now. Handle define-minor-mode, and defalias (with no argument
5 checking).
6
12007-11-21 Dan Nicolaescu <dann@ics.uci.edu> 72007-11-21 Dan Nicolaescu <dann@ics.uci.edu>
2 8
3 * frame.el (msdos-mouse-p): 9 * frame.el (msdos-mouse-p):
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el
index c3e41086599..76719f1b876 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -34,6 +34,8 @@
34 34
35;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). 35;; 1. Handle defstructs (eg uniquify-item-base in desktop.el).
36 36
37;; 2. Check C files (look in src/)?
38
37;;; Code: 39;;; Code:
38 40
39(defconst check-declare-warning-buffer "*Check Declarations Warnings*" 41(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 (let ((m (format "Checking %s..." fnfile)) 82 (let ((m (format "Checking %s..." fnfile))
81 re fn sig siglist arglist type errlist) 83 re fn sig siglist arglist type errlist)
82 (message "%s" m) 84 (message "%s" m)
83 (or (file-exists-p fnfile) 85 (if (string-equal (file-name-extension fnfile) "c")
84 (setq fnfile (concat fnfile ".el"))) 86 (progn
85 (if (file-exists-p fnfile) 87 (message "%sskipping C file" m)
86 (with-temp-buffer 88 nil)
87 (insert-file-contents fnfile) 89 (or (file-exists-p fnfile)
88 ;; defsubst's don't _have_ to be known at compile time. 90 (setq fnfile (concat fnfile ".el")))
89 (setq re (format "^[ \t]*(\\(def\\(?:un\\|subst\\|\ 91 (if (file-exists-p fnfile)
90ine-derived-mode\\)\\)\[ \t]+%s\\([ \t;]+\\|$\\)" 92 (with-temp-buffer
91 (regexp-opt (mapcar 'cadr fnlist) t))) 93 (insert-file-contents fnfile)
92 (while (re-search-forward re nil t) 94 ;; defsubst's don't _have_ to be known at compile time.
93 (skip-chars-forward " \t\n") 95 (setq re (format "^[ \t]*(\\(def\\(?:un\\|subst\\|\
94 (setq fn (match-string 2) 96ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\
95 sig (if (string-equal "define-derived-mode" 97\[ \t]*%s\\([ \t;]+\\|$\\)"
96 (match-string 1)) 98 (regexp-opt (mapcar 'cadr fnlist) t)))
97 '(0 . 0) 99 (while (re-search-forward re nil t)
98 (if (looking-at "\\((\\|nil\\)") 100 (skip-chars-forward " \t\n")
99 (byte-compile-arglist-signature 101 (setq fn (match-string 2)
100 (read (current-buffer))))) 102 sig (cond ((string-equal (match-string 1)
101 ;; alist of functions and arglist signatures. 103 "define-derived-mode")
102 siglist (cons (cons fn sig) siglist))))) 104 '(0 . 0))
103 (dolist (e fnlist) 105 ((string-equal (match-string 1)
104 (setq arglist (nth 2 e) 106 "define-minor-mode")
105 type 107 '(0 . 1))
106 (if re ; re non-nil means found a file 108 ;; Can't easily check alias arguments.
107 (if (setq sig (assoc (cadr e) siglist)) 109 ((string-equal (match-string 1)
108 ;; Recall we use t to mean no arglist specified, 110 "defalias")
109 ;; to distinguish from an empty arglist. 111 t)
110 (unless (eq arglist t) 112 (t
111 (unless (equal (byte-compile-arglist-signature arglist) 113 (if (looking-at "\\((\\|nil\\)")
112 (cdr sig)) 114 (byte-compile-arglist-signature
113 "arglist mismatch")) 115 (read (current-buffer))))))
114 "function not found") 116 ;; alist of functions and arglist signatures.
115 "file not found")) 117 siglist (cons (cons fn sig) siglist)))))
116 (when type 118 (dolist (e fnlist)
117 (setq errlist (cons (list (car e) (cadr e) type) errlist)))) 119 (setq arglist (nth 2 e)
118 (message "%s%s" m (if errlist "problems found" "OK")) 120 type
119 errlist)) 121 (if re ; re non-nil means found a file
122 (if (setq sig (assoc (cadr e) siglist))
123 ;; Recall we use t to mean no arglist specified,
124 ;; to distinguish from an empty arglist.
125 (unless (or (eq arglist t)
126 (eq sig t))
127 (unless (equal (byte-compile-arglist-signature arglist)
128 (cdr sig))
129 "arglist mismatch"))
130 "function not found")
131 "file not found"))
132 (when type
133 (setq errlist (cons (list (car e) (cadr e) type) errlist))))
134 (message "%s%s" m (if errlist "problems found" "OK"))
135 errlist)))
120 136
121(defun check-declare-sort (alist) 137(defun check-declare-sort (alist)
122 "Sort a list with elements FILE (FNFILE ...). 138 "Sort a list with elements FILE (FNFILE ...).