GNU bug report logs - #5293
23.1; unload-feature on buffer-local hooks

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Kevin Ryde <user42@HIDDEN>; merged with #34686; dated Sat, 2 Jan 2010 21:07:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 5293 34686. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs@HIDDEN> to internal_control <at> debbugs.gnu.org. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 6 Aug 2011 01:22:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 05 21:22:26 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QpVas-0004md-5q
	for submit <at> debbugs.gnu.org; Fri, 05 Aug 2011 21:22:26 -0400
Received: from mailout2-6.pacific.net.au ([61.8.2.229]
	helo=mailout2.pacific.net.au)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gg@HIDDEN>)
	id 1QpVao-0004mQ-1M; Fri, 05 Aug 2011 21:22:23 -0400
Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au
	[61.8.2.163])
	by mailout2.pacific.net.au (Postfix) with ESMTP id AE7222C09B0;
	Sat,  6 Aug 2011 11:21:31 +1000 (EST)
Received: from blah.blah (unknown [203.26.175.151])
	by mailproxy2.pacific.net.au (Postfix) with ESMTP id 7DC9527419;
	Sat,  6 Aug 2011 11:21:25 +1000 (EST)
Received: from gg by blah.blah with local (Exim 4.72)
	(envelope-from <gg@HIDDEN>)
	id 1QpVZB-00052r-5r; Sat, 06 Aug 2011 11:20:41 +1000
From: Kevin Ryde <user42@HIDDEN>
To: control <at> debbugs.gnu.org
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN> <jwvfwm62h9r.fsf-monnier+emacs@HIDDEN>
Date: Sat, 06 Aug 2011 11:20:41 +1000
In-Reply-To: <jwvfwm62h9r.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Sat, 16 Jul 2011 14:50:54 -0400")
Message-ID: <87aabnnxna.fsf@HIDDEN>
User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -3.4 (---)
X-Debbugs-Envelope-To: 5293
Cc: Juanma Barranquero <lekktu@HIDDEN>,
	Stefan Monnier <monnier@HIDDEN>, 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.4 (---)

reopen 5293
thanks

Stefan Monnier <monnier@HIDDEN> writes:
>
>> No, just the hooks.  If it makes sense to remove unloaded funcs from
>> hook global values then surely the same rationale applies to remove them
>> from the buffer-local values too.
>
> Agreed.  Someone would have to try it out to see if it can be
> done efficiently.

Reopened for that, or failing that then for clarifying the docstring.

I imagine there's not normally many hooks or many buffers, or many
buffer-local variables, whichever one of those was the efficient way to
scan ... and unload-feature isn't used very much anyway.

(Actually the way unload-feature seems not much used and not getting
much attention from packages makes me wonder if it's worth bothering.
But if unload-feature did a little more then it would increase its
usefulness, perhaps to the point where it would be used more :-)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 16 Jul 2011 18:51:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 16 14:51:03 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Qi9x8-00038k-Qq
	for submit <at> debbugs.gnu.org; Sat, 16 Jul 2011 14:51:03 -0400
Received: from [207.164.135.98] (helo=soln-sr3720.solutionip.com)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1Qi9x7-000382-Fl
	for 5293 <at> debbugs.gnu.org; Sat, 16 Jul 2011 14:51:02 -0400
Received: from [172.22.15.247] (helo=ceviche.home)
	by soln-sr3720.solutionip.com with esmtp (Exim 3.34 #1)
	id 1Qi9x1-0000qw-00; Sat, 16 Jul 2011 14:50:55 -0400
Received: by ceviche.home (Postfix, from userid 20848)
	id E426C660D5; Sat, 16 Jul 2011 14:50:54 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Kevin Ryde <user42@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
Message-ID: <jwvfwm62h9r.fsf-monnier+emacs@HIDDEN>
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN>
Date: Sat, 16 Jul 2011 14:50:54 -0400
In-Reply-To: <871uxsl778.fsf@HIDDEN> (Kevin Ryde's message of "Fri, 15 Jul
	2011 10:26:51 +1000")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 5293
Cc: Juanma Barranquero <lekktu@HIDDEN>, 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

> No, just the hooks.  If it makes sense to remove unloaded funcs from
> hook global values then surely the same rationale applies to remove them
> from the buffer-local values too.

Agreed.  Someone would have to try it out to see if it can be
done efficiently.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 15 Jul 2011 16:22:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 15 12:22:09 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Qhl9Q-0000fC-Hj
	for submit <at> debbugs.gnu.org; Fri, 15 Jul 2011 12:22:09 -0400
Received: from mail-pv0-f172.google.com ([74.125.83.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1Qhl8m-0000da-Fk
	for 5293 <at> debbugs.gnu.org; Fri, 15 Jul 2011 12:21:56 -0400
Received: by pvh18 with SMTP id 18so1401651pvh.3
	for <5293 <at> debbugs.gnu.org>; Fri, 15 Jul 2011 09:21:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	bh=h4hq7HKJOddDQOC5DmsZQ0+E9xaVOPcUt1RMMG3jhJ0=;
	b=Tzup1yqKCD/KfUeJSu0bXD2YoSJ10SlzOWbQjIP+60GwpSs7mEjRDX2Uh4bvIzCzxj
	qJhmiburtkQqDajjXs1W5sgZZ5/fuYPkXaN48dx8jJZj1olpaHVP45VLeBnA6ZoFE8cM
	7ph2xbzrA0iciwhSMg+k/8tbOChyCFkg9/z6M=
Received: by 10.142.234.3 with SMTP id g3mr1543113wfh.423.1310746875128; Fri,
	15 Jul 2011 09:21:15 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.142.144.4 with HTTP; Fri, 15 Jul 2011 09:20:35 -0700 (PDT)
In-Reply-To: <87k4bjedb9.fsf@HIDDEN>
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN>
	<CAAeL0SRwni8KP0CAfw2-bM5Kpa7teSQ44opxWKTKhmxS-wrD-Q@HIDDEN>
	<87oc0wdiy9.fsf@HIDDEN>
	<CAAeL0SS7V1WxuZ4SBmaQUPO+-+2BEH=Cr1yk7L0u7LbLcpi2pQ@HIDDEN>
	<87k4bjedb9.fsf@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Fri, 15 Jul 2011 18:20:35 +0200
Message-ID: <CAAeL0SR=9hd3KQCGraQ6=BBcfsjyQwm=auPm2Q+A0kXPZPqK3Q@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
To: =?UTF-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.5 (---)
X-Debbugs-Envelope-To: 5293
Cc: Kevin Ryde <user42@HIDDEN>, 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.5 (---)

On Fri, Jul 15, 2011 at 18:08, =C5=A0t=C4=9Bp=C3=A1n N=C4=9Bmec <stepnem@gm=
ail.com> wrote:

> Note I omitted the "major" part, i.e., it's not uncommon for minor modes
> to make global hook additions. Sorry if that's not really related to the
> problem at hand.

Currently, minor modes are not automatically turned off; packages that
define minor modes *need* a FEATURE-unload-function. See allout.el,
hi-lock.el, hl-line.el, linum.el, etc. Turning off the minor mode
should remove these hooks.

> The important thing is that the documentation needs to
> describe what actually happens, so whatever you decide to do about this,
> please update the documentation (which, as you confirmed, needs to be
> done anyway).

I agree that the documentation should better reflect what
unload-feature actually does, but I won't be the one writing it. I
suck at that.

=C2=A0 =C2=A0 Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 15 Jul 2011 16:13:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 15 12:13:33 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Qhl1B-000825-FS
	for submit <at> debbugs.gnu.org; Fri, 15 Jul 2011 12:13:33 -0400
Received: from mail-fx0-f42.google.com ([209.85.161.42])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1Qhl18-00081g-Em
	for 5293 <at> debbugs.gnu.org; Fri, 15 Jul 2011 12:13:31 -0400
Received: by fxe23 with SMTP id 23so3551793fxe.29
	for <5293 <at> debbugs.gnu.org>; Fri, 15 Jul 2011 09:13:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=from:to:cc:subject:in-reply-to:references:user-agent:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	bh=wJaC0H38CMQ4sBTQG/IYEFNHlpZdzvzAPTUi5ECPdxU=;
	b=F2ZAi35pNnX+QOLpwxte1haRQnU+xwpJ0XWi7TF/T//XxcRed3b7LlPDZu1VYBPiA2
	NvOf//xjO81GVGFjgSwaDqtNze02a9mPBWZZG0RjJJXZKCyvWcjdRvR6MDmu6dF7xIGd
	dNQaqmjsqOTcbjEe+r6pPO9qYmVhqxyVg1xuE=
Received: by 10.223.21.141 with SMTP id j13mr5524537fab.79.1310746404519;
	Fri, 15 Jul 2011 09:13:24 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id h9sm846835faa.15.2011.07.15.09.13.20
	(version=TLSv1/SSLv3 cipher=OTHER);
	Fri, 15 Jul 2011 09:13:21 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: Juanma Barranquero <lekktu@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
In-Reply-To: <CAAeL0SS7V1WxuZ4SBmaQUPO+-+2BEH=Cr1yk7L0u7LbLcpi2pQ@HIDDEN>
	(Juanma Barranquero's message of "Fri, 15 Jul 2011 13:24:00 +0200")
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN>
	<CAAeL0SRwni8KP0CAfw2-bM5Kpa7teSQ44opxWKTKhmxS-wrD-Q@HIDDEN>
	<87oc0wdiy9.fsf@HIDDEN>
	<CAAeL0SS7V1WxuZ4SBmaQUPO+-+2BEH=Cr1yk7L0u7LbLcpi2pQ@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Date: Fri, 15 Jul 2011 18:08:58 +0200
Message-ID: <87k4bjedb9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 5293
Cc: Kevin Ryde <user42@HIDDEN>, 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

Juanma Barranquero <lekktu@HIDDEN> writes:

> On Fri, Jul 15, 2011 at 10:52, =C5=A0t=C4=9Bp=C3=A1n N=C4=9Bmec <stepnem@=
gmail.com> wrote:
>
>> 1) If your reasoning about hooks being added via modes were correct, you
>> wouldn't have to remove even the global hook additions.
>
> Why? Global additions are not removed when the buffer's major mode is
> switched. Local variables, including local values of hooks, are.

Note I omitted the "major" part, i.e., it's not uncommon for minor modes
to make global hook additions. Sorry if that's not really related to the
problem at hand.

>> If it's faulty
>> (which is probably the case), both global and local hooks need to be
>> managed, as Kevin said.
>
> I'm more of the opinion that both should be un-managed. A look at the
> sources is enough to see that hook removal is currently ugly and
> ad-hoc, and ugly too.

Fine with me, as long as the documentation reflects this.

>> 2) The `unload-feature' docstring says it undoes "any additions that the
>> library has made to hook variables", but that's apparently not what's
>> really happening, so if things stay as they are, the doc string should
>> be corrected.
>
> Yes. The docstring for unload-feature has always promised more than it
> could reasonably accomplish. Yours is only one example.

Please do update it then.

[...]

> Both Kevin and you seem to think that unload-feature should do
> everything and that having to define FEATURE-unload-function is a bug
> or something like that. It is not.  I'm all for making unload-feature
> smarter, as long as it does not trample on the programmer's ability to
> do. I can perfectly well imagine unloading a package but setting a
> hook with an autoloading function from that same package.

Right... I do know about unload functions and use them where
appropriate. The important thing is that the documentation needs to
describe what actually happens, so whatever you decide to do about this,
please update the documentation (which, as you confirmed, needs to be
done anyway).

  =C5=A0t=C4=9Bp=C3=A1n




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 15 Jul 2011 11:24:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 15 07:24:50 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QhgVm-000500-5u
	for submit <at> debbugs.gnu.org; Fri, 15 Jul 2011 07:24:50 -0400
Received: from mail-pz0-f41.google.com ([209.85.210.41])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1QhgVj-0004zn-FM
	for 5293 <at> debbugs.gnu.org; Fri, 15 Jul 2011 07:24:48 -0400
Received: by pzk4 with SMTP id 4so1328658pzk.0
	for <5293 <at> debbugs.gnu.org>; Fri, 15 Jul 2011 04:24:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	bh=GQuZnquTma6KApUzLs0Wy3zbZ1mMFAYW2iT66lvzL4Y=;
	b=EVaYEsCuBilez+ff95PSay+2ha3qxYttuOp5P6k8DZmpfik9LJhzENKVZziDzmJ7XM
	hABZhxcYWcK8KdiJbnfHTUiAq3g5eQL4Wm39fq8j7zA8drAQONBPIYMAQl0L50j9dybI
	Sy70PZZBr9VHwvw/pSB/amuH3l9auDeRFgufk=
Received: by 10.142.222.14 with SMTP id u14mr1431012wfg.309.1310729081370;
	Fri, 15 Jul 2011 04:24:41 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.142.144.4 with HTTP; Fri, 15 Jul 2011 04:24:00 -0700 (PDT)
In-Reply-To: <87oc0wdiy9.fsf@HIDDEN>
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN>
	<CAAeL0SRwni8KP0CAfw2-bM5Kpa7teSQ44opxWKTKhmxS-wrD-Q@HIDDEN>
	<87oc0wdiy9.fsf@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Fri, 15 Jul 2011 13:24:00 +0200
Message-ID: <CAAeL0SS7V1WxuZ4SBmaQUPO+-+2BEH=Cr1yk7L0u7LbLcpi2pQ@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
To: =?UTF-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.3 (---)
X-Debbugs-Envelope-To: 5293
Cc: Kevin Ryde <user42@HIDDEN>, 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.3 (---)

On Fri, Jul 15, 2011 at 10:52, =C5=A0t=C4=9Bp=C3=A1n N=C4=9Bmec <stepnem@gm=
ail.com> wrote:

> 1) If your reasoning about hooks being added via modes were correct, you
> wouldn't have to remove even the global hook additions.

Why? Global additions are not removed when the buffer's major mode is
switched. Local variables, including local values of hooks, are.

> If it's faulty
> (which is probably the case), both global and local hooks need to be
> managed, as Kevin said.

I'm more of the opinion that both should be un-managed. A look at the
sources is enough to see that hook removal is currently ugly and
ad-hoc, and ugly too.

> 2) The `unload-feature' docstring says it undoes "any additions that the
> library has made to hook variables", but that's apparently not what's
> really happening, so if things stay as they are, the doc string should
> be corrected.

Yes. The docstring for unload-feature has always promised more than it
could reasonably accomplish. Yours is only one example.

> 3) Are local hook additions really such a "hard/unstandard" thing to
> undo?

Local hook additions aren't. And they are correctly treated right now.
What we are discussing is local hooks in buffers whose major mode
wasn't also defined in the same feature being unloaded. For example,
things like

;;; my-mode.el

(define-derived-mode my-mode ...)

(defun my-mode-this ()  ...)

(defun my-mode-that ()  ...)

(defun my-mode-hook ()  ...)

(with-current-buffer (get-buffer "some poor unsuspecting buffer"))
   ;;; do not set the buffer major mode to my-mode, but
   (add-hook 'some-hook 'my-mode-hook nil t))

(provide 'my-mode)

;;;; end of my-mode.el


and that kind of thing is unfrequent enough that the better fix is

(defun my-mode-unload-function ()
   (ignore-errors
      (with-current-buffer (get-buffer "some poor unsuspecting buffer")
         (remove-hook 'some-hook 'my-mode-hook t)))
   nil)

Both Kevin and you seem to think that unload-feature should do
everything and that having to define FEATURE-unload-function is a bug
or something like that. It is not.  I'm all for making unload-feature
smarter, as long as it does not trample on the programmer's ability to
do. I can perfectly well imagine unloading a package but setting a
hook with an autoloading function from that same package.

=C2=A0 =C2=A0 Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 15 Jul 2011 08:57:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 15 04:57:04 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QheCl-0001gf-Pi
	for submit <at> debbugs.gnu.org; Fri, 15 Jul 2011 04:57:04 -0400
Received: from mail-fx0-f42.google.com ([209.85.161.42])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QheCj-0001gB-KZ
	for 5293 <at> debbugs.gnu.org; Fri, 15 Jul 2011 04:57:02 -0400
Received: by fxe23 with SMTP id 23so2846304fxe.29
	for <5293 <at> debbugs.gnu.org>; Fri, 15 Jul 2011 01:56:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=from:to:cc:subject:in-reply-to:references:user-agent:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	bh=ol0mEKswTCd8oL5iiOjsugbZdpNNzJTkj+7j9THTZBw=;
	b=gj0146JcqUPg1gi9wEKRs2YTUr5zOkxFACgPpR2N/1ocw7lNJWAjsbDuxysguNdvEf
	EDFgcQcl5nlbjJCvYN0Gb7d6PCuhHlv7GHY/+A1NrK96fVfZu2xbALJgTAimSMltJcxX
	ktjkX+fdHTikQw9jf1un2eoOa+IwIyak4dL/I=
Received: by 10.223.75.25 with SMTP id w25mr1368824faj.140.1310720215464;
	Fri, 15 Jul 2011 01:56:55 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id a24sm652534fak.12.2011.07.15.01.56.52
	(version=TLSv1/SSLv3 cipher=OTHER);
	Fri, 15 Jul 2011 01:56:52 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: Juanma Barranquero <lekktu@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
In-Reply-To: <CAAeL0SRwni8KP0CAfw2-bM5Kpa7teSQ44opxWKTKhmxS-wrD-Q@HIDDEN>
	(Juanma Barranquero's message of "Fri, 15 Jul 2011 02:34:29 +0200")
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN>
	<CAAeL0SRwni8KP0CAfw2-bM5Kpa7teSQ44opxWKTKhmxS-wrD-Q@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Date: Fri, 15 Jul 2011 10:52:30 +0200
Message-ID: <87oc0wdiy9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 5293
Cc: Kevin Ryde <user42@HIDDEN>, 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

Juanma Barranquero <lekktu@HIDDEN> writes:

> On Fri, Jul 15, 2011 at 02:26, Kevin Ryde <user42@HIDDEN> wrote:
>
>> Or conversely, it's undesirable to leave behind an unbound func in a
>> hook, and the same undesirability as to a buffer-local value as a global
>> value.
>
> But the usual case is that these buffer-local values are set via major
> modes also defined in the same package, and so they are automatically
> removed when the major modes are disabled (i.e., when the buffers are
> switched to other major modes). The only case where a buffer-local
> value is left behind is when the package's code sets it in
> non-standard ways, and in this case, it's the package responsability
> to define a FEATURE-unload-function to undo the changes.
>
> The philosophy behind unload-feature is: we try to automatically undo
> the easy/standard things, and give the package the opportunity to undo
> the hard/unstandard things itself. And I think it's the right
> approach.

1) If your reasoning about hooks being added via modes were correct, you
wouldn't have to remove even the global hook additions. If it's faulty
(which is probably the case), both global and local hooks need to be
managed, as Kevin said.

2) The `unload-feature' docstring says it undoes "any additions that the
library has made to hook variables", but that's apparently not what's
really happening, so if things stay as they are, the doc string should
be corrected.

3) Are local hook additions really such a "hard/unstandard" thing to
undo?

  =C5=A0t=C4=9Bp=C3=A1n




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 15 Jul 2011 00:35:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 14 20:35:20 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QhWND-0007Cb-RZ
	for submit <at> debbugs.gnu.org; Thu, 14 Jul 2011 20:35:20 -0400
Received: from mail-pv0-f172.google.com ([74.125.83.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1QhWN8-0007CM-Us
	for 5293 <at> debbugs.gnu.org; Thu, 14 Jul 2011 20:35:19 -0400
Received: by pvh18 with SMTP id 18so752132pvh.3
	for <5293 <at> debbugs.gnu.org>; Thu, 14 Jul 2011 17:35:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	bh=fQc/Rl7OiH4lDiw7QBdvaWpzXcktA/JtWZQ/MFCNMAM=;
	b=ZMtJSADUeRnIccZZP7BqqXrW1p4xJE699hOkZzy11nRjg5FIdS3TV6rq7+y7ZWwI0u
	jDMdbiktGyXOi+DLVTI4J0QJWzIin0IqlzBFMoPKMiY9Xg5P53UqLUC16PLNQNO/x2O9
	+mfexAtFtZIJMBrde/Iw5JWDCptbuJ02AZ2Xc=
Received: by 10.142.120.1 with SMTP id s1mr1265372wfc.252.1310690109115; Thu,
	14 Jul 2011 17:35:09 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.142.144.4 with HTTP; Thu, 14 Jul 2011 17:34:29 -0700 (PDT)
In-Reply-To: <871uxsl778.fsf@HIDDEN>
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	<871uxsl778.fsf@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Fri, 15 Jul 2011 02:34:29 +0200
Message-ID: <CAAeL0SRwni8KP0CAfw2-bM5Kpa7teSQ44opxWKTKhmxS-wrD-Q@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
To: Kevin Ryde <user42@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.5 (---)
X-Debbugs-Envelope-To: 5293
Cc: 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.5 (---)

On Fri, Jul 15, 2011 at 02:26, Kevin Ryde <user42@HIDDEN> wrote:

> Or conversely, it's undesirable to leave behind an unbound func in a
> hook, and the same undesirability as to a buffer-local value as a global
> value.

But the usual case is that these buffer-local values are set via major
modes also defined in the same package, and so they are automatically
removed when the major modes are disabled (i.e., when the buffers are
switched to other major modes). The only case where a buffer-local
value is left behind is when the package's code sets it in
non-standard ways, and in this case, it's the package responsability
to define a FEATURE-unload-function to undo the changes.

The philosophy behind unload-feature is: we try to automatically undo
the easy/standard things, and give the package the opportunity to undo
the hard/unstandard things itself. And I think it's the right
approach.

=C2=A0 =C2=A0 Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 15 Jul 2011 00:28:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 14 20:28:02 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QhWGA-00072H-7o
	for submit <at> debbugs.gnu.org; Thu, 14 Jul 2011 20:28:02 -0400
Received: from mailout2-6.pacific.net.au ([61.8.2.229]
	helo=mailout2.pacific.net.au)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gg@HIDDEN>) id 1QhWG7-000722-Oe
	for 5293 <at> debbugs.gnu.org; Thu, 14 Jul 2011 20:28:00 -0400
Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au
	[61.8.2.163])
	by mailout2.pacific.net.au (Postfix) with ESMTP id 233102BDFC4;
	Fri, 15 Jul 2011 10:27:53 +1000 (EST)
Received: from blah.blah (unknown [203.26.175.98])
	by mailproxy2.pacific.net.au (Postfix) with ESMTP id C1F022741C;
	Fri, 15 Jul 2011 10:27:46 +1000 (EST)
Received: from gg by blah.blah with local (Exim 4.72)
	(envelope-from <gg@HIDDEN>)
	id 1QhWF1-00064H-8A; Fri, 15 Jul 2011 10:26:51 +1000
From: Kevin Ryde <user42@HIDDEN>
To: Juanma Barranquero <lekktu@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
References: <87hbr4p67t.fsf@HIDDEN>
	<CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
Date: Fri, 15 Jul 2011 10:26:51 +1000
In-Reply-To: <CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
	(Juanma Barranquero's message of "Wed, 13 Jul 2011 22:28:02 +0200")
Message-ID: <871uxsl778.fsf@HIDDEN>
User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 5293
Cc: 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.5 (---)

Juanma Barranquero <lekktu@HIDDEN> writes:
>
> but I'm not sure that looking in every buffer-local
> variable of every live buffer

No, just the hooks.  If it makes sense to remove unloaded funcs from
hook global values then surely the same rationale applies to remove them
from the buffer-local values too.

Or conversely, it's undesirable to leave behind an unbound func in a
hook, and the same undesirability as to a buffer-local value as a global
value.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at 5293-done <at> debbugs.gnu.org:


Received: (at 5293-done) by debbugs.gnu.org; 13 Jul 2011 20:28:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 13 16:28:51 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Qh639-0006Qr-2K
	for submit <at> debbugs.gnu.org; Wed, 13 Jul 2011 16:28:51 -0400
Received: from mail-pv0-f172.google.com ([74.125.83.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1Qh636-0006Qf-26
	for 5293-done <at> debbugs.gnu.org; Wed, 13 Jul 2011 16:28:48 -0400
Received: by pvh18 with SMTP id 18so5391597pvh.3
	for <5293-done <at> debbugs.gnu.org>; Wed, 13 Jul 2011 13:28:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type:content-transfer-encoding;
	bh=ZclQL+eMsDPNHAKvE/ISyRKGSzccaB7Ng3kObyg93JQ=;
	b=tQMRHEYDmP4bSFQ5Fk7u12t7XZ/TUfYFHWwEtxl03aeSGvexFaLXtS4ac6ML8zdxwO
	qUdf1+DyVgDq2fi/U/dq1w95ARr/rQ0H4n+jvEAJpqAMldoHd7eny5c8AH2d4O4MAb1e
	b4ZrZxoTn+UkFt355FBRFkpTMJzDpiSXcEGK8=
Received: by 10.142.222.14 with SMTP id u14mr636339wfg.309.1310588922109; Wed,
	13 Jul 2011 13:28:42 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.142.144.4 with HTTP; Wed, 13 Jul 2011 13:28:02 -0700 (PDT)
In-Reply-To: <87hbr4p67t.fsf@HIDDEN>
References: <87hbr4p67t.fsf@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Wed, 13 Jul 2011 22:28:02 +0200
Message-ID: <CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
To: Kevin Ryde <user42@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.4 (---)
X-Debbugs-Envelope-To: 5293-done
Cc: 5293-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.4 (---)

> Evalling the code in try-foo.el below loads then unloads foo.el. =C2=A0It
> gets an error
>
> =C2=A0 =C2=A0void-function foo-message
>
> where I hoped unload-feature might have purged that `foo-message' from
> `after-change-functions'.
>
> I suppose looking in all buffers is more work for unload-feature, but
> would be a good protection against bad things happening later. =C2=A0I ex=
pect
> some of the standard hooks like `after-change-functions' are used
> buffer-local most of the time.

You're right that some hooks are used buffer-locally most of the time,
but it's also true that in many cases they are used from a major mode,
i.e., in your case, if foo.el defined a foo-mode and set
`after-change-functions' locally in foo-mode buffers, unload-feature
would do OK (with the current trunk, not any released Emacsen).

As it is, foo.el is doing something non-standard, and unload-feature
cannot try to revert by itself every non-standard thing packages do.
That's why FEATURE-unload-function exists. So, in this case, the right
fix would be adding this function to foo.el:

(defun foo-unload-function ()
  "Unload foo.el."
  (ignore-errors
    (with-current-buffer (get-buffer "foo-buffer")
      (remove-hook 'after-change-functions 'foo-message t)))
  ;; continue standard unloading
  nil)

That said, there are improvements that could be made to unload-feature
(for example, trying to automatically deactivate minor modes being
undefined), but I'm not sure that looking in every buffer-local
variable of every live buffer is a sensible thing to do. I'm closing
this one because it is not really a bug. We can open a wishlist bug
for unload-feature is you want.

=C2=A0 =C2=A0 Juanma




Notification sent to Kevin Ryde <user42@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Juanma Barranquero <lekktu@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 5293 <at> debbugs.gnu.org:


Received: (at 5293) by debbugs.gnu.org; 2 Jan 2010 23:14:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 02 18:14:57 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1NRDBR-0000Ig-7q
	for submit <at> debbugs.gnu.org; Sat, 02 Jan 2010 18:14:57 -0500
Received: from mail-bw0-f216.google.com ([209.85.218.216])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <lekktu@HIDDEN>) id 1NRDBP-0000IY-SR
	for 5293 <at> debbugs.gnu.org; Sat, 02 Jan 2010 18:14:56 -0500
Received: by bwz8 with SMTP id 8so9024201bwz.39
	for <5293 <at> debbugs.gnu.org>; Sat, 02 Jan 2010 15:14:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:received:in-reply-to:references
	:from:date:message-id:subject:to:cc:content-type;
	bh=NR/ZNTd+BSie+/9MvQp8Gq4OE64LTY3uiNJE+y+s56M=;
	b=xV16rP6PYdEuYUN+MP61zUo9kobFFDvGFv0fLknR9wc6ocR76JNhC8aP7FEHzi5zDP
	XatjSNeITiRBtUqwc6Q7eh7Xc4szSn7HoLhNQLzvdt0KV+HOvA3a1cg7xmP0FJnEglWp
	oRRDyxSzh3hvWP7NT/p1nfvYyfdj5jOLRqvYM=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc:content-type;
	b=naLPMCES3zERIiYtaNfUAE/01SLVrJrx8A3v8USE1jHe8Vb1YMmQCCM7zyYasgu8X3
	wDO/82ltx9Rt0Peo0BL/LINhif98lziMYazFBBa2LwQ5nexK6FcvzzKpwll+H/JKXBXi
	ao3t2LZzXV1MXfULUXZ+oOXgvg650Ymp7ikrQ=
MIME-Version: 1.0
Received: by 10.204.8.151 with SMTP id h23mr2473823bkh.194.1262474091108; Sat, 
	02 Jan 2010 15:14:51 -0800 (PST)
In-Reply-To: <87hbr4p67t.fsf@HIDDEN>
References: <87hbr4p67t.fsf@HIDDEN>
From: Juanma Barranquero <lekktu@HIDDEN>
Date: Sun, 3 Jan 2010 00:14:31 +0100
Message-ID: <f7ccd24b1001021514uf98ee51ifcff27bd21aa3436@HIDDEN>
Subject: Re: bug#5293: 23.1; unload-feature on buffer-local hooks
To: Kevin Ryde <user42@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 5293
Cc: 5293 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

On Sat, Jan 2, 2010 at 22:06, Kevin Ryde <user42@HIDDEN> wrote:

> When `unload-feature' looks in hooks for functions that it's going to
> unload, it doesn't seem to look in buffer-local values, other than for
> the current buffer.
[...]
> I suppose looking in all buffers is more work for unload-feature, but
> would be a good protection against bad things happening later.

Yes, unload-feature should look at buffer-local values, too.

For the moment being, a package like foo should define a function (foo
in the function name matches the feature name you're unloading):

(defun foo-unload-function ()
  ;; do whatever is necessary; in foo's case:
  (with-current-buffer (get-buffer "foo-bufer")
    (remove-hook 'after-change-functions 'foo-message t))
  ;; continue standard unloading
  nil)

that will be automatically called upon unloading foo.el; in most
cases, it should return nil to allow unload-feature to continue the
normal unloading process.

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Jan 2010 21:06:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 02 16:06:35 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1NRBBD-0007l8-Jr
	for submit <at> debbugs.gnu.org; Sat, 02 Jan 2010 16:06:35 -0500
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gg@HIDDEN>) id 1NRBBC-0007l2-45
	for submit <at> debbugs.gnu.org; Sat, 02 Jan 2010 16:06:34 -0500
Received: from mail.gnu.org ([199.232.76.166]:33175 helo=mx10.gnu.org)
	by fencepost.gnu.org with esmtp (Exim 4.69)
	(envelope-from <gg@HIDDEN>) id 1NRBB8-0000nL-0U
	for submit <at> debbugs.gnu.org; Sat, 02 Jan 2010 16:06:30 -0500
Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim
	4.60) (envelope-from <gg@HIDDEN>) id 1NRBB5-0001Rx-IJ
	for submit <at> debbugs.gnu.org; Sat, 02 Jan 2010 16:06:29 -0500
X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on monty-python
X-Spam-Level: 
X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,
	FORGED_RCVD_HELO,UNPARSEABLE_RELAY autolearn=ham version=3.1.0
Received: from lists.gnu.org ([199.232.76.165]:52737)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <gg@HIDDEN>) id 1NRBB5-0001Rp-Af
	for submit <at> debbugs.gnu.org; Sat, 02 Jan 2010 16:06:27 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NRBB5-0000Bf-8s
	for bug-gnu-emacs@HIDDEN; Sat, 02 Jan 2010 16:06:27 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NRBB0-00005t-C2
	for bug-gnu-emacs@HIDDEN; Sat, 02 Jan 2010 16:06:26 -0500
Received: from [199.232.76.173] (port=60117 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NRBB0-00005h-7x
	for bug-gnu-emacs@HIDDEN; Sat, 02 Jan 2010 16:06:22 -0500
Received: from mailout2-16.pacific.net.au ([125.255.80.143]:45346
	helo=mailout2.pacific.net.au)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <gg@HIDDEN>) id 1NRBAz-0001Od-DP
	for bug-gnu-emacs@HIDDEN; Sat, 02 Jan 2010 16:06:21 -0500
Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au
	[61.8.2.162])
	by mailout2.pacific.net.au (Postfix) with ESMTP id E309E19C063
	for <bug-gnu-emacs@HIDDEN>; Sun,  3 Jan 2010 08:06:18 +1100 (EST)
Received: from blah.blah (ppp2155.dyn.pacific.net.au [61.8.33.85])
	by mailproxy1.pacific.net.au (Postfix) with ESMTP id DA3DF5BE401
	for <bug-gnu-emacs@HIDDEN>; Sun,  3 Jan 2010 08:06:17 +1100 (EST)
Received: from gg by blah.blah with local (Exim 4.71)
	(envelope-from <gg@HIDDEN>) id 1NRBAt-000230-6Y
	for bug-gnu-emacs@HIDDEN; Sun, 03 Jan 2010 08:06:15 +1100
From: Kevin Ryde <user42@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 23.1; unload-feature on buffer-local hooks
Date: Sun, 03 Jan 2010 08:06:14 +1100
Message-ID: <87hbr4p67t.fsf@HIDDEN>
User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6,
	seldom 2.4 (older, 4)
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6,
	seldom 2.4 (older, 4)
X-Spam-Score: -5.4 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.5 (-----)

--=-=-=

When `unload-feature' looks in hooks for functions that it's going to
unload, it doesn't seem to look in buffer-local values, other than for
the current buffer.

Evalling the code in try-foo.el below loads then unloads foo.el.  It
gets an error

    void-function foo-message

where I hoped unload-feature might have purged that `foo-message' from
`after-change-functions'.

I suppose looking in all buffers is more work for unload-feature, but
would be a good protection against bad things happening later.  I expect
some of the standard hooks like `after-change-functions' are used
buffer-local most of the time.

If instead it's an intentional omission (to save work) then the elisp
manual and the docstring could note it so that modes or packages using
buffer-local hook settings can take steps to undo.



--=-=-=
Content-Type: application/emacs-lisp
Content-Disposition: attachment; filename=foo.el
Content-Transfer-Encoding: quoted-printable

(defun foo-message (&rest args)
  (message "hello"))

(switch-to-buffer "foo-buffer")
(add-hook 'after-change-functions 'foo-message
          nil
          t) ;; buffer-local

(provide 'foo)

;;; foo.el ends here

--=-=-=
Content-Type: application/emacs-lisp
Content-Disposition: attachment; filename=try-foo.el
Content-Transfer-Encoding: quoted-printable

(progn
  (add-to-list 'load-path (expand-file-name "."))
  (load "foo.el")

  (switch-to-buffer "*scratch*")
  (unload-feature 'foo t)

  (switch-to-buffer "foo-buffer")
  (insert "x"))


--=-=-=




In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
 of 2009-09-14 on raven, modified by Debian
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_AU
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-1-unix
  default-enable-multibyte-characters: t

--=-=-=--





Acknowledgement sent to Kevin Ryde <user42@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#5293; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 1 Mar 2019 01:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.