From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Elena Newsgroups: gmane.emacs.help Subject: Re: Redefining functions and variables Date: Tue, 27 Jul 2010 15:16:01 -0700 (PDT) Organization: http://groups.google.com Message-ID: <76fd4dc4-a964-4629-90e2-329e1b83fd8d@h25g2000vba.googlegroups.com> References: <68e690c9-aece-461d-afe9-ca9115ceaee5@m1g2000vbh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1291852360 14944 80.91.229.12 (8 Dec 2010 23:52:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 23:52:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 00:52:36 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQToK-000648-2s for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 00:52:36 +0100 Original-Received: from localhost ([127.0.0.1]:48926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQToJ-0006B0-9w for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 18:52:35 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!h25g2000vba.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-NNTP-Posting-Host: 94.36.131.210 Original-X-Trace: posting.google.com 1280268961 28524 127.0.0.1 (27 Jul 2010 22:16:01 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 27 Jul 2010 22:16:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h25g2000vba.googlegroups.com; posting-host=94.36.131.210; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.19) Gecko/2010062510 Iceweasel/3.0.6 (Debian-3.0.6-3),gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:180127 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:76246 Archived-At: On 27 Lug, 22:21, Stefan Monnier wrote: > > I wonder whether there is a way to catch such redefinitions whenever > > they happen (which also would help when accidentally redefining > > something) > > Not sure what you mean by that. Let's assume we have two definitions for the same function: ;; File A (loaded first) (defun foo () ... ;; File B (loaded later) (defun foo () ;; This is a redefinition: I'd like to get a warning. ... Since redefining functions is the heart of interactive programming, such a warning should be issued only while loading files. That way, you could consider whether to rename the second function or to rewrite it as an advice (as you suggested). If such a goal can only be achieved by rewriting "defun" and checking by means of "fboundp" whether the function has already been defined, here is my (failed, as noted) attempt: (defmacro defun (name args &rest body) `(progn ;; `load-file-name' is not null only if we are loading a file. (when (and load-file-name ;; FAIL: I don't know how to quote the value of `name'. (fboundp ,name)) (message "Warning: %s is being redefined in %s." ;; FAIL: I don't know how to quote the value of `name'. (symbol-name ,name) load-file-name) (defun ,name ,args ,@body)))) Any suggestions? Thanks.