From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: August Karlstrom Newsgroups: gmane.emacs.help Subject: Re: Finding Unused Identifiers Date: Sun, 05 Mar 2006 16:05:00 GMT Organization: Telia Internet Message-ID: References: <4406fc36$0$11610$3b214f66@tunews.univie.ac.at> <1YDNf.5345$F56.2416@newsread3.news.atl.earthlink.net> <1kwdawrs69lxs$.1nqpbp8apcebt.dlg@40tude.net> <440b0026$0$8024$3b214f66@tunews.univie.ac.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1141686902 10529 80.91.229.2 (6 Mar 2006 23:15:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Mar 2006 23:15:02 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 07 00:15:00 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 1FGOuk-0007fx-Rx for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Mar 2006 00:14:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGOuj-0006Ir-Sc for geh-help-gnu-emacs@m.gmane.org; Mon, 06 Mar 2006 18:14:53 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newspeer1.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help In-Reply-To: <440b0026$0$8024$3b214f66@tunews.univie.ac.at> Original-Lines: 67 Original-NNTP-Posting-Host: 83.250.237.84 Original-X-Complaints-To: abuse@telia.com Original-X-Trace: newsb.telia.net 1141574700 83.250.237.84 (Sun, 05 Mar 2006 17:05:00 CET) Original-NNTP-Posting-Date: Sun, 05 Mar 2006 17:05:00 CET Original-Xref: shelby.stanford.edu gnu.emacs.help:137939 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:33575 Archived-At: Markus Triska wrote: > The comment "that are never accessed in the same buffer" is also incorrect: > > (defvar falsepositive 0) > > (eval `(print ,(intern (concat "false" "positive")))) > > ==> > > Found unused global identifier(s): > > falsepositive > > > Hyphenated identifiers can yield false negatives: > > (defvar has-hyphen 0) > > (print 'has) > > ==> > > No unused global identifiers found. Thanks Markus for your remarks. When I tested my functions I had previously changed the syntax class for `-' to "w" (word) and then forgot that, so I never noticed the problem. I wonder why the syntax class of dash is not "word" by default in LISP buffers. Here is a corrected version: (defun my-elisp-unused-globals () "Return a list of unused global identifiers. Returns a list of global identifiers in the current buffer declared with defconst, defimage, defmacro, defsubst, defun or defvar that occur only once in the same buffer. Requires that no local identifier uses the same name as a global identifier." (let ((pos nil) (res nil) (id nil) (saved-syntax (char-syntax ?-))) (modify-syntax-entry ?- "w") (save-excursion (beginning-of-buffer) (setq pos (re-search-forward my-elisp-global-decl-re nil t)) (while (not (null pos)) (save-excursion (setq id (match-string-no-properties 1)) (setq pos (re-search-forward (concat "\\<" id "\\>") nil t)) (when (null pos) (setq pos (re-search-backward (concat "\\<" id "\\>") nil t 2))) (when (null pos) (setq res (cons id res)))) (setq pos (re-search-forward my-elisp-global-decl-re nil t)))) (modify-syntax-entry ?- (string saved-syntax)) res)) Regards, August -- I am the "ILOVEGNU" signature virus. Just copy me to your signature. This email was infected under the terms of the GNU General Public License.