Mercurial > emacs
comparison lisp/emacs-lisp/check-declare.el @ 86220:1244ab609a99
(check-declare-verify): If fnfile does not exist, try adding `.el'
extension. Also search for defsubsts.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 19 Nov 2007 00:09:20 +0000 |
parents | d5707b4c3b0f |
children | d6eda104caa6 |
comparison
equal
deleted
inserted
replaced
86219:16c8cf994132 | 86220:1244ab609a99 |
---|---|
27 ;; The byte-compiler often warns about undefined functions that you | 27 ;; The byte-compiler often warns about undefined functions that you |
28 ;; know will actually be defined when it matters. The `declare-function' | 28 ;; know will actually be defined when it matters. The `declare-function' |
29 ;; statement allows you to suppress these warnings. This package | 29 ;; statement allows you to suppress these warnings. This package |
30 ;; checks that all such statements in a file or directory are accurate. | 30 ;; checks that all such statements in a file or directory are accurate. |
31 ;; The entry points are `check-declare-file' and `check-declare-directory'. | 31 ;; The entry points are `check-declare-file' and `check-declare-directory'. |
32 | |
33 ;;; TODO: | |
34 | |
35 ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). | |
32 | 36 |
33 ;;; Code: | 37 ;;; Code: |
34 | 38 |
35 (defconst check-declare-warning-buffer "*Check Declarations Warnings*" | 39 (defconst check-declare-warning-buffer "*Check Declarations Warnings*" |
36 "Name of buffer used to display any `check-declare' warnings.") | 40 "Name of buffer used to display any `check-declare' warnings.") |
74 found to be true, otherwise a list of errors with elements of the form | 78 found to be true, otherwise a list of errors with elements of the form |
75 \(FILE FN TYPE), where TYPE is a string giving details of the error." | 79 \(FILE FN TYPE), where TYPE is a string giving details of the error." |
76 (let ((m (format "Checking %s..." fnfile)) | 80 (let ((m (format "Checking %s..." fnfile)) |
77 re fn sig siglist arglist type errlist) | 81 re fn sig siglist arglist type errlist) |
78 (message "%s" m) | 82 (message "%s" m) |
83 (or (file-exists-p fnfile) | |
84 (setq fnfile (concat fnfile ".el"))) | |
79 (if (file-exists-p fnfile) | 85 (if (file-exists-p fnfile) |
80 (with-temp-buffer | 86 (with-temp-buffer |
81 (insert-file-contents fnfile) | 87 (insert-file-contents fnfile) |
82 (setq re (format "^[ \t]*(defun[ \t]+%s\\>" | 88 ;; defsubst's don't _have_ to be known at compile time. |
89 (setq re (format "^[ \t]*(def\\(un\\|subst\\)[ \t]+%s\\>" | |
83 (regexp-opt (mapcar 'cadr fnlist) t))) | 90 (regexp-opt (mapcar 'cadr fnlist) t))) |
84 (while (re-search-forward re nil t) | 91 (while (re-search-forward re nil t) |
85 (skip-chars-forward " \t\n") | 92 (skip-chars-forward " \t\n") |
86 (setq fn (match-string 1) | 93 (setq fn (match-string 2) |
87 sig (if (looking-at "\\((\\|nil\\)") | 94 sig (if (looking-at "\\((\\|nil\\)") |
88 (byte-compile-arglist-signature | 95 (byte-compile-arglist-signature |
89 (read (current-buffer)))) | 96 (read (current-buffer)))) |
90 ;; alist of functions and arglist signatures. | 97 ;; alist of functions and arglist signatures. |
91 siglist (cons (cons fn sig) siglist))))) | 98 siglist (cons (cons fn sig) siglist))))) |