-;;; elint.el -- Lint Emacs Lisp
+;;; elint.el --- Lint Emacs Lisp
;; Copyright (C) 1997 Free Software Foundation, Inc.
;; ** top form ** header...
(let ((elint-top-form-logged t))
(elint-log-message "\nLinting complete.\n")))
-
+
(defun elint-defun ()
"Lint the function at point."
(interactive)
(elint-init-env elint-buffer-forms))
(set (make-local-variable 'elint-last-env-time) (buffer-modified-tick))
elint-buffer-forms))
-
+
(defun elint-get-top-forms ()
"Collect all the top forms in the current buffer."
(save-excursion
(defun elint-find-next-top-form ()
"Find the next top form from point.
-Returns nil if there are no more forms, T otherwise."
+Return nil if there are no more forms, t otherwise."
(parse-partial-sexp (point) (point-max) nil t)
(not (eobp)))
(ding)
(message "Can't get variables from require'd library %s" name)))
env)
-
+
(defun regexp-assoc (regexp alist)
"Search for a key matching REGEXP in ALIST."
(let ((res nil))
(defmacro . elint-check-defun-form)
(defvar . elint-check-defvar-form)
(defconst . elint-check-defvar-form)
- (defcustom . elint-check-defvar-form)
+ (defcustom . elint-check-defcustom-form)
(macro . elint-check-macro-form)
(condition-case . elint-check-condition-case-form))
"Functions to call when some special form should be linted.")
-
+
(defun elint-form (form env)
"Lint FORM in the environment ENV.
The environment created by the form is returned."
((eq args 'undefined)
(setq argsok nil)
(elint-error "Call to undefined function: %s" form))
-
+
((eq args 'unknown) nil)
-
+
(t (setq argsok (elint-match-args form args))))
;; Is this a macro?
(if (symbolp sym)
(setq newenv (elint-env-add-var newenv sym))))
newenv))
-
+
(defun elint-check-defvar-form (form env)
"Lint the defvar/defconst FORM in ENV."
(if (or (= (length form) 2)
(car (cdr form)))
(elint-error "Malformed variable declaration: %s" form)
env))
-
+
+(defun elint-check-defcustom-form (form env)
+ "Lint the defcustom FORM in ENV."
+ (if (and (> (length form) 3)
+ ;; even no. of keyword/value args ?
+ (zerop (logand (length form) 1)))
+ (elint-env-add-global-var (elint-form (nth 2 form) env)
+ (car (cdr form)))
+ (elint-error "Malformed variable declaration: %s" form)
+ env))
+
(defun elint-check-function-form (form env)
"Lint the function FORM in ENV."
(let ((func (car (cdr-safe form))))
(setq errforms (cdr errforms))
)))
resenv))
-
+
;;;
;;; Message functions
;;;
;; to reflect different seriousness of linting errors
(defun elint-error (string &rest args)
- "Report an linting error.
+ "Report a linting error.
STRING and ARGS are thrown on `format' to get the message."
(let ((errstr (apply 'format string args)))
(elint-log-message errstr)
))
-
+
(defun elint-warning (string &rest args)
- "Report an linting warning.
+ "Report a linting warning.
STRING and ARGS are thrown on `format' to get the message."
(let ((errstr (apply 'format string args)))
(elint-log-message errstr)
(setq truncate-lines t)
(set-buffer oldbuf)))
)))
-
+
;;;
;;; Initializing code
;;;
-
+
;;;###autoload
(defun elint-initialize ()
"Initialize elint."
point-before-scroll require-final-newline selective-display
selective-display-ellipses tab-width truncate-lines vc-mode)
"Standard buffer local vars.")
-
+
(defconst elint-unknown-builtin-args
'((while test &rest forms)
(insert-before-markers-and-inherit &rest text)
(catch tag &rest body)
(and &rest args)
(funcall func &rest args)
- (insert-string &rest args)
(insert &rest args)
(vconcat &rest args)
(run-hook-with-args hook &rest args)
(message-box string &rest args)
(prog2 x y &rest body)
(prog1 first &rest body)
- (ml-provide-prefix-argument prefix form)
(insert-before-markers &rest args)
(call-process-region start end program &optional delete
destination display &rest args)
(track-mouse &rest body)
(unwind-protect bodyform &rest unwindforms)
(save-restriction &rest body)
- (ml-prefix-argument-loop)
(quote arg)
(make-byte-code &rest args)
(or &rest args)
(start-process name buffer program &rest args)
(run-hook-with-args-until-failure hook &rest args)
(if cond then &rest else)
- (ml-if)
(apply function &rest args)
(format string &rest args)
(encode-time second minute hour day month year zone &rest args)
(provide 'elint)
+;;; arch-tag: b2f061e2-af84-4ddc-8e39-f5e969ac228f
;;; elint.el ends here
-