From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Finding Unused Identifiers Date: Fri, 03 Mar 2006 12:25:07 +0100 Organization: Informatimago Message-ID: <87y7zrhiss.fsf@thalassa.informatimago.com> References: <4406fc36$0$11610$3b214f66@tunews.univie.ac.at> <1YDNf.5345$F56.2416@newsread3.news.atl.earthlink.net> <1kwdawrs69lxs$.1nqpbp8apcebt.dlg@40tude.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1141422299 14074 80.91.229.2 (3 Mar 2006 21:44:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 3 Mar 2006 21:44:59 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 03 22:44:57 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FFI4u-0007D2-Mt for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Mar 2006 22:44:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FFI4u-0004m7-PN for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Mar 2006 16:44:48 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 55 Original-X-Trace: individual.net MERBaRW/XsfkLh8brkosPQ5jmnTk5EA5xJVeAk2e+WgwMJf+O1 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:33k6jJj3cSXmExtLvXL1990Nvfs= Original-Xref: shelby.stanford.edu gnu.emacs.help:137892 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:33516 Archived-At: Peter Tury 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.