Mercurial > emacs
annotate lisp/emacs-lisp/check-declare.el @ 110523:a5ad4f188e19
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 18 Sep 2010 22:49:54 -0400 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
86178 | 1 ;;; check-declare.el --- Check declare-function statements |
2 | |
106815 | 3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
86178 | 4 |
5 ;; Author: Glenn Morris <rgm@gnu.org> | |
6 ;; Keywords: lisp, tools, maint | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94459
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
86178 | 11 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94459
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94459
diff
changeset
|
13 ;; (at your option) any later version. |
86178 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94459
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
86178 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; The byte-compiler often warns about undefined functions that you | |
26 ;; know will actually be defined when it matters. The `declare-function' | |
27 ;; statement allows you to suppress these warnings. This package | |
28 ;; checks that all such statements in a file or directory are accurate. | |
29 ;; The entry points are `check-declare-file' and `check-declare-directory'. | |
30 | |
86388 | 31 ;; For more information, see Info node `elisp(Declaring Functions)'. |
32 | |
86220
1244ab609a99
(check-declare-verify): If fnfile does not exist, try adding `.el'
Glenn Morris <rgm@gnu.org>
parents:
86178
diff
changeset
|
33 ;;; TODO: |
1244ab609a99
(check-declare-verify): If fnfile does not exist, try adding `.el'
Glenn Morris <rgm@gnu.org>
parents:
86178
diff
changeset
|
34 |
87260
4cd2a938a117
(check-declare-verify): Handle deffoo.
Glenn Morris <rgm@gnu.org>
parents:
86841
diff
changeset
|
35 ;; 1. Warn about functions marked as obsolete, eg |
4cd2a938a117
(check-declare-verify): Handle deffoo.
Glenn Morris <rgm@gnu.org>
parents:
86841
diff
changeset
|
36 ;; password-read-and-add in smime.el. |
105280
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
37 ;; 2. defmethod, defclass argument checking. |
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
38 ;; 3. defclass also defines -p and -child-p. |
87260
4cd2a938a117
(check-declare-verify): Handle deffoo.
Glenn Morris <rgm@gnu.org>
parents:
86841
diff
changeset
|
39 |
86178 | 40 ;;; Code: |
41 | |
42 (defconst check-declare-warning-buffer "*Check Declarations Warnings*" | |
43 "Name of buffer used to display any `check-declare' warnings.") | |
44 | |
86342
79a4d6e44352
(check-declare-locate): New function.
Glenn Morris <rgm@gnu.org>
parents:
86302
diff
changeset
|
45 (defun check-declare-locate (file basefile) |
79a4d6e44352
(check-declare-locate): New function.
Glenn Morris <rgm@gnu.org>
parents:
86302
diff
changeset
|
46 "Return the full path of FILE. |
96696
b4b1fe2990a7
(check-declare-locate, check-declare-verify): Handle .m files.
Glenn Morris <rgm@gnu.org>
parents:
94655
diff
changeset
|
47 Expands files with a \".c\" or \".m\" extension relative to the Emacs |
86528
db04d9e790f1
(check-declare-locate): Reflow doc.
Glenn Morris <rgm@gnu.org>
parents:
86457
diff
changeset
|
48 \"src/\" directory. Otherwise, `locate-library' searches for FILE. |
db04d9e790f1
(check-declare-locate): Reflow doc.
Glenn Morris <rgm@gnu.org>
parents:
86457
diff
changeset
|
49 If that fails, expands FILE relative to BASEFILE's directory part. |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
50 The returned file might not exist. If FILE has an \"ext:\" prefix, so does |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
51 the result." |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
52 (let ((ext (string-match "^ext:" file)) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
53 tfile) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
54 (if ext |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
55 (setq file (substring file 4))) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
56 (setq file |
96696
b4b1fe2990a7
(check-declare-locate, check-declare-verify): Handle .m files.
Glenn Morris <rgm@gnu.org>
parents:
94655
diff
changeset
|
57 (if (member (file-name-extension file) '("c" "m")) |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
58 (expand-file-name file (expand-file-name "src" source-directory)) |
105277
7f2b90c428b4
(check-declare-locate): Remove pointless file-name-nondirectory call
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
59 (if (setq tfile (locate-library file)) |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
60 (progn |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
61 (setq tfile |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
62 (replace-regexp-in-string "\\.elc\\'" ".el" tfile)) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
63 (if (and (not (file-exists-p tfile)) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
64 (file-exists-p (concat tfile ".gz"))) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
65 (concat tfile ".gz") |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
66 tfile)) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
67 (setq tfile (expand-file-name file |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
68 (file-name-directory basefile))) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
69 (if (or (file-exists-p tfile) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
70 (string-match "\\.el\\'" tfile)) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
71 tfile |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
72 (concat tfile ".el"))))) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
73 (if ext (concat "ext:" file) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
74 file))) |
86342
79a4d6e44352
(check-declare-locate): New function.
Glenn Morris <rgm@gnu.org>
parents:
86302
diff
changeset
|
75 |
86178 | 76 (defun check-declare-scan (file) |
77 "Scan FILE for `declare-function' calls. | |
86841
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
78 Return a list with elements of the form (FNFILE FN ARGLIST FILEONLY), |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
79 where only the first two elements need be present. This claims that FNFILE |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
80 defines FN, with ARGLIST. FILEONLY non-nil means only check that FNFILE |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
81 exists, not that it defines FN. This is for function definitions that we |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
82 don't know how to recognize (e.g. some macros)." |
86178 | 83 (let ((m (format "Scanning %s..." file)) |
105316
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
84 alist form len fn fnfile arglist fileonly) |
86178 | 85 (message "%s" m) |
86 (with-temp-buffer | |
87 (insert-file-contents file) | |
105316
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
88 ;; FIXME we could theoretically be inside a string. |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
89 (while (re-search-forward "^[ \t]*\\((declare-function\\)[ \t\n]" nil t) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
90 (goto-char (match-beginning 1)) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
91 (if (and (setq form (ignore-errors (read (current-buffer))) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
92 len (length form)) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
93 (> len 2) (< len 6) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
94 (symbolp (setq fn (cadr form))) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
95 (setq fn (symbol-name fn)) ; later we use as a search string |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
96 (stringp (setq fnfile (nth 2 form))) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
97 (setq fnfile (check-declare-locate fnfile |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
98 (expand-file-name file))) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
99 ;; Use `t' to distinguish unspecified arglist from empty one. |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
100 (or (eq t (setq arglist (if (> len 3) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
101 (nth 3 form) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
102 t))) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
103 (listp arglist)) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
104 (symbolp (setq fileonly (nth 4 form)))) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
105 (setq alist (cons (list fnfile fn arglist fileonly) alist)) |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
106 ;; FIXME make this more noticeable. |
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
107 (message "Malformed declaration for `%s'" (cadr form))))) |
86178 | 108 (message "%sdone" m) |
109 alist)) | |
110 | |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
111 (defun check-declare-errmsg (errlist &optional full) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
112 "Return a string with the number of errors in ERRLIST, if any. |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
113 Normally just counts the number of elements in ERRLIST. |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
114 With optional argument FULL, sums the number of elements in each element." |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
115 (if errlist |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
116 (let ((l (length errlist))) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
117 (when full |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
118 (setq l 0) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
119 (dolist (e errlist) |
94459
e7a38a8c4a05
(check-declare-errmsg): Fix counting in the `full' case.
Glenn Morris <rgm@gnu.org>
parents:
88085
diff
changeset
|
120 (setq l (+ l (1- (length e)))))) |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
121 (format "%d problem%s found" l (if (= l 1) "" "s"))) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
122 "OK")) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
123 |
86178 | 124 (autoload 'byte-compile-arglist-signature "bytecomp") |
125 | |
126 (defun check-declare-verify (fnfile fnlist) | |
127 "Check that FNFILE contains function definitions matching FNLIST. | |
86841
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
128 Each element of FNLIST has the form (FILE FN ARGLIST FILEONLY), where |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
129 only the first two elements need be present. This means FILE claimed FN |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
130 was defined in FNFILE with the specified ARGLIST. FILEONLY non-nil means |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
131 to only check that FNFILE exists, not that it actually defines FN. |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
132 |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
133 Returns nil if all claims are found to be true, otherwise a list |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
134 of errors with elements of the form \(FILE FN TYPE), where TYPE |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
135 is a string giving details of the error." |
86178 | 136 (let ((m (format "Checking %s..." fnfile)) |
96696
b4b1fe2990a7
(check-declare-locate, check-declare-verify): Handle .m files.
Glenn Morris <rgm@gnu.org>
parents:
94655
diff
changeset
|
137 (cflag (member (file-name-extension fnfile) '("c" "m"))) |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
138 (ext (string-match "^ext:" fnfile)) |
86300
96fee69c65a2
(check-declare-verify): Implement arglist checking for C files.
Glenn Morris <rgm@gnu.org>
parents:
86297
diff
changeset
|
139 re fn sig siglist arglist type errlist minargs maxargs) |
86178 | 140 (message "%s" m) |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
141 (if ext |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
142 (setq fnfile (substring fnfile 4))) |
105316
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
143 (if (file-regular-p fnfile) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
144 (with-temp-buffer |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
145 (insert-file-contents fnfile) |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
146 ;; defsubst's don't _have_ to be known at compile time. |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
147 (setq re (format (if cflag |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
148 "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" |
87260
4cd2a938a117
(check-declare-verify): Handle deffoo.
Glenn Morris <rgm@gnu.org>
parents:
86841
diff
changeset
|
149 "^[ \t]*(\\(fset[ \t]+'\\|\ |
105280
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
150 def\\(?:un\\|subst\\|foo\\|method\\|class\\|\ |
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
151 ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\\|\ |
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
152 \\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\ |
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
153 ine-overloadable-function\\)\\)\ |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
154 \[ \t]*%s\\([ \t;]+\\|$\\)") |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
155 (regexp-opt (mapcar 'cadr fnlist) t))) |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
156 (while (re-search-forward re nil t) |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
157 (skip-chars-forward " \t\n") |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
158 (setq fn (match-string 2) |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
159 type (match-string 1) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
160 ;; (min . max) for a fixed number of arguments, or |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
161 ;; arglists with optional elements. |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
162 ;; (min) for arglists with &rest. |
86302
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
163 ;; sig = 'err means we could not find an arglist. |
86300
96fee69c65a2
(check-declare-verify): Implement arglist checking for C files.
Glenn Morris <rgm@gnu.org>
parents:
86297
diff
changeset
|
164 sig (cond (cflag |
86302
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
165 (or |
105277
7f2b90c428b4
(check-declare-locate): Remove pointless file-name-nondirectory call
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
166 (when (search-forward "," nil t 3) |
86302
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
167 (skip-chars-forward " \t\n") |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
168 ;; Assuming minargs and maxargs on same line. |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
169 (when (looking-at "\\([0-9]+\\)[ \t]*,[ \t]*\ |
86300
96fee69c65a2
(check-declare-verify): Implement arglist checking for C files.
Glenn Morris <rgm@gnu.org>
parents:
86297
diff
changeset
|
170 \\([0-9]+\\|MANY\\|UNEVALLED\\)") |
86302
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
171 (setq minargs (string-to-number |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
172 (match-string 1)) |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
173 maxargs (match-string 2)) |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
174 (cons minargs (unless (string-match "[^0-9]" |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
175 maxargs) |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
176 (string-to-number |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
177 maxargs))))) |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
178 'err)) |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
179 ((string-match |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
180 "\\`define-\\(derived\\|generic\\)-mode\\'" |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
181 type) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
182 '(0 . 0)) |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
183 ((string-match |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
184 "\\`define\\(-global\\(ized\\)?\\)?-minor-mode\\'" |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
185 type) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
186 '(0 . 1)) |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
187 ;; Prompt to update. |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
188 ((string-match |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
189 "\\`define-obsolete-function-alias\\>" |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
190 type) |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
191 'obsolete) |
86528
db04d9e790f1
(check-declare-locate): Reflow doc.
Glenn Morris <rgm@gnu.org>
parents:
86457
diff
changeset
|
192 ;; Can't easily check arguments in these cases. |
105280
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
193 ((string-match "\\`\\(def\\(alias\\|\ |
24b278c5dc72
(check-declare-verify): Add basic defmethod and defclass, and
Glenn Morris <rgm@gnu.org>
parents:
105277
diff
changeset
|
194 method\\|class\\)\\|fset\\)\\>" type) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
195 t) |
86302
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
196 ((looking-at "\\((\\|nil\\)") |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
197 (byte-compile-arglist-signature |
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
198 (read (current-buffer)))) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
199 (t |
86302
9525bd421fdb
(check-declare-verify): Fix previous change. Warn if could not find
Glenn Morris <rgm@gnu.org>
parents:
86300
diff
changeset
|
200 'err)) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
201 ;; alist of functions and arglist signatures. |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
202 siglist (cons (cons fn sig) siglist))))) |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
203 (dolist (e fnlist) |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
204 (setq arglist (nth 2 e) |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
205 type |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
206 (if (not re) |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
207 "file not found" |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
208 (if (not (setq sig (assoc (cadr e) siglist))) |
86841
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
209 (unless (nth 3 e) ; fileonly |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
210 "function not found") |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
211 (setq sig (cdr sig)) |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
212 (cond ((eq sig 'obsolete) ; check even when no arglist specified |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
213 "obsolete alias") |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
214 ;; arglist t means no arglist specified, as |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
215 ;; opposed to an empty arglist. |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
216 ((eq arglist t) nil) |
86528
db04d9e790f1
(check-declare-locate): Reflow doc.
Glenn Morris <rgm@gnu.org>
parents:
86457
diff
changeset
|
217 ((eq sig t) nil) ; eg defalias - can't check arguments |
86457
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
218 ((eq sig 'err) |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
219 "arglist not found") ; internal error |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
220 ((not (equal (byte-compile-arglist-signature |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
221 arglist) |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
222 sig)) |
47fc5bc30170
(check-declare-locate): Handle compressed files.
Glenn Morris <rgm@gnu.org>
parents:
86388
diff
changeset
|
223 "arglist mismatch"))))) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
224 (when type |
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
225 (setq errlist (cons (list (car e) (cadr e) type) errlist)))) |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
226 (message "%s%s" m |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
227 (if (or re (not ext)) |
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
228 (check-declare-errmsg errlist) |
86841
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
229 (progn |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
230 (setq errlist nil) |
885c9731dd1d
(check-declare-scan): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
86810
diff
changeset
|
231 "skipping external file"))) |
86297
a80b13d94c3c
(check-declare-scan): Expand .c files relative to src/ directory.
Glenn Morris <rgm@gnu.org>
parents:
86278
diff
changeset
|
232 errlist)) |
86178 | 233 |
234 (defun check-declare-sort (alist) | |
235 "Sort a list with elements FILE (FNFILE ...). | |
236 Returned list has elements FNFILE (FILE ...)." | |
237 (let (file fnfile rest sort a) | |
238 (dolist (e alist) | |
239 (setq file (car e)) | |
240 (dolist (f (cdr e)) | |
241 (setq fnfile (car f) | |
242 rest (cdr f)) | |
243 (if (setq a (assoc fnfile sort)) | |
244 (setcdr a (append (cdr a) (list (cons file rest)))) | |
245 (setq sort (cons (list fnfile (cons file rest)) sort))))) | |
246 sort)) | |
247 | |
248 (defun check-declare-warn (file fn fnfile type) | |
249 "Warn that FILE made a false claim about FN in FNFILE. | |
250 TYPE is a string giving the nature of the error. Warning is displayed in | |
251 `check-declare-warning-buffer'." | |
252 (display-warning 'check-declare | |
253 (format "%s said `%s' was defined in %s: %s" | |
254 (file-name-nondirectory file) fn | |
255 (file-name-nondirectory fnfile) | |
256 type) | |
257 nil check-declare-warning-buffer)) | |
258 | |
259 (defun check-declare-files (&rest files) | |
260 "Check veracity of all `declare-function' statements in FILES. | |
261 Return a list of any errors found." | |
262 (let (alist err errlist) | |
263 (dolist (file files) | |
264 (setq alist (cons (cons file (check-declare-scan file)) alist))) | |
265 ;; Sort so that things are ordered by the files supposed to | |
266 ;; contain the defuns. | |
267 (dolist (e (check-declare-sort alist)) | |
268 (if (setq err (check-declare-verify (car e) (cdr e))) | |
269 (setq errlist (cons (cons (car e) err) errlist)))) | |
270 (if (get-buffer check-declare-warning-buffer) | |
271 (kill-buffer check-declare-warning-buffer)) | |
272 ;; Sort back again so that errors are ordered by the files | |
273 ;; containing the declare-function statements. | |
274 (dolist (e (check-declare-sort errlist)) | |
275 (dolist (f (cdr e)) | |
276 (check-declare-warn (car e) (cadr f) (car f) (nth 2 f)))) | |
277 errlist)) | |
278 | |
279 ;;;###autoload | |
280 (defun check-declare-file (file) | |
281 "Check veracity of all `declare-function' statements in FILE. | |
282 See `check-declare-directory' for more information." | |
283 (interactive "fFile to check: ") | |
284 (or (file-exists-p file) | |
285 (error "File `%s' not found" file)) | |
286 (let ((m (format "Checking %s..." file)) | |
287 errlist) | |
288 (message "%s" m) | |
289 (setq errlist (check-declare-files file)) | |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
290 (message "%s%s" m (check-declare-errmsg errlist)) |
86178 | 291 errlist)) |
292 | |
293 ;;;###autoload | |
294 (defun check-declare-directory (root) | |
295 "Check veracity of all `declare-function' statements under directory ROOT. | |
105316
3d13129b958c
(check-declare-scan): Read the declaration rather than parsing it as a
Glenn Morris <rgm@gnu.org>
parents:
105280
diff
changeset
|
296 Returns non-nil if any false statements are found." |
86178 | 297 (interactive "DDirectory to check: ") |
298 (or (file-directory-p (setq root (expand-file-name root))) | |
299 (error "Directory `%s' not found" root)) | |
300 (let ((m "Checking `declare-function' statements...") | |
301 (m2 "Finding files with declarations...") | |
302 errlist files) | |
303 (message "%s" m) | |
304 (message "%s" m2) | |
88085
f4834ccd5bce
(check-declare-directory): Use `find-program' and
Juanma Barranquero <lekktu@gmail.com>
parents:
87665
diff
changeset
|
305 (setq files (process-lines find-program root |
f4834ccd5bce
(check-declare-directory): Use `find-program' and
Juanma Barranquero <lekktu@gmail.com>
parents:
87665
diff
changeset
|
306 "-name" "*.el" |
f4834ccd5bce
(check-declare-directory): Use `find-program' and
Juanma Barranquero <lekktu@gmail.com>
parents:
87665
diff
changeset
|
307 "-exec" grep-program |
f4834ccd5bce
(check-declare-directory): Use `find-program' and
Juanma Barranquero <lekktu@gmail.com>
parents:
87665
diff
changeset
|
308 "-l" "^[ \t]*(declare-function" "{}" ";")) |
86178 | 309 (message "%s%d found" m2 (length files)) |
310 (when files | |
311 (setq errlist (apply 'check-declare-files files)) | |
86810
bf4a9f989c37
(check-declare-locate, check-declare-verify): Handle `external' files.
Glenn Morris <rgm@gnu.org>
parents:
86528
diff
changeset
|
312 (message "%s%s" m (check-declare-errmsg errlist t)) |
86178 | 313 errlist))) |
314 | |
315 (provide 'check-declare) | |
316 | |
317 ;; arch-tag: a4d6cdc4-deb7-4502-b327-0e4ef3d82d96 | |
318 ;;; check-declare.el ends here. |