2001-07-16 12:23:00 +00:00
|
|
|
|
;;; elint.el --- Lint Emacs Lisp
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
2009-02-24 03:32:19 +00:00
|
|
|
|
;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
|
|
|
|
;; 2009 Free Software Foundation, Inc.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Peter Liljenberg <petli@lysator.liu.se>
|
|
|
|
|
;; Created: May 1997
|
|
|
|
|
;; Keywords: lisp
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; This is a linter for Emacs Lisp. Currently, it mainly catches
|
|
|
|
|
;; misspellings and undefined variables, although it can also catch
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; function calls with the wrong number of arguments.
|
|
|
|
|
|
2009-07-24 03:52:42 +00:00
|
|
|
|
;; To use, call elint-current-buffer or elint-defun to lint a buffer
|
|
|
|
|
;; or defun. The first call runs `elint-initialize' to set up some
|
|
|
|
|
;; argument data, which may take a while.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
;; The linter will try to "include" any require'd libraries to find
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; the variables defined in those. There is a fair amount of voodoo
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; involved in this, but it seems to work in normal situations.
|
|
|
|
|
|
|
|
|
|
;;; To do:
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; * List of variables and functions defined in dumped lisp files.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; * Adding type checking. (Stop that sniggering!)
|
2009-09-12 02:41:39 +00:00
|
|
|
|
;; * Handle eval-when-compile (eg for requires, being sensitive to the
|
|
|
|
|
;; difference between funcs and macros).
|
|
|
|
|
;; * Requires within function bodies.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(defvar elint-log-buffer "*Elint*"
|
|
|
|
|
"*The buffer to insert lint messages in.")
|
|
|
|
|
|
2004-12-13 19:34:46 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; Data
|
|
|
|
|
;;;
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
|
|
|
|
|
;; FIXME does this serve any useful purpose now elint-builtin-variables exists?
|
|
|
|
|
(defconst elint-standard-variables '(local-write-file-hooks vc-mode)
|
|
|
|
|
"Standard buffer local variables, excluding `elint-builtin-variables'.")
|
|
|
|
|
|
|
|
|
|
(defvar elint-builtin-variables nil
|
|
|
|
|
"List of built-in variables. Set by `elint-initialize'.")
|
|
|
|
|
|
|
|
|
|
(defvar elint-autoloaded-variables nil
|
|
|
|
|
"List of `loaddefs.el' variables. Set by `elint-initialize'.")
|
|
|
|
|
|
|
|
|
|
;; FIXME dumped variables and functions.
|
|
|
|
|
|
|
|
|
|
(defconst elint-unknown-builtin-args nil
|
|
|
|
|
"Those built-ins for which we can't find arguments, if any.")
|
|
|
|
|
|
|
|
|
|
(defconst elint-extra-errors '(file-locked file-supersession ftp-error)
|
|
|
|
|
"Errors without error-message or error-confitions properties.")
|
2004-12-13 19:34:46 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; ADT: top-form
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defsubst elint-make-top-form (form pos)
|
|
|
|
|
"Create a top form.
|
|
|
|
|
FORM is the form, and POS is the point where it starts in the buffer."
|
|
|
|
|
(cons form pos))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-top-form-form (top-form)
|
|
|
|
|
"Extract the form from a TOP-FORM."
|
|
|
|
|
(car top-form))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-top-form-pos (top-form)
|
|
|
|
|
"Extract the position from a TOP-FORM."
|
|
|
|
|
(cdr top-form))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; ADT: env
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defsubst elint-make-env ()
|
|
|
|
|
"Create an empty environment."
|
|
|
|
|
(list (list nil) nil nil))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-add-env (env newenv)
|
|
|
|
|
"Augment ENV with NEWENV.
|
|
|
|
|
None of them is modified, and the new env is returned."
|
|
|
|
|
(list (append (car env) (car newenv))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(append (cadr env) (cadr newenv))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(append (car (cdr (cdr env))) (car (cdr (cdr newenv))))))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-add-var (env var)
|
|
|
|
|
"Augment ENV with the variable VAR.
|
|
|
|
|
The new environment is returned, the old is unmodified."
|
|
|
|
|
(cons (cons (list var) (car env)) (cdr env)))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-add-global-var (env var)
|
|
|
|
|
"Augment ENV with the variable VAR.
|
|
|
|
|
ENV is modified so VAR is seen everywhere.
|
|
|
|
|
ENV is returned."
|
|
|
|
|
(nconc (car env) (list (list var)))
|
|
|
|
|
env)
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-find-var (env var)
|
|
|
|
|
"Non-nil if ENV contains the variable VAR.
|
|
|
|
|
Actually, a list with VAR as a single element is returned."
|
|
|
|
|
(assq var (car env)))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-add-func (env func args)
|
|
|
|
|
"Augment ENV with the function FUNC, which has the arguments ARGS.
|
|
|
|
|
The new environment is returned, the old is unmodified."
|
|
|
|
|
(list (car env)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(cons (list func args) (cadr env))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(car (cdr (cdr env)))))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-find-func (env func)
|
|
|
|
|
"Non-nil if ENV contains the function FUNC.
|
|
|
|
|
Actually, a list of (FUNC ARGS) is returned."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(assq func (cadr env)))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defsubst elint-env-add-macro (env macro def)
|
|
|
|
|
"Augment ENV with the macro named MACRO.
|
|
|
|
|
DEF is the macro definition (a lambda expression or similar).
|
|
|
|
|
The new environment is returned, the old is unmodified."
|
|
|
|
|
(list (car env)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(cadr env)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(cons (cons macro def) (car (cdr (cdr env))))))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-macro-env (env)
|
|
|
|
|
"Return the macro environment of ENV.
|
|
|
|
|
This environment can be passed to `macroexpand'."
|
|
|
|
|
(car (cdr (cdr env))))
|
|
|
|
|
|
|
|
|
|
(defsubst elint-env-macrop (env macro)
|
|
|
|
|
"Non-nil if ENV contains MACRO."
|
|
|
|
|
(assq macro (elint-env-macro-env env)))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; User interface
|
|
|
|
|
;;;
|
|
|
|
|
|
2009-09-12 02:41:39 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun elint-file (file)
|
|
|
|
|
"Lint the file FILE."
|
|
|
|
|
(interactive "fElint file: ")
|
|
|
|
|
(setq file (expand-file-name file))
|
|
|
|
|
(or elint-builtin-variables
|
|
|
|
|
(elint-initialize))
|
|
|
|
|
(let ((dir (file-name-directory file)))
|
|
|
|
|
(let ((default-directory dir))
|
|
|
|
|
(elint-display-log))
|
|
|
|
|
(elint-set-mode-line t)
|
|
|
|
|
(with-current-buffer elint-log-buffer
|
|
|
|
|
(unless (string-equal default-directory dir)
|
|
|
|
|
(elint-log-message (format "\nLeaving directory `%s'"
|
|
|
|
|
default-directory) t)
|
|
|
|
|
(elint-log-message (format "Entering directory `%s'" dir) t)
|
|
|
|
|
(setq default-directory dir))))
|
|
|
|
|
(let ((str (format "Linting file %s" file)))
|
|
|
|
|
(message "%s..." str)
|
|
|
|
|
(or noninteractive
|
|
|
|
|
(elint-log-message (format "\n%s at %s" str (current-time-string)) t))
|
|
|
|
|
;; elint-current-buffer clears log.
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents file)
|
2009-09-12 18:48:22 +00:00
|
|
|
|
(let ((buffer-file-name file)
|
|
|
|
|
(max-lisp-eval-depth (max 1000 max-lisp-eval-depth)))
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(with-syntax-table emacs-lisp-mode-syntax-table
|
|
|
|
|
(mapc 'elint-top-form (elint-update-env)))))
|
|
|
|
|
(elint-set-mode-line)
|
|
|
|
|
(message "%s...done" str)))
|
|
|
|
|
|
|
|
|
|
;; cf byte-recompile-directory.
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun elint-directory (directory)
|
|
|
|
|
"Lint all the .el files in DIRECTORY."
|
|
|
|
|
(interactive "DElint directory: ")
|
|
|
|
|
(let ((elint-running t))
|
|
|
|
|
(dolist (file (directory-files directory t))
|
|
|
|
|
;; Bytecomp has emacs-lisp-file-regexp.
|
|
|
|
|
(when (and (string-match "\\.el\\'" file)
|
|
|
|
|
(file-readable-p file)
|
|
|
|
|
(not (auto-save-file-name-p file)))
|
|
|
|
|
(elint-file file))))
|
|
|
|
|
(elint-set-mode-line))
|
|
|
|
|
|
2009-07-24 03:52:42 +00:00
|
|
|
|
;;;###autoload
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-current-buffer ()
|
2009-07-24 03:52:42 +00:00
|
|
|
|
"Lint the current buffer.
|
|
|
|
|
If necessary, this first calls `elint-initalize'."
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(interactive)
|
2009-07-24 03:52:42 +00:00
|
|
|
|
(or elint-builtin-variables
|
|
|
|
|
(elint-initialize))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(elint-clear-log (format "Linting %s" (or (buffer-file-name)
|
|
|
|
|
(buffer-name))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(elint-display-log)
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(elint-set-mode-line t)
|
2007-09-26 00:13:53 +00:00
|
|
|
|
(mapc 'elint-top-form (elint-update-env))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; Tell the user we're finished. This is terribly klugy: we set
|
2009-09-12 02:41:39 +00:00
|
|
|
|
;; elint-top-form-logged so elint-log-message doesn't print the
|
|
|
|
|
;; ** top form ** header...
|
|
|
|
|
(elint-set-mode-line)
|
|
|
|
|
(elint-log-message "\nLinting finished.\n" t))
|
|
|
|
|
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
2009-07-24 03:52:42 +00:00
|
|
|
|
;;;###autoload
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-defun ()
|
2009-07-24 03:52:42 +00:00
|
|
|
|
"Lint the function at point.
|
|
|
|
|
If necessary, this first calls `elint-initalize'."
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(interactive)
|
2009-07-24 03:52:42 +00:00
|
|
|
|
(or elint-builtin-variables
|
|
|
|
|
(elint-initialize))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(save-excursion
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(or (beginning-of-defun) (error "Lint what?"))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(let ((pos (point))
|
|
|
|
|
(def (read (current-buffer))))
|
|
|
|
|
(elint-display-log)
|
|
|
|
|
(elint-update-env)
|
|
|
|
|
(elint-top-form (elint-make-top-form def pos)))))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Top form functions
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defvar elint-buffer-env nil
|
|
|
|
|
"The environment of a elisp buffer.
|
|
|
|
|
Will be local in linted buffers.")
|
|
|
|
|
|
|
|
|
|
(defvar elint-buffer-forms nil
|
|
|
|
|
"The top forms in a buffer.
|
|
|
|
|
Will be local in linted buffers.")
|
|
|
|
|
|
|
|
|
|
(defvar elint-last-env-time nil
|
|
|
|
|
"The last time the buffers env was updated.
|
|
|
|
|
Is measured in buffer-modified-ticks and is local in linted buffers.")
|
|
|
|
|
|
|
|
|
|
(defun elint-update-env ()
|
|
|
|
|
"Update the elint environment in the current buffer.
|
|
|
|
|
Don't do anything if the buffer hasn't been changed since this
|
|
|
|
|
function was called the last time.
|
|
|
|
|
Returns the forms."
|
|
|
|
|
(if (and (local-variable-p 'elint-buffer-env (current-buffer))
|
|
|
|
|
(local-variable-p 'elint-buffer-forms (current-buffer))
|
|
|
|
|
(local-variable-p 'elint-last-env-time (current-buffer))
|
|
|
|
|
(= (buffer-modified-tick) elint-last-env-time))
|
|
|
|
|
;; Env is up to date
|
|
|
|
|
elint-buffer-forms
|
|
|
|
|
;; Remake env
|
|
|
|
|
(set (make-local-variable 'elint-buffer-forms) (elint-get-top-forms))
|
|
|
|
|
(set (make-local-variable 'elint-buffer-env)
|
|
|
|
|
(elint-init-env elint-buffer-forms))
|
|
|
|
|
(set (make-local-variable 'elint-last-env-time) (buffer-modified-tick))
|
|
|
|
|
elint-buffer-forms))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-get-top-forms ()
|
|
|
|
|
"Collect all the top forms in the current buffer."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((tops nil))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (elint-find-next-top-form)
|
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(setq tops (cons
|
|
|
|
|
(elint-make-top-form (read (current-buffer)) pos)
|
|
|
|
|
tops))
|
|
|
|
|
(end-of-file
|
|
|
|
|
(goto-char pos)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(error "Missing ')' in top form: %s"
|
|
|
|
|
(buffer-substring pos (line-end-position)))))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(nreverse tops))))
|
|
|
|
|
|
|
|
|
|
(defun elint-find-next-top-form ()
|
|
|
|
|
"Find the next top form from point.
|
2001-12-20 19:01:00 +00:00
|
|
|
|
Return nil if there are no more forms, t otherwise."
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(parse-partial-sexp (point) (point-max) nil t)
|
|
|
|
|
(not (eobp)))
|
|
|
|
|
|
|
|
|
|
(defun elint-init-env (forms)
|
2005-06-16 16:14:11 +00:00
|
|
|
|
"Initialize the environment from FORMS."
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(let ((env (elint-make-env))
|
|
|
|
|
form)
|
|
|
|
|
(while forms
|
|
|
|
|
(setq form (elint-top-form-form (car forms))
|
|
|
|
|
forms (cdr forms))
|
|
|
|
|
(cond
|
2009-09-12 22:32:52 +00:00
|
|
|
|
;; Eg nnmaildir seems to use [] as a form of comment syntax.
|
|
|
|
|
((not (listp form))
|
|
|
|
|
(elint-error "Skipping non-list form `%s'" form))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; Add defined variable
|
|
|
|
|
((memq (car form) '(defvar defconst defcustom))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(setq env (elint-env-add-var env (cadr form))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; Add function
|
|
|
|
|
((memq (car form) '(defun defsubst))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(setq env (elint-env-add-func env (cadr form) (nth 2 form))))
|
2009-09-12 02:41:39 +00:00
|
|
|
|
((eq (car form) 'define-derived-mode)
|
|
|
|
|
(setq env (elint-env-add-func env (cadr form) ())
|
|
|
|
|
env (elint-env-add-var env (cadr form))))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; FIXME it would be nice to check the autoloads are correct.
|
|
|
|
|
((eq (car form) 'autoload)
|
|
|
|
|
(setq env (elint-env-add-func env (cadr (cadr form)) 'unknown)))
|
|
|
|
|
((eq (car form) 'declare-function)
|
|
|
|
|
(setq env (elint-env-add-func env (cadr form)
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(if (or (< (length form) 4)
|
|
|
|
|
(eq (nth 3 form) t))
|
|
|
|
|
'unknown
|
|
|
|
|
(nth 3 form)))))
|
|
|
|
|
((and (eq (car form) 'defalias) (listp (nth 2 form)))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; If the alias points to something already in the environment,
|
|
|
|
|
;; add the alias to the environment with the same arguments.
|
|
|
|
|
(let ((def (elint-env-find-func env (cadr (nth 2 form)))))
|
|
|
|
|
;; FIXME warn if the alias target is unknown.
|
|
|
|
|
(setq env (elint-env-add-func env (cadr (cadr form))
|
|
|
|
|
(if def (cadr def) 'unknown)))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; Add macro, both as a macro and as a function
|
|
|
|
|
((eq (car form) 'defmacro)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(setq env (elint-env-add-macro env (cadr form)
|
|
|
|
|
(cons 'lambda (cddr form)))
|
|
|
|
|
env (elint-env-add-func env (cadr form) (nth 2 form))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; Import variable definitions
|
|
|
|
|
((eq (car form) 'require)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(let ((name (eval (cadr form)))
|
|
|
|
|
(file (eval (nth 2 form))))
|
|
|
|
|
(setq env (elint-add-required-env env name file))))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
env))
|
|
|
|
|
|
|
|
|
|
(defun elint-add-required-env (env name file)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
"Augment ENV with the variables defined by feature NAME in FILE."
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(let* ((libname (if (stringp file)
|
|
|
|
|
file
|
|
|
|
|
(symbol-name name)))
|
|
|
|
|
|
|
|
|
|
;; First try to find .el files, then the raw name
|
|
|
|
|
(lib1 (locate-library (concat libname ".el") t))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(lib (or lib1 (locate-library libname t))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;; Clear the messages :-/
|
|
|
|
|
(message nil)
|
|
|
|
|
(if lib
|
|
|
|
|
(save-excursion
|
2009-09-14 00:48:06 +00:00
|
|
|
|
;; FIXME this doesn't use a temp buffer, because it
|
|
|
|
|
;; stores the result in buffer-local variables so that
|
|
|
|
|
;; it can be reused.
|
|
|
|
|
(set-buffer (find-file-noselect lib))
|
|
|
|
|
(elint-update-env)
|
|
|
|
|
(setq env (elint-env-add-env env elint-buffer-env)))
|
|
|
|
|
;;; (with-temp-buffer
|
|
|
|
|
;;; (insert-file-contents lib)
|
|
|
|
|
;;; (with-syntax-table emacs-lisp-mode-syntax-table
|
|
|
|
|
;;; (elint-update-env))
|
|
|
|
|
;;; (setq env (elint-env-add-env env elint-buffer-env))))
|
2009-09-12 02:41:39 +00:00
|
|
|
|
;;(message "Elint processed (require '%s)" name))
|
|
|
|
|
(error "Unable to find require'd library %s" name)))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(error
|
|
|
|
|
(message "Can't get variables from require'd library %s" name)))
|
|
|
|
|
env)
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defvar elint-top-form nil
|
|
|
|
|
"The currently linted top form, or nil.")
|
|
|
|
|
|
|
|
|
|
(defvar elint-top-form-logged nil
|
|
|
|
|
"T if the currently linted top form has been mentioned in the log buffer.")
|
|
|
|
|
|
|
|
|
|
(defun elint-top-form (form)
|
|
|
|
|
"Lint a top FORM."
|
|
|
|
|
(let ((elint-top-form form)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(elint-top-form-logged nil)
|
|
|
|
|
(elint-current-pos (elint-top-form-pos form)))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(elint-form (elint-top-form-form form) elint-buffer-env)))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; General form linting functions
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defconst elint-special-forms
|
|
|
|
|
'((let . elint-check-let-form)
|
|
|
|
|
(let* . elint-check-let-form)
|
|
|
|
|
(setq . elint-check-setq-form)
|
|
|
|
|
(quote . elint-check-quote-form)
|
|
|
|
|
(cond . elint-check-cond-form)
|
|
|
|
|
(lambda . elint-check-defun-form)
|
|
|
|
|
(function . elint-check-function-form)
|
|
|
|
|
(setq-default . elint-check-setq-form)
|
|
|
|
|
(defun . elint-check-defun-form)
|
|
|
|
|
(defsubst . elint-check-defun-form)
|
|
|
|
|
(defmacro . elint-check-defun-form)
|
|
|
|
|
(defvar . elint-check-defvar-form)
|
|
|
|
|
(defconst . elint-check-defvar-form)
|
1997-10-02 02:47:57 +00:00
|
|
|
|
(defcustom . elint-check-defcustom-form)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(macro . elint-check-macro-form)
|
|
|
|
|
(condition-case . elint-check-condition-case-form))
|
|
|
|
|
"Functions to call when some special form should be linted.")
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-form (form env)
|
|
|
|
|
"Lint FORM in the environment ENV.
|
|
|
|
|
The environment created by the form is returned."
|
|
|
|
|
(cond
|
|
|
|
|
((consp form)
|
|
|
|
|
(let ((func (cdr (assq (car form) elint-special-forms))))
|
|
|
|
|
(if func
|
|
|
|
|
;; Special form
|
|
|
|
|
(funcall func form env)
|
|
|
|
|
|
|
|
|
|
(let* ((func (car form))
|
|
|
|
|
(args (elint-get-args func env))
|
|
|
|
|
(argsok t))
|
|
|
|
|
(cond
|
|
|
|
|
((eq args 'undefined)
|
|
|
|
|
(setq argsok nil)
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(elint-error "Call to undefined function: %s" func))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
((eq args 'unknown) nil)
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(t (setq argsok (elint-match-args form args))))
|
|
|
|
|
|
|
|
|
|
;; Is this a macro?
|
|
|
|
|
(if (elint-env-macrop env func)
|
|
|
|
|
;; Macro defined in buffer, expand it
|
|
|
|
|
(if argsok
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; FIXME error if macro uses macro, eg bytecomp.el.
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(elint-form
|
|
|
|
|
(macroexpand form (elint-env-macro-env env)) env)
|
|
|
|
|
(error
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(elint-error "Elint failed to expand macro: %s" func)
|
|
|
|
|
env))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
env)
|
|
|
|
|
|
|
|
|
|
(let ((fcode (if (symbolp func)
|
|
|
|
|
(if (fboundp func)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(indirect-function func))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
func)))
|
|
|
|
|
(if (and (listp fcode) (eq (car fcode) 'macro))
|
|
|
|
|
;; Macro defined outside buffer
|
|
|
|
|
(if argsok
|
|
|
|
|
(elint-form (macroexpand form) env)
|
|
|
|
|
env)
|
|
|
|
|
;; Function, lint its parameters
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(elint-forms (cdr form) env))))))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
((symbolp form)
|
|
|
|
|
;; :foo variables are quoted
|
|
|
|
|
(if (and (/= (aref (symbol-name form) 0) ?:)
|
|
|
|
|
(elint-unbound-variable form env))
|
|
|
|
|
(elint-warning "Reference to unbound symbol: %s" form))
|
|
|
|
|
env)
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(t env)))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-forms (forms env)
|
|
|
|
|
"Lint the FORMS, accumulating an environment, starting with ENV."
|
|
|
|
|
;; grumblegrumbletailrecursiongrumblegrumble
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(if (listp forms)
|
|
|
|
|
(dolist (f forms env)
|
|
|
|
|
(setq env (elint-form f env)))
|
|
|
|
|
;; Loop macro?
|
2009-09-12 18:48:22 +00:00
|
|
|
|
(elint-error "Elint failed to parse form: %s" forms)
|
|
|
|
|
env))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-unbound-variable (var env)
|
|
|
|
|
"T if VAR is unbound in ENV."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(not (or (memq var '(nil t))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(elint-env-find-var env var)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(memq var elint-builtin-variables)
|
|
|
|
|
(memq var elint-autoloaded-variables)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(memq var elint-standard-variables))))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Function argument checking
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defun elint-match-args (arglist argpattern)
|
|
|
|
|
"Match ARGLIST against ARGPATTERN."
|
|
|
|
|
(let ((state 'all)
|
|
|
|
|
(al (cdr arglist))
|
|
|
|
|
(ap argpattern)
|
|
|
|
|
(ok t))
|
|
|
|
|
(while
|
|
|
|
|
(cond
|
|
|
|
|
((and (null al) (null ap)) nil)
|
|
|
|
|
((eq (car ap) '&optional)
|
|
|
|
|
(setq state 'optional)
|
|
|
|
|
(setq ap (cdr ap))
|
|
|
|
|
t)
|
|
|
|
|
((eq (car ap) '&rest)
|
|
|
|
|
nil)
|
|
|
|
|
((or (and (eq state 'all) (or (null al) (null ap)))
|
|
|
|
|
(and (eq state 'optional) (and al (null ap))))
|
|
|
|
|
(elint-error "Wrong number of args: %s, %s" arglist argpattern)
|
|
|
|
|
(setq ok nil)
|
|
|
|
|
nil)
|
|
|
|
|
((and (eq state 'optional) (null al))
|
|
|
|
|
nil)
|
|
|
|
|
(t (setq al (cdr al)
|
|
|
|
|
ap (cdr ap))
|
|
|
|
|
t)))
|
|
|
|
|
ok))
|
|
|
|
|
|
|
|
|
|
(defun elint-get-args (func env)
|
|
|
|
|
"Find the args of FUNC in ENV.
|
|
|
|
|
Returns `unknown' if we couldn't find arguments."
|
|
|
|
|
(let ((f (elint-env-find-func env func)))
|
|
|
|
|
(if f
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(cadr f)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(if (symbolp func)
|
|
|
|
|
(if (fboundp func)
|
|
|
|
|
(let ((fcode (indirect-function func)))
|
|
|
|
|
(if (subrp fcode)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; FIXME builtins with no args have args = nil.
|
|
|
|
|
(or (get func 'elint-args) 'unknown)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(elint-find-args-in-code fcode)))
|
|
|
|
|
'undefined)
|
|
|
|
|
(elint-find-args-in-code func)))))
|
|
|
|
|
|
|
|
|
|
(defun elint-find-args-in-code (code)
|
|
|
|
|
"Extract the arguments from CODE.
|
|
|
|
|
CODE can be a lambda expression, a macro, or byte-compiled code."
|
|
|
|
|
(cond
|
|
|
|
|
((byte-code-function-p code)
|
|
|
|
|
(aref code 0))
|
|
|
|
|
((and (listp code) (eq (car code) 'lambda))
|
|
|
|
|
(car (cdr code)))
|
|
|
|
|
((and (listp code) (eq (car code) 'macro))
|
|
|
|
|
(elint-find-args-in-code (cdr code)))
|
|
|
|
|
(t 'unknown)))
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Functions to check some special forms
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(defun elint-check-cond-form (form env)
|
|
|
|
|
"Lint a cond FORM in ENV."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(dolist (f (cdr form) env)
|
|
|
|
|
(if (consp f)
|
|
|
|
|
(elint-forms f env)
|
|
|
|
|
(elint-error "cond clause should be a list: %s" f))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-check-defun-form (form env)
|
|
|
|
|
"Lint a defun/defmacro/lambda FORM in ENV."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(setq form (if (eq (car form) 'lambda) (cdr form) (cddr form)))
|
|
|
|
|
(mapc (lambda (p)
|
|
|
|
|
(or (memq p '(&optional &rest))
|
|
|
|
|
(setq env (elint-env-add-var env p))))
|
2007-09-26 00:13:53 +00:00
|
|
|
|
(car form))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(elint-forms (cdr form) env))
|
|
|
|
|
|
|
|
|
|
(defun elint-check-let-form (form env)
|
|
|
|
|
"Lint the let/let* FORM in ENV."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(let ((varlist (cadr form)))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(if (not varlist)
|
|
|
|
|
(progn
|
|
|
|
|
(elint-error "Missing varlist in let: %s" form)
|
|
|
|
|
env)
|
|
|
|
|
;; Check for (let (a (car b)) ...) type of error
|
|
|
|
|
(if (and (= (length varlist) 2)
|
|
|
|
|
(symbolp (car varlist))
|
|
|
|
|
(listp (car (cdr varlist)))
|
|
|
|
|
(fboundp (car (car (cdr varlist)))))
|
|
|
|
|
(elint-warning "Suspect varlist: %s" form))
|
|
|
|
|
;; Add variables to environment, and check the init values
|
|
|
|
|
(let ((newenv env))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(mapc (lambda (s)
|
|
|
|
|
(cond
|
|
|
|
|
((symbolp s)
|
|
|
|
|
(setq newenv (elint-env-add-var newenv s)))
|
|
|
|
|
((and (consp s) (<= (length s) 2))
|
|
|
|
|
(elint-form (cadr s)
|
|
|
|
|
(if (eq (car form) 'let)
|
|
|
|
|
env
|
|
|
|
|
newenv))
|
|
|
|
|
(setq newenv
|
|
|
|
|
(elint-env-add-var newenv (car s))))
|
|
|
|
|
(t (elint-error
|
|
|
|
|
"Malformed `let' declaration: %s" s))))
|
2007-09-26 00:13:53 +00:00
|
|
|
|
varlist)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
;; Lint the body forms
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(elint-forms (cddr form) newenv)))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-check-setq-form (form env)
|
|
|
|
|
"Lint the setq FORM in ENV."
|
|
|
|
|
(or (= (mod (length form) 2) 1)
|
|
|
|
|
(elint-error "Missing value in setq: %s" form))
|
|
|
|
|
(let ((newenv env)
|
|
|
|
|
sym val)
|
|
|
|
|
(setq form (cdr form))
|
|
|
|
|
(while form
|
|
|
|
|
(setq sym (car form)
|
|
|
|
|
val (car (cdr form))
|
|
|
|
|
form (cdr (cdr form)))
|
|
|
|
|
(if (symbolp sym)
|
|
|
|
|
(if (elint-unbound-variable sym newenv)
|
|
|
|
|
(elint-warning "Setting previously unbound symbol: %s" sym))
|
|
|
|
|
(elint-error "Setting non-symbol in setq: %s" sym))
|
|
|
|
|
(elint-form val newenv)
|
|
|
|
|
(if (symbolp sym)
|
|
|
|
|
(setq newenv (elint-env-add-var newenv sym))))
|
|
|
|
|
newenv))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-check-defvar-form (form env)
|
|
|
|
|
"Lint the defvar/defconst FORM in ENV."
|
|
|
|
|
(if (or (= (length form) 2)
|
|
|
|
|
(= (length form) 3)
|
|
|
|
|
(and (= (length form) 4) (stringp (nth 3 form))))
|
|
|
|
|
(elint-env-add-global-var (elint-form (nth 2 form) env)
|
|
|
|
|
(car (cdr form)))
|
|
|
|
|
(elint-error "Malformed variable declaration: %s" form)
|
|
|
|
|
env))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-check-defcustom-form (form env)
|
|
|
|
|
"Lint the defcustom FORM in ENV."
|
|
|
|
|
(if (and (> (length form) 3)
|
2003-10-20 17:16:16 +00:00
|
|
|
|
;; even no. of keyword/value args ?
|
|
|
|
|
(zerop (logand (length form) 1)))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
(elint-env-add-global-var (elint-form (nth 2 form) env)
|
|
|
|
|
(car (cdr form)))
|
|
|
|
|
(elint-error "Malformed variable declaration: %s" form)
|
|
|
|
|
env))
|
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-check-function-form (form env)
|
|
|
|
|
"Lint the function FORM in ENV."
|
|
|
|
|
(let ((func (car (cdr-safe form))))
|
|
|
|
|
(cond
|
|
|
|
|
((symbolp func)
|
|
|
|
|
(or (elint-env-find-func env func)
|
|
|
|
|
(fboundp func)
|
|
|
|
|
(elint-warning "Reference to undefined function: %s" form))
|
|
|
|
|
env)
|
|
|
|
|
((and (consp func) (memq (car func) '(lambda macro)))
|
|
|
|
|
(elint-form func env))
|
|
|
|
|
((stringp func) env)
|
|
|
|
|
(t (elint-error "Not a function object: %s" form)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
env))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-check-quote-form (form env)
|
|
|
|
|
"Lint the quote FORM in ENV."
|
|
|
|
|
env)
|
|
|
|
|
|
|
|
|
|
(defun elint-check-macro-form (form env)
|
|
|
|
|
"Check the macro FORM in ENV."
|
|
|
|
|
(elint-check-function-form (list (car form) (cdr form)) env))
|
|
|
|
|
|
|
|
|
|
(defun elint-check-condition-case-form (form env)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
"Check the `condition-case' FORM in ENV."
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(let ((resenv env))
|
|
|
|
|
(if (< (length form) 3)
|
|
|
|
|
(elint-error "Malformed condition-case: %s" form)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(or (symbolp (cadr form))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(elint-warning "First parameter should be a symbol: %s" form))
|
|
|
|
|
(setq resenv (elint-form (nth 2 form) env))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(let ((newenv (elint-env-add-var env (cadr form)))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
errlist)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(dolist (err (nthcdr 3 form))
|
|
|
|
|
(setq errlist (car err))
|
|
|
|
|
(mapc (lambda (s)
|
|
|
|
|
(or (get s 'error-conditions)
|
|
|
|
|
(get s 'error-message)
|
|
|
|
|
(memq s elint-extra-errors)
|
|
|
|
|
(elint-warning
|
|
|
|
|
"Not an error symbol in error handler: %s" s)))
|
2007-09-26 00:13:53 +00:00
|
|
|
|
(cond
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
((symbolp errlist) (list errlist))
|
|
|
|
|
((listp errlist) errlist)
|
|
|
|
|
(t (elint-error "Bad error list in error handler: %s"
|
|
|
|
|
errlist)
|
|
|
|
|
nil)))
|
|
|
|
|
(elint-forms (cdr err) newenv))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
resenv))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; Message functions
|
|
|
|
|
;;;
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(defvar elint-current-pos) ; dynamically bound in elint-top-form
|
|
|
|
|
|
|
|
|
|
(defun elint-log (type string args)
|
|
|
|
|
(elint-log-message (format "%s:%d:%s: %s"
|
2009-07-24 03:52:42 +00:00
|
|
|
|
(let ((f (buffer-file-name)))
|
|
|
|
|
(if f
|
|
|
|
|
(file-name-nondirectory f)
|
|
|
|
|
(buffer-name)))
|
2009-09-12 22:32:52 +00:00
|
|
|
|
(if (boundp 'elint-current-pos)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char elint-current-pos)
|
|
|
|
|
(1+ (count-lines (point-min)
|
|
|
|
|
(line-beginning-position))))
|
|
|
|
|
0) ; unknown position
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
type
|
|
|
|
|
(apply 'format string args))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-error (string &rest args)
|
2002-10-17 16:49:14 +00:00
|
|
|
|
"Report a linting error.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
STRING and ARGS are thrown on `format' to get the message."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(elint-log "Error" string args))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-warning (string &rest args)
|
2002-10-17 16:49:14 +00:00
|
|
|
|
"Report a linting warning.
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
See `elint-error'."
|
|
|
|
|
(elint-log "Warning" string args))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(defun elint-output (string)
|
|
|
|
|
"Print or insert STRING, depending on value of `noninteractive'."
|
|
|
|
|
(if noninteractive
|
|
|
|
|
(message "%s" string)
|
|
|
|
|
(insert string "\n")))
|
|
|
|
|
|
|
|
|
|
(defun elint-log-message (errstr &optional top)
|
|
|
|
|
"Insert ERRSTR last in the lint log buffer.
|
|
|
|
|
Optional argument TOP non-nil means pretend `elint-top-form-logged' is non-nil."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(with-current-buffer (elint-get-log-buffer)
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(goto-char (point-max))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(or (bolp) (newline))
|
|
|
|
|
;; Do we have to say where we are?
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(unless (or elint-top-form-logged top)
|
|
|
|
|
(let* ((form (elint-top-form-form elint-top-form))
|
|
|
|
|
(top (car form)))
|
|
|
|
|
(elint-output (cond
|
|
|
|
|
((memq top '(defun defsubst))
|
|
|
|
|
(format "\nIn function %s:" (cadr form)))
|
|
|
|
|
((eq top 'defmacro)
|
|
|
|
|
(format "\nIn macro %s:" (cadr form)))
|
|
|
|
|
((memq top '(defvar defconst))
|
|
|
|
|
(format "\nIn variable %s:" (cadr form)))
|
|
|
|
|
(t "\nIn top level expression:"))))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(setq elint-top-form-logged t))
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(elint-output errstr))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-clear-log (&optional header)
|
|
|
|
|
"Clear the lint log buffer.
|
|
|
|
|
Insert HEADER followed by a blank line if non-nil."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(let ((dir default-directory))
|
|
|
|
|
(with-current-buffer (elint-get-log-buffer)
|
|
|
|
|
(setq default-directory dir)
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(if header (insert header "\n"))))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-display-log ()
|
|
|
|
|
"Display the lint log buffer."
|
|
|
|
|
(let ((pop-up-windows t))
|
|
|
|
|
(display-buffer (elint-get-log-buffer))
|
|
|
|
|
(sit-for 0)))
|
|
|
|
|
|
2009-09-12 02:41:39 +00:00
|
|
|
|
(defvar elint-running)
|
|
|
|
|
|
|
|
|
|
(defun elint-set-mode-line (&optional on)
|
|
|
|
|
"Set the mode-line-process of the Elint log buffer."
|
|
|
|
|
(with-current-buffer (elint-get-log-buffer)
|
|
|
|
|
(and (eq major-mode 'compilation-mode)
|
|
|
|
|
(setq mode-line-process
|
|
|
|
|
(list (if (or on (bound-and-true-p elint-running))
|
|
|
|
|
(propertize ":run" 'face 'compilation-warning)
|
|
|
|
|
(propertize ":finished" 'face 'compilation-info)))))))
|
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-get-log-buffer ()
|
|
|
|
|
"Return a log buffer for elint."
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(or (get-buffer elint-log-buffer)
|
|
|
|
|
(with-current-buffer (get-buffer-create elint-log-buffer)
|
|
|
|
|
(or (eq major-mode 'compilation-mode)
|
|
|
|
|
(compilation-mode))
|
|
|
|
|
(setq buffer-undo-list t)
|
|
|
|
|
(current-buffer))))
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;;;
|
|
|
|
|
;;; Initializing code
|
|
|
|
|
;;;
|
1997-10-02 02:47:57 +00:00
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;;;###autoload
|
2009-07-24 03:52:42 +00:00
|
|
|
|
(defun elint-initialize (&optional reinit)
|
|
|
|
|
"Initialize elint.
|
|
|
|
|
If elint is already initialized, this does nothing, unless
|
|
|
|
|
optional prefix argument REINIT is non-nil."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(if (and elint-builtin-variables (not reinit))
|
|
|
|
|
(message "Elint is already initialized")
|
|
|
|
|
(message "Initializing elint...")
|
|
|
|
|
(setq elint-builtin-variables (elint-find-builtin-variables)
|
|
|
|
|
elint-autoloaded-variables (elint-find-autoloaded-variables))
|
|
|
|
|
(mapc (lambda (x) (or (not (symbolp (car x)))
|
|
|
|
|
(eq (cdr x) 'unknown)
|
|
|
|
|
(put (car x) 'elint-args (cdr x))))
|
|
|
|
|
(elint-find-builtin-args))
|
|
|
|
|
(if elint-unknown-builtin-args
|
|
|
|
|
(mapc (lambda (x) (put (car x) 'elint-args (cdr x)))
|
|
|
|
|
elint-unknown-builtin-args))
|
|
|
|
|
(message "Initializing elint...done")))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
(defun elint-find-builtin-variables ()
|
|
|
|
|
"Return a list of all built-in variables."
|
|
|
|
|
;; Cribbed from help-fns.el.
|
|
|
|
|
(let ((docbuf " *DOC*")
|
|
|
|
|
vars var)
|
2009-07-24 03:52:42 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(if (get-buffer docbuf)
|
|
|
|
|
(progn
|
|
|
|
|
(set-buffer docbuf)
|
|
|
|
|
(goto-char (point-min)))
|
|
|
|
|
(set-buffer (get-buffer-create docbuf))
|
|
|
|
|
(insert-file-contents-literally
|
|
|
|
|
(expand-file-name internal-doc-file-name doc-directory)))
|
|
|
|
|
(while (search-forward "V" nil t)
|
|
|
|
|
(and (setq var (intern-soft
|
|
|
|
|
(buffer-substring (point) (line-end-position))))
|
|
|
|
|
(boundp var)
|
|
|
|
|
(setq vars (cons var vars))))
|
|
|
|
|
vars)))
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-find-autoloaded-variables ()
|
|
|
|
|
"Return a list of all autoloaded variables."
|
|
|
|
|
(let (var vars)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents (locate-library "loaddefs.el"))
|
|
|
|
|
(while (re-search-forward "^(defvar \\([[:alnum:]_-]+\\)" nil t)
|
|
|
|
|
(and (setq var (intern-soft (match-string 1)))
|
|
|
|
|
(boundp var)
|
|
|
|
|
(setq vars (cons var vars)))))
|
|
|
|
|
vars))
|
|
|
|
|
|
1997-08-07 17:25:43 +00:00
|
|
|
|
(defun elint-find-builtins ()
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
"Return a list of all built-in functions."
|
|
|
|
|
(let (subrs)
|
|
|
|
|
(mapatoms (lambda (s) (and (fboundp s) (subrp (symbol-function s))
|
|
|
|
|
(setq subrs (cons s subrs)))))
|
|
|
|
|
subrs))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(defun elint-find-builtin-args (&optional list)
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
"Return a list of the built-in functions and their arguments.
|
1997-08-07 17:25:43 +00:00
|
|
|
|
If LIST is nil, call `elint-find-builtins' to get a list of all built-in
|
|
|
|
|
functions, otherwise use LIST.
|
|
|
|
|
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
Each function is represented by a cons cell:
|
1997-08-07 17:25:43 +00:00
|
|
|
|
\(function-symbol . args)
|
|
|
|
|
If no documentation could be found args will be `unknown'."
|
2009-02-24 03:32:19 +00:00
|
|
|
|
(mapcar (lambda (f)
|
|
|
|
|
(let ((doc (documentation f t)))
|
|
|
|
|
(or (and doc
|
|
|
|
|
(string-match "\n\n(fn\\(.*)\\)\\'" doc)
|
|
|
|
|
(ignore-errors
|
(elint-standard-variables): Remove most members,
since the next two variables cover them automatically now.
(elint-builtin-variables, elint-autoloaded-variables): New.
(elint-unknown-builtin-args): Remove all members, since they can be
parsed automatically now.
(elint-extra-errors): New.
(elint-env-add-env, elint-env-add-macro): Use cadr.
(elint-current-buffer): Use or. Change final message.
(elint-get-top-forms): Use line-end-position.
(elint-init-env): Use cadr. Handle autoload, declare-function,
and defalias.
(elint-add-required-env): Doc fix. Use or. Standardize error.
(regexp-assoc): Remove unused function.
(elint-top-form): Set elint-current-pos, to record the start of the
top-level form, for compilation-mode.
(elint-form): Trap errors in macro expansion. Use dolist.
(elint-unbound-variable): Use elint-builtin-variables and
elint-autoloaded-variables.
(elint-get-args): Use cadr, or.
(elint-check-cond-form): Use dolist, cadr.
(elint-check-condition-case-form): Doc fix. Use cadr.
Use elint-extra-errors.
(elint-log): New function.
(elint-error, elint-warning): Use elint-log for a bytecomp-style format.
Distinguish errors and warnings.
(elint-log-message): Use with-current-buffer. Inhibit read-only.
Use a bytecomp-style format.
(elint-clear-log): Preserve default-directory. Inhibit read-only.
(elint-get-log-buffer): Use compilation mode. Disable undo.
Don't truncate lines.
(elint-initialize): Set builtin and autoloaded variable lists.
Only process elint-unknown-builtin-args if non-nil.
(elint-find-builtin-variables, elint-find-autoloaded-variables):
New functions.
(elint-find-builtin-args): Doc fix. Handle "BODY...)".
2009-07-23 02:54:39 +00:00
|
|
|
|
;; "BODY...)" -> "&rest BODY)".
|
|
|
|
|
(read (replace-regexp-in-string
|
|
|
|
|
"\\([^ ]+\\)\\.\\.\\.)\\'" "&rest \\1)"
|
|
|
|
|
(format "(%s %s" f (match-string 1 doc)) t))))
|
2009-02-24 03:32:19 +00:00
|
|
|
|
(cons f 'unknown))))
|
|
|
|
|
(or list (elint-find-builtins))))
|
1997-08-07 17:25:43 +00:00
|
|
|
|
|
|
|
|
|
(provide 'elint)
|
|
|
|
|
|
2008-04-10 14:10:46 +00:00
|
|
|
|
;; arch-tag: b2f061e2-af84-4ddc-8e39-f5e969ac228f
|
1997-08-07 17:25:43 +00:00
|
|
|
|
;;; elint.el ends here
|