aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-10-02 02:47:57 +0000
committerKarl Heuer1997-10-02 02:47:57 +0000
commit7f0feddae256983d4ee6d694ce3f7dab771a837c (patch)
tree1efcbbbf7d4e71bf3fd937f653f6ba49d57f7243
parentcafba8996c7690c1d482d76ae11ea4b0ac2a6dc9 (diff)
downloademacs-7f0feddae256983d4ee6d694ce3f7dab771a837c.tar.gz
emacs-7f0feddae256983d4ee6d694ce3f7dab771a837c.zip
(elint-check-defcustom-form): New function.
(elint-special-forms): Use it.
-rw-r--r--lisp/emacs-lisp/elint.el37
1 files changed, 23 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el
index 6b66759948c..d6c5ed3a29c 100644
--- a/lisp/emacs-lisp/elint.el
+++ b/lisp/emacs-lisp/elint.el
@@ -145,7 +145,7 @@ This environment can be passed to `macroexpand'."
145 ;; ** top form ** header... 145 ;; ** top form ** header...
146 (let ((elint-top-form-logged t)) 146 (let ((elint-top-form-logged t))
147 (elint-log-message "\nLinting complete.\n"))) 147 (elint-log-message "\nLinting complete.\n")))
148 148
149(defun elint-defun () 149(defun elint-defun ()
150 "Lint the function at point." 150 "Lint the function at point."
151 (interactive) 151 (interactive)
@@ -193,7 +193,7 @@ Returns the forms."
193 (elint-init-env elint-buffer-forms)) 193 (elint-init-env elint-buffer-forms))
194 (set (make-local-variable 'elint-last-env-time) (buffer-modified-tick)) 194 (set (make-local-variable 'elint-last-env-time) (buffer-modified-tick))
195 elint-buffer-forms)) 195 elint-buffer-forms))
196 196
197(defun elint-get-top-forms () 197(defun elint-get-top-forms ()
198 "Collect all the top forms in the current buffer." 198 "Collect all the top forms in the current buffer."
199 (save-excursion 199 (save-excursion
@@ -271,7 +271,7 @@ Returns nil if there are no more forms, T otherwise."
271 (ding) 271 (ding)
272 (message "Can't get variables from require'd library %s" name))) 272 (message "Can't get variables from require'd library %s" name)))
273 env) 273 env)
274 274
275(defun regexp-assoc (regexp alist) 275(defun regexp-assoc (regexp alist)
276 "Search for a key matching REGEXP in ALIST." 276 "Search for a key matching REGEXP in ALIST."
277 (let ((res nil)) 277 (let ((res nil))
@@ -312,11 +312,11 @@ Returns nil if there are no more forms, T otherwise."
312 (defmacro . elint-check-defun-form) 312 (defmacro . elint-check-defun-form)
313 (defvar . elint-check-defvar-form) 313 (defvar . elint-check-defvar-form)
314 (defconst . elint-check-defvar-form) 314 (defconst . elint-check-defvar-form)
315 (defcustom . elint-check-defvar-form) 315 (defcustom . elint-check-defcustom-form)
316 (macro . elint-check-macro-form) 316 (macro . elint-check-macro-form)
317 (condition-case . elint-check-condition-case-form)) 317 (condition-case . elint-check-condition-case-form))
318 "Functions to call when some special form should be linted.") 318 "Functions to call when some special form should be linted.")
319 319
320(defun elint-form (form env) 320(defun elint-form (form env)
321 "Lint FORM in the environment ENV. 321 "Lint FORM in the environment ENV.
322The environment created by the form is returned." 322The environment created by the form is returned."
@@ -334,9 +334,9 @@ The environment created by the form is returned."
334 ((eq args 'undefined) 334 ((eq args 'undefined)
335 (setq argsok nil) 335 (setq argsok nil)
336 (elint-error "Call to undefined function: %s" form)) 336 (elint-error "Call to undefined function: %s" form))
337 337
338 ((eq args 'unknown) nil) 338 ((eq args 'unknown) nil)
339 339
340 (t (setq argsok (elint-match-args form args)))) 340 (t (setq argsok (elint-match-args form args))))
341 341
342 ;; Is this a macro? 342 ;; Is this a macro?
@@ -526,7 +526,7 @@ CODE can be a lambda expression, a macro, or byte-compiled code."
526 (if (symbolp sym) 526 (if (symbolp sym)
527 (setq newenv (elint-env-add-var newenv sym)))) 527 (setq newenv (elint-env-add-var newenv sym))))
528 newenv)) 528 newenv))
529 529
530(defun elint-check-defvar-form (form env) 530(defun elint-check-defvar-form (form env)
531 "Lint the defvar/defconst FORM in ENV." 531 "Lint the defvar/defconst FORM in ENV."
532 (if (or (= (length form) 2) 532 (if (or (= (length form) 2)
@@ -536,7 +536,16 @@ CODE can be a lambda expression, a macro, or byte-compiled code."
536 (car (cdr form))) 536 (car (cdr form)))
537 (elint-error "Malformed variable declaration: %s" form) 537 (elint-error "Malformed variable declaration: %s" form)
538 env)) 538 env))
539 539
540(defun elint-check-defcustom-form (form env)
541 "Lint the defcustom FORM in ENV."
542 (if (and (> (length form) 3)
543 (evenp (length form))) ; even no. of keyword/value args
544 (elint-env-add-global-var (elint-form (nth 2 form) env)
545 (car (cdr form)))
546 (elint-error "Malformed variable declaration: %s" form)
547 env))
548
540(defun elint-check-function-form (form env) 549(defun elint-check-function-form (form env)
541 "Lint the function FORM in ENV." 550 "Lint the function FORM in ENV."
542 (let ((func (car (cdr-safe form)))) 551 (let ((func (car (cdr-safe form))))
@@ -591,7 +600,7 @@ CODE can be a lambda expression, a macro, or byte-compiled code."
591 (setq errforms (cdr errforms)) 600 (setq errforms (cdr errforms))
592 ))) 601 )))
593 resenv)) 602 resenv))
594 603
595;;; 604;;;
596;;; Message functions 605;;; Message functions
597;;; 606;;;
@@ -605,7 +614,7 @@ STRING and ARGS are thrown on `format' to get the message."
605 (let ((errstr (apply 'format string args))) 614 (let ((errstr (apply 'format string args)))
606 (elint-log-message errstr) 615 (elint-log-message errstr)
607 )) 616 ))
608 617
609(defun elint-warning (string &rest args) 618(defun elint-warning (string &rest args)
610 "Report an linting warning. 619 "Report an linting warning.
611STRING and ARGS are thrown on `format' to get the message." 620STRING and ARGS are thrown on `format' to get the message."
@@ -668,11 +677,11 @@ Insert HEADER followed by a blank line if non-nil."
668 (setq truncate-lines t) 677 (setq truncate-lines t)
669 (set-buffer oldbuf))) 678 (set-buffer oldbuf)))
670 ))) 679 )))
671 680
672;;; 681;;;
673;;; Initializing code 682;;; Initializing code
674;;; 683;;;
675 684
676;;;###autoload 685;;;###autoload
677(defun elint-initialize () 686(defun elint-initialize ()
678 "Initialize elint." 687 "Initialize elint."
@@ -733,7 +742,7 @@ If no documentation could be found args will be `unknown'."
733 point-before-scroll require-final-newline selective-display 742 point-before-scroll require-final-newline selective-display
734 selective-display-ellipses tab-width truncate-lines vc-mode) 743 selective-display-ellipses tab-width truncate-lines vc-mode)
735 "Standard buffer local vars.") 744 "Standard buffer local vars.")
736 745
737(defconst elint-unknown-builtin-args 746(defconst elint-unknown-builtin-args
738 '((while test &rest forms) 747 '((while test &rest forms)
739 (insert-before-markers-and-inherit &rest text) 748 (insert-before-markers-and-inherit &rest text)