comparison lisp/emacs-lisp/check-declare.el @ 86342:79a4d6e44352

(check-declare-locate): New function. (check-declare-scan): Use check-declare-locate. (check-declare-verify): No longer adjust fnfile, now check-declare-locate does it.
author Glenn Morris <rgm@gnu.org>
date Thu, 22 Nov 2007 20:25:51 +0000
parents 9525bd421fdb
children b8e2c95bbb6e
comparison
equal deleted inserted replaced
86341:5a317f281e6c 86342:79a4d6e44352
36 36
37 ;;; Code: 37 ;;; Code:
38 38
39 (defconst check-declare-warning-buffer "*Check Declarations Warnings*" 39 (defconst check-declare-warning-buffer "*Check Declarations Warnings*"
40 "Name of buffer used to display any `check-declare' warnings.") 40 "Name of buffer used to display any `check-declare' warnings.")
41
42 (defun check-declare-locate (file basefile)
43 "Return the full path of FILE.
44 Expands files with a \".c\" extension relative to the Emacs
45 \"src/\" directory. Otherwise, `locate-library' searches for
46 FILE. If that fails, expands FILE relative to BASEFILE's
47 directory part. The returned file might not exist."
48 (if (string-equal "c" (file-name-extension file))
49 (expand-file-name file (expand-file-name "src" source-directory))
50 (let ((tfile (locate-library (file-name-nondirectory file))))
51 (if tfile
52 (replace-regexp-in-string "\\.elc\\'" ".el" tfile)
53 (setq tfile (expand-file-name file (file-name-directory basefile)))
54 (if (or (file-exists-p tfile)
55 (string-match "\\.el\\'" tfile))
56 tfile
57 (concat tfile ".el"))))))
41 58
42 (defun check-declare-scan (file) 59 (defun check-declare-scan (file)
43 "Scan FILE for `declare-function' calls. 60 "Scan FILE for `declare-function' calls.
44 Return a list with elements of the form (FNFILE FN ARGLIST), where 61 Return a list with elements of the form (FNFILE FN ARGLIST), where
45 ARGLIST may be absent. This claims that FNFILE defines FN, with ARGLIST." 62 ARGLIST may be absent. This claims that FNFILE defines FN, with ARGLIST."
50 (insert-file-contents file) 67 (insert-file-contents file)
51 (while (re-search-forward 68 (while (re-search-forward
52 "^[ \t]*(declare-function[ \t]+\\(\\S-+\\)[ \t]+\ 69 "^[ \t]*(declare-function[ \t]+\\(\\S-+\\)[ \t]+\
53 \"\\(\\S-+\\)\"" nil t) 70 \"\\(\\S-+\\)\"" nil t)
54 (setq fn (match-string 1) 71 (setq fn (match-string 1)
55 fnfile (match-string 2)) 72 fnfile (match-string 2)
56 (or (file-name-absolute-p fnfile) 73 fnfile (check-declare-locate fnfile (expand-file-name file))
57 (setq fnfile 74 alist (cons
58 (expand-file-name fnfile
59 ;; .c files are assumed to be
60 ;; relative to the Emacs src/ directory.
61 (if (string-equal
62 "c" (file-name-extension fnfile))
63 (expand-file-name "src"
64 source-directory)
65 (file-name-directory file)))))
66 (setq alist (cons
67 (list fnfile fn 75 (list fnfile fn
68 (progn 76 (progn
69 (skip-chars-forward " \t\n") 77 (skip-chars-forward " \t\n")
70 ;; Use `t' to distinguish no arglist 78 ;; Use `t' to distinguish no arglist
71 ;; specified from an empty one. 79 ;; specified from an empty one.
87 \(FILE FN TYPE), where TYPE is a string giving details of the error." 95 \(FILE FN TYPE), where TYPE is a string giving details of the error."
88 (let ((m (format "Checking %s..." fnfile)) 96 (let ((m (format "Checking %s..." fnfile))
89 (cflag (string-equal "c" (file-name-extension fnfile))) 97 (cflag (string-equal "c" (file-name-extension fnfile)))
90 re fn sig siglist arglist type errlist minargs maxargs) 98 re fn sig siglist arglist type errlist minargs maxargs)
91 (message "%s" m) 99 (message "%s" m)
92 (or cflag
93 (file-exists-p fnfile)
94 (setq fnfile (concat fnfile ".el")))
95 (if (file-exists-p fnfile) 100 (if (file-exists-p fnfile)
96 (with-temp-buffer 101 (with-temp-buffer
97 (insert-file-contents fnfile) 102 (insert-file-contents fnfile)
98 ;; defsubst's don't _have_ to be known at compile time. 103 ;; defsubst's don't _have_ to be known at compile time.
99 (setq re (format (if cflag 104 (setq re (format (if cflag