Subject: bug#1063: improvement of elint.el

From: "Shigeru Fukaya" <[email-masked]>
Date: Wed, 1 Oct 2008 23:41:05 +0900

Hello,

I changed elint.el to work better in the latest Emacs.

Revised features are,

 * Regard more variables as defined.

   - Variables defined in C source without help string.
     (by preset in elint-standard-variables)

   - Variables having entries in DOC file.

   - Variables defined in some file, but unbound.

 * Get builtin function arguments properly.
   (adapt to current (fn ARG1 ARG2...) document form)

Regards,
Shigeru
*** elint.el	Tue May  6 22:54:43 2008
--- elint-new.el	Wed Oct  1 23:23:27 2008
***************
*** 68,74 ****
       overwrite-mode
       point-before-scroll right-fringe-width right-margin-width
       scroll-bar-width scroll-down-aggressively scroll-up-aggressively selective-display
!      selective-display-ellipses tab-width truncate-lines vc-mode vertical-scroll-bar)
    "Standard buffer local vars.")
  
  (defconst elint-unknown-builtin-args
--- 68,78 ----
       overwrite-mode
       point-before-scroll right-fringe-width right-margin-width
       scroll-bar-width scroll-down-aggressively scroll-up-aggressively selective-display
!      selective-display-ellipses tab-width truncate-lines vc-mode vertical-scroll-bar
!      ;; bound, defined in some C source, and no help.
!      activate-menubar-hook buffer-name-history coding-system-history
!      extended-command-history kbd-macro-termination-hook
!      minibuffer-default read-expression-history yes-or-no-p-history)
    "Standard buffer local vars.")
  
  (defconst elint-unknown-builtin-args
***************
*** 461,467 ****
    (not (or (eq var nil)
  	   (eq var t)
  	   (elint-env-find-var env var)
! 	   (memq var elint-standard-variables))))
  
  ;;;
  ;;; Function argument checking
--- 465,476 ----
    (not (or (eq var nil)
  	   (eq var t)
  	   (elint-env-find-var env var)
! 	   (memq var elint-standard-variables)
! 	   ;; symbol in DOC may be bound at runtime.
! 	   (numberp (get var 'variable-documentation))
! 	   (numberp (cdr-safe (get var 'variable-documentation)))
! 	   ;; symbol in some loaded file may be bound at runtime.
! 	   (symbol-file var))))
  
  ;;;
  ;;; Function argument checking
***************
*** 770,778 ****
  			(eq (cdr x) 'unknown)
  			(put (car x) 'elint-args (cdr x)))))
  	(elint-find-builtin-args))
!   (mapcar (function (lambda (x)
  		      (put (car x) 'elint-args (cdr x))))
! 	  elint-unknown-builtin-args))

  (defun elint-find-builtins ()
--- 779,787 ----
  			(eq (cdr x) 'unknown)
  			(put (car x) 'elint-args (cdr x)))))
  	(elint-find-builtin-args))
!   (mapc (function (lambda (x)		;;; mapcar
  		      (put (car x) 'elint-args (cdr x))))
! 	elint-unknown-builtin-args))

  (defun elint-find-builtins ()
***************
*** 783,788 ****
--- 792,798 ----
      subrs
      ))
  
+ 
  (defun elint-find-builtin-args (&optional list)
    "Returns a list of the built-in functions and their arguments.
  
***************
*** 792,808 ****
  Each functions is represented by a cons cell:
  \(function-symbol . args)
  If no documentation could be found args will be `unknown'."
  
-     (mapcar (function (lambda (f)
- 			(let ((doc (documentation f t)))
- 			  (if (and doc (string-match "\n\n\\((.*)\\)" doc))
- 			      (read (match-string 1 doc))
- 			    (cons f 'unknown))
- 			  )))
- 	    (if list list
- 	      (elint-find-builtins))))
  
  (provide 'elint)
- 
- ;; arch-tag: b2f061e2-af84-4ddc-8e39-f5e969ac228f
- ;;; elint.el ends here
--- 802,822 ----
  Each functions is represented by a cons cell:
  \(function-symbol . args)
  If no documentation could be found args will be `unknown'."
+   (mapcar (lambda (f)
+ 	    (let ((doc (documentation f t))
+ 		  exp)
+ 	      (if (and doc (string-match "\n\n\\((.*)\\)" doc))
+ 		  (progn
+ 		    (setq exp (match-string 1 doc))
+ 		    ;; replace (fn ARG...) to (name arg...)
+ 		    (read
+ 		     (if (string-match "\\`(\\(fn\\) " exp)
+ 			 (replace-match (symbol-name f) nil t
+ 					(downcase exp) 1)
+ 		       exp)))
+ 		(cons f 'unknown))))
+ 	  (if list list
+ 	    (elint-find-builtins))))

  (provide 'elint)