[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding Unused Identifiers
From: |
Pascal Bourguignon |
Subject: |
Re: Finding Unused Identifiers |
Date: |
Fri, 03 Mar 2006 12:25:07 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Peter Tury <tury.peter@gmail.com> writes:
> On Thu, 02 Mar 2006 22:25:10 GMT, August Karlstrom wrote:
>
>> I mean "forgotten" variables and functions that were never intended to
>> be exported. I know that in Elisp all identifiers with file scope are
>> exported, but it would be nice to at least have a list of all
>> declared-but-never-used-in-the-same-file identifiers. That would give
>> you an hint of what can safely be removed.
>>
>
> As the first easiest(?) step it might help if you generate a list of all
> words what has only one instance in that file (and that instance is in an
> outermost defvar...)? If the list would have a form what is usable in
> compilation mode, then one could go throught it easily and check what
> should really be removed...
(require 'cl)
(require 'pjb-sources)
;; http://www.informatimago.com/develop/emacs/
(let ((defvars '())
(refered '()))
(flet ((push-refered (form)
(cond ((symbolp form)
(push form refered))
(t (while (consp form)
(push-refered (car form))
(setf form (cdr form)))))))
(map-sexps "/home/pjb/src/public/emacs/pjb-sources.el"
(lambda (form start end)
(if (and (consp form) (eq 'defvar (first form)))
(progn (push (second form) defvars)
(and (third form) (push-refered (third form))))
(push-refered form)))
:deeply nil :atoms t)
(print defvars)
(set-difference defvars refered)))
Prints:
(dummy line-num-map *silent* *pjb-sources-initials* *map-sexps-function*
*map-sexps-atoms* *map-sexps-deeply* *map-sexps-top-level*
*walk-sexps-end-marker* update-def-names-minimum-lines update-def-names
*greek-flk* pretty-greek)
and returns:
(dummy)
--
__Pascal Bourguignon__ http://www.informatimago.com/
WARNING: This product warps space and time in its vicinity.
- Finding Unused Identifiers, August Karlstrom, 2006/03/02
- Re: Finding Unused Identifiers, Markus Triska, 2006/03/02
- Re: Finding Unused Identifiers, B. T. Raven, 2006/03/02
- Re: Finding Unused Identifiers, Markus Triska, 2006/03/02
- Re: Finding Unused Identifiers, August Karlstrom, 2006/03/02
- Re: Finding Unused Identifiers, Peter Tury, 2006/03/03
- Re: Finding Unused Identifiers,
Pascal Bourguignon <=
- Re: Finding Unused Identifiers, Markus Triska, 2006/03/03
- Re: Finding Unused Identifiers, Pascal Bourguignon, 2006/03/06
- Re: Finding Unused Identifiers, Markus Triska, 2006/03/06
- Re: Finding Unused Identifiers, August Karlstrom, 2006/03/06
- Re: Finding Unused Identifiers, August Karlstrom, 2006/03/06
- Re: Finding Unused Identifiers, Markus Triska, 2006/03/06
- Re: Finding Unused Identifiers, August Karlstrom, 2006/03/06
- Re: Finding Unused Identifiers, Kevin Rodgers, 2006/03/08
- Message not available
- Re: Finding Unused Identifiers, August Karlstrom, 2006/03/09