help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Problem advising nreverse.


From: Sergei Organov
Subject: Re: Problem advising nreverse.
Date: Tue, 15 Dec 2009 15:02:39 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:

> [I'm responding to this message, because subsequently the thread spun out of
> control beyond my comprehension.]
>
> Sergei Organov wrote:
>> pjb@informatimago.com (Pascal J. Bourguignon) writes:
> ...
>>> Redefining nreverse and reloading the ewoc-collect function would help
>>> as indicated...
>>
>> Yeah, but:
>>
>> 1. I don't really want `nreverse' to be always redefined.
>
> If you know the bug is in ewoc, you don't want nreverse redefined ever.
>
>> 2. I don't know how to reload `ewoc-collect' (from elisp) provided it's
>>    already byte-compiled.
>
> Put the new defun in a file and explicitly reload it.

Copy-paste the original and fix that? This has its own drawbacks. Think
what will happen when new version of the package with incompatible
function appears.

>> Here what I've actually originally tried (that didn't work):
>>
>> (defadvice ewoc-collect (around fix-ewoc-collect activate)
>>   "Fix buggy `ewoc-collect' by reversing its result provided it
>>    was altered by `nreverse'."
>>   (let ((last-nreverse-result))
>>     (unwind-protect
>>         (progn
>>           (defadvice nreverse (after notice-nreverse activate)
>>             (setq last-nreverse-result ad-return-value))
>>           ad-do-it)
>
> ad-do-it is not a variable: it is a form that can only be meaningfully
> referenced *within* a defadvice form.

But it *is* within 'fix-ewoc-collect' defadvice form (look at top-level).

>
>>       (ad-unadvise 'nreverse))
>>     (if (eq last-nreverse-result ad-return-value)
>>         (setq ad-return-value (nreverse ad-return-value)))))
>
> I don't understand: How can you determine whether any value "was
> altered by nreverse"?  That is not Lispish thinking.

Yeah, probably it is not Lispish. Another option was to make 'nreverse'
a no-op for duration of 'ewoc-collect' call, but that didn't work
either, apparently due to the same reason defadvice of nreverse doesn't
work.

-- 
Sergei.





reply via email to

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