Mercurial > emacs
comparison lisp/emacs-lisp/elint.el @ 111425:9ee34f35bd15
Silence elint compilation.
* lisp/emacs-lisp/elint.el (elint-init-env): Prefix dynamic local `env'.
(elint-init-form): Update for above name change.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 06 Nov 2010 12:40:33 -0700 |
parents | 2da9673fc448 |
children | 417b1e4d63cd |
comparison
equal
deleted
inserted
replaced
111424:e8807c0f5742 | 111425:9ee34f35bd15 |
---|---|
392 "Find the next top form from point. | 392 "Find the next top form from point. |
393 Return nil if there are no more forms, t otherwise." | 393 Return nil if there are no more forms, t otherwise." |
394 (parse-partial-sexp (point) (point-max) nil t) | 394 (parse-partial-sexp (point) (point-max) nil t) |
395 (not (eobp))) | 395 (not (eobp))) |
396 | 396 |
397 (defvar env) ; from elint-init-env | 397 (defvar elint-env) ; from elint-init-env |
398 | 398 |
399 (defun elint-init-form (form) | 399 (defun elint-init-form (form) |
400 "Process FORM, adding to ENV if recognized." | 400 "Process FORM, adding to ELINT-ENV if recognized." |
401 (cond | 401 (cond |
402 ;; Eg nnmaildir seems to use [] as a form of comment syntax. | 402 ;; Eg nnmaildir seems to use [] as a form of comment syntax. |
403 ((not (listp form)) | 403 ((not (listp form)) |
404 (elint-warning "Skipping non-list form `%s'" form)) | 404 (elint-warning "Skipping non-list form `%s'" form)) |
405 ;; Add defined variable | 405 ;; Add defined variable |
406 ((memq (car form) '(defvar defconst defcustom)) | 406 ((memq (car form) '(defvar defconst defcustom)) |
407 (setq env (elint-env-add-var env (cadr form)))) | 407 (setq elint-env (elint-env-add-var elint-env (cadr form)))) |
408 ;; Add function | 408 ;; Add function |
409 ((memq (car form) '(defun defsubst)) | 409 ((memq (car form) '(defun defsubst)) |
410 (setq env (elint-env-add-func env (cadr form) (nth 2 form)))) | 410 (setq elint-env (elint-env-add-func elint-env (cadr form) (nth 2 form)))) |
411 ;; FIXME needs a handler to say second arg is not a variable when we come | 411 ;; FIXME needs a handler to say second arg is not a variable when we come |
412 ;; to scan the form. | 412 ;; to scan the form. |
413 ((eq (car form) 'define-derived-mode) | 413 ((eq (car form) 'define-derived-mode) |
414 (setq env (elint-env-add-func env (cadr form) ()) | 414 (setq elint-env (elint-env-add-func elint-env (cadr form) ()) |
415 env (elint-env-add-var env (cadr form)) | 415 elint-env (elint-env-add-var elint-env (cadr form)) |
416 env (elint-env-add-var env (intern (format "%s-map" (cadr form)))))) | 416 elint-env (elint-env-add-var elint-env |
417 (intern (format "%s-map" (cadr form)))))) | |
417 ((eq (car form) 'define-minor-mode) | 418 ((eq (car form) 'define-minor-mode) |
418 (setq env (elint-env-add-func env (cadr form) '(&optional arg)) | 419 (setq elint-env (elint-env-add-func elint-env (cadr form) '(&optional arg)) |
419 ;; FIXME mode map? | 420 ;; FIXME mode map? |
420 env (elint-env-add-var env (cadr form)))) | 421 elint-env (elint-env-add-var elint-env (cadr form)))) |
421 ((and (eq (car form) 'easy-menu-define) | 422 ((and (eq (car form) 'easy-menu-define) |
422 (cadr form)) | 423 (cadr form)) |
423 (setq env (elint-env-add-func env (cadr form) '(event)) | 424 (setq elint-env (elint-env-add-func elint-env (cadr form) '(event)) |
424 env (elint-env-add-var env (cadr form)))) | 425 elint-env (elint-env-add-var elint-env (cadr form)))) |
425 ;; FIXME it would be nice to check the autoloads are correct. | 426 ;; FIXME it would be nice to check the autoloads are correct. |
426 ((eq (car form) 'autoload) | 427 ((eq (car form) 'autoload) |
427 (setq env (elint-env-add-func env (cadr (cadr form)) 'unknown))) | 428 (setq elint-env (elint-env-add-func elint-env (cadr (cadr form)) 'unknown))) |
428 ((eq (car form) 'declare-function) | 429 ((eq (car form) 'declare-function) |
429 (setq env (elint-env-add-func | 430 (setq elint-env (elint-env-add-func |
430 env (cadr form) | 431 elint-env (cadr form) |
431 (if (or (< (length form) 4) | 432 (if (or (< (length form) 4) |
432 (eq (nth 3 form) t) | 433 (eq (nth 3 form) t) |
433 (unless (stringp (nth 2 form)) | 434 (unless (stringp (nth 2 form)) |
434 (elint-error "Malformed declaration for `%s'" | 435 (elint-error "Malformed declaration for `%s'" |
435 (cadr form)) | 436 (cadr form)) |
438 (nth 3 form))))) | 439 (nth 3 form))))) |
439 ((and (eq (car form) 'defalias) (listp (nth 2 form))) | 440 ((and (eq (car form) 'defalias) (listp (nth 2 form))) |
440 ;; If the alias points to something already in the environment, | 441 ;; If the alias points to something already in the environment, |
441 ;; add the alias to the environment with the same arguments. | 442 ;; add the alias to the environment with the same arguments. |
442 ;; FIXME symbol-function, eg backquote.el? | 443 ;; FIXME symbol-function, eg backquote.el? |
443 (let ((def (elint-env-find-func env (cadr (nth 2 form))))) | 444 (let ((def (elint-env-find-func elint-env (cadr (nth 2 form))))) |
444 (setq env (elint-env-add-func env (cadr (cadr form)) | 445 (setq elint-env (elint-env-add-func elint-env (cadr (cadr form)) |
445 (if def (cadr def) 'unknown))))) | 446 (if def (cadr def) 'unknown))))) |
446 ;; Add macro, both as a macro and as a function | 447 ;; Add macro, both as a macro and as a function |
447 ((eq (car form) 'defmacro) | 448 ((eq (car form) 'defmacro) |
448 (setq env (elint-env-add-macro env (cadr form) | 449 (setq elint-env (elint-env-add-macro elint-env (cadr form) |
449 (cons 'lambda (cddr form))) | 450 (cons 'lambda (cddr form))) |
450 env (elint-env-add-func env (cadr form) (nth 2 form)))) | 451 elint-env (elint-env-add-func elint-env (cadr form) (nth 2 form)))) |
451 ((and (eq (car form) 'put) | 452 ((and (eq (car form) 'put) |
452 (= 4 (length form)) | 453 (= 4 (length form)) |
453 (eq (car-safe (cadr form)) 'quote) | 454 (eq (car-safe (cadr form)) 'quote) |
454 (equal (nth 2 form) '(quote error-conditions))) | 455 (equal (nth 2 form) '(quote error-conditions))) |
455 (set (make-local-variable 'elint-extra-errors) | 456 (set (make-local-variable 'elint-extra-errors) |
469 ;; We need cl if elint-form is to be able to expand cl macros. | 470 ;; We need cl if elint-form is to be able to expand cl macros. |
470 (require 'cl) | 471 (require 'cl) |
471 (setq name 'cl-macs | 472 (setq name 'cl-macs |
472 file nil | 473 file nil |
473 elint-doing-cl t)) ; blech | 474 elint-doing-cl t)) ; blech |
474 (setq env (elint-add-required-env env name file)))))) | 475 (setq elint-env (elint-add-required-env elint-env name file)))))) |
475 env) | 476 elint-env) |
476 | 477 |
477 (defun elint-init-env (forms) | 478 (defun elint-init-env (forms) |
478 "Initialize the environment from FORMS." | 479 "Initialize the environment from FORMS." |
479 (let ((env (elint-make-env)) | 480 (let ((elint-env (elint-make-env)) |
480 form) | 481 form) |
481 (while forms | 482 (while forms |
482 (setq form (elint-top-form-form (car forms)) | 483 (setq form (elint-top-form-form (car forms)) |
483 forms (cdr forms)) | 484 forms (cdr forms)) |
484 ;; FIXME eval-when-compile should be treated differently (macros). | 485 ;; FIXME eval-when-compile should be treated differently (macros). |
487 (if (memq (car-safe form) | 488 (if (memq (car-safe form) |
488 '(eval-and-compile eval-when-compile progn prog1 prog2 | 489 '(eval-and-compile eval-when-compile progn prog1 prog2 |
489 with-no-warnings)) | 490 with-no-warnings)) |
490 (mapc 'elint-init-form (cdr form)) | 491 (mapc 'elint-init-form (cdr form)) |
491 (elint-init-form form))) | 492 (elint-init-form form))) |
492 env)) | 493 elint-env)) |
493 | 494 |
494 (defun elint-add-required-env (env name file) | 495 (defun elint-add-required-env (env name file) |
495 "Augment ENV with the variables defined by feature NAME in FILE." | 496 "Augment ENV with the variables defined by feature NAME in FILE." |
496 (condition-case err | 497 (condition-case err |
497 (let* ((libname (if (stringp file) | 498 (let* ((libname (if (stringp file) |
1169 (cons f 'unknown)))) | 1170 (cons f 'unknown)))) |
1170 (or list (elint-find-builtins)))) | 1171 (or list (elint-find-builtins)))) |
1171 | 1172 |
1172 (provide 'elint) | 1173 (provide 'elint) |
1173 | 1174 |
1174 ;; arch-tag: b2f061e2-af84-4ddc-8e39-f5e969ac228f | |
1175 ;;; elint.el ends here | 1175 ;;; elint.el ends here |