aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-11-29 04:23:49 +0000
committerGlenn Morris2007-11-29 04:23:49 +0000
commit122bcd7ef24fbf416f339dc093d0bf59bbb1ed5b (patch)
tree1e1877682937cf2fb2822f9493d2117f659c5140
parent4bb6c266e4c36335826f4668076ec72af74a3971 (diff)
downloademacs-122bcd7ef24fbf416f339dc093d0bf59bbb1ed5b.tar.gz
emacs-122bcd7ef24fbf416f339dc093d0bf59bbb1ed5b.zip
(check-declare-locate, check-declare-verify): Handle `external' files.
(check-declare-errmsg): New function. (check-declare-verify, check-declare-file, check-declare-directory): Use check-declare-errmsg to report the number of problems.
-rw-r--r--lisp/emacs-lisp/check-declare.el68
1 files changed, 49 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el
index d98b59d774e..5d2ee740e4b 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -48,22 +48,31 @@
48Expands files with a \".c\" extension relative to the Emacs 48Expands files with a \".c\" extension relative to the Emacs
49\"src/\" directory. Otherwise, `locate-library' searches for FILE. 49\"src/\" directory. Otherwise, `locate-library' searches for FILE.
50If that fails, expands FILE relative to BASEFILE's directory part. 50If that fails, expands FILE relative to BASEFILE's directory part.
51The returned file might not exist." 51The returned file might not exist. If FILE has an \"ext:\" prefix, so does
52 (if (string-equal "c" (file-name-extension file)) 52the result."
53 (expand-file-name file (expand-file-name "src" source-directory)) 53 (let ((ext (string-match "^ext:" file))
54 (let ((tfile (locate-library (file-name-nondirectory file)))) 54 tfile)
55 (if tfile 55 (if ext
56 (progn 56 (setq file (substring file 4)))
57 (setq tfile (replace-regexp-in-string "\\.elc\\'" ".el" tfile)) 57 (setq file
58 (if (and (not (file-exists-p tfile)) 58 (if (string-equal "c" (file-name-extension file))
59 (file-exists-p (concat tfile ".gz"))) 59 (expand-file-name file (expand-file-name "src" source-directory))
60 (concat tfile ".gz") 60 (if (setq tfile (locate-library (file-name-nondirectory file)))
61 tfile)) 61 (progn
62 (setq tfile (expand-file-name file (file-name-directory basefile))) 62 (setq tfile
63 (if (or (file-exists-p tfile) 63 (replace-regexp-in-string "\\.elc\\'" ".el" tfile))
64 (string-match "\\.el\\'" tfile)) 64 (if (and (not (file-exists-p tfile))
65 tfile 65 (file-exists-p (concat tfile ".gz")))
66 (concat tfile ".el")))))) 66 (concat tfile ".gz")
67 tfile))
68 (setq tfile (expand-file-name file
69 (file-name-directory basefile)))
70 (if (or (file-exists-p tfile)
71 (string-match "\\.el\\'" tfile))
72 tfile
73 (concat tfile ".el")))))
74 (if ext (concat "ext:" file)
75 file)))
67 76
68(defun check-declare-scan (file) 77(defun check-declare-scan (file)
69 "Scan FILE for `declare-function' calls. 78 "Scan FILE for `declare-function' calls.
@@ -93,6 +102,19 @@ ARGLIST may be absent. This claims that FNFILE defines FN, with ARGLIST."
93 (message "%sdone" m) 102 (message "%sdone" m)
94 alist)) 103 alist))
95 104
105(defun check-declare-errmsg (errlist &optional full)
106 "Return a string with the number of errors in ERRLIST, if any.
107Normally just counts the number of elements in ERRLIST.
108With optional argument FULL, sums the number of elements in each element."
109 (if errlist
110 (let ((l (length errlist)))
111 (when full
112 (setq l 0)
113 (dolist (e errlist)
114 (setq l (1+ l))))
115 (format "%d problem%s found" l (if (= l 1) "" "s")))
116 "OK"))
117
96(autoload 'byte-compile-arglist-signature "bytecomp") 118(autoload 'byte-compile-arglist-signature "bytecomp")
97 119
98(defun check-declare-verify (fnfile fnlist) 120(defun check-declare-verify (fnfile fnlist)
@@ -104,8 +126,11 @@ found to be true, otherwise a list of errors with elements of the form
104\(FILE FN TYPE), where TYPE is a string giving details of the error." 126\(FILE FN TYPE), where TYPE is a string giving details of the error."
105 (let ((m (format "Checking %s..." fnfile)) 127 (let ((m (format "Checking %s..." fnfile))
106 (cflag (string-equal "c" (file-name-extension fnfile))) 128 (cflag (string-equal "c" (file-name-extension fnfile)))
129 (ext (string-match "^ext:" fnfile))
107 re fn sig siglist arglist type errlist minargs maxargs) 130 re fn sig siglist arglist type errlist minargs maxargs)
108 (message "%s" m) 131 (message "%s" m)
132 (if ext
133 (setq fnfile (substring fnfile 4)))
109 (if (file-exists-p fnfile) 134 (if (file-exists-p fnfile)
110 (with-temp-buffer 135 (with-temp-buffer
111 (insert-file-contents fnfile) 136 (insert-file-contents fnfile)
@@ -185,7 +210,12 @@ ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\
185 "arglist mismatch"))))) 210 "arglist mismatch")))))
186 (when type 211 (when type
187 (setq errlist (cons (list (car e) (cadr e) type) errlist)))) 212 (setq errlist (cons (list (car e) (cadr e) type) errlist))))
188 (message "%s%s" m (if errlist "problems found" "OK")) 213 (message "%s%s" m
214 (if (or re (not ext))
215 (check-declare-errmsg errlist)
216 (prog1
217 "skipping external file"
218 (setq errlist nil))))
189 errlist)) 219 errlist))
190 220
191(defun check-declare-sort (alist) 221(defun check-declare-sort (alist)
@@ -244,7 +274,7 @@ See `check-declare-directory' for more information."
244 errlist) 274 errlist)
245 (message "%s" m) 275 (message "%s" m)
246 (setq errlist (check-declare-files file)) 276 (setq errlist (check-declare-files file))
247 (message "%s%s" m (if errlist "problems found" "OK")) 277 (message "%s%s" m (check-declare-errmsg errlist))
248 errlist)) 278 errlist))
249 279
250;;;###autoload 280;;;###autoload
@@ -267,7 +297,7 @@ described in the documentation of `declare-function'."
267 (message "%s%d found" m2 (length files)) 297 (message "%s%d found" m2 (length files))
268 (when files 298 (when files
269 (setq errlist (apply 'check-declare-files files)) 299 (setq errlist (apply 'check-declare-files files))
270 (message "%s%s" m (if errlist "problems found" "OK")) 300 (message "%s%s" m (check-declare-errmsg errlist t))
271 errlist))) 301 errlist)))
272 302
273(provide 'check-declare) 303(provide 'check-declare)