emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comint-carriage-motion causes severe problems.


From: Stefan Monnier
Subject: Re: comint-carriage-motion causes severe problems.
Date: Thu, 04 Jul 2002 11:43:14 -0400

> However, I now believe that there is an even better solution which not
> only removes the arbitrariness in the above example, but moreover
> removes any danger of breaking existing code, which otherwise seems
> to be a very real danger, and which also adds useful flexibility.
> 
> Indeed, I now start to get really weary about breaking existing code
> where people rely on the fact that remove-hook "does no harm anyway"
> if bar is not in the local value of foo and hence it does not matter
> whether
> 
> (remove-hook 'foo 'bar 'local) 
> 
> is executed several times if a file is accidentally loaded more than
> once.

This fear is unfounded.  I have been using my hacked Emacs with this
feature for at least a year with no problem and I have grepped
through the code to try and see what kind of behavior is expected,
and the fact is that hooks are added either only globally or only
locally.  And since my code only adds a (not . BAR) if we're removing
it locally and it is present globally, that means that my code is
almost never activated.  I hactually have a (debug) call in my code
to see when a (not . BAR) happens, and the very few times it has
happened have all been right.

> Depending on peoples' style, current code may contain third non-nil
> arguments of t or 'local, as you use, but I can not possibly see how
> people would have used a third argument 'override anywhere.  (Unless
> they were actually anticipating your code.)  Hence, all worries about
> breaking existing code would be gone, the worry about arbitrariness in
> cases of the type you describe is gone, the worry about bad things
> happening if files get accidentally loaded more than once is totally
> gone and we have, moreover, better flexibility.

I'm not sure what you mean by "better flexibility".  My "arbitrary"
choice is not so arbitrary in that it tries to maintain compatibility
and it also has the advantage of still allowing the other behavior.
I.e. if you really want to make sure that the hook function will not
be run, like your `override' argument would do, you can just do

        (remove 'foo 'bar 'local)
        (remove 'foo 'bar 'local)

where the first call will remove any local ocurrence and the second
will override any remaining global ocurrence.

So I'm not sure if we really get more flexibility and if the
added complexity is warranted.  I see the current behavior of
(remove 'foo 'bar 'local) as a bug and my patch as a bug-fix.
This impression is partly based on the (very few) cases where the
code was triggered to insert (not . BAR).


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]