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

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

Re: Problem advising nreverse.


From: Kevin Rodgers
Subject: Re: Problem advising nreverse.
Date: Tue, 15 Dec 2009 01:19:34 -0700
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

[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.

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.

      (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.

This starts to work as soon as I re-evaluate the (defun ewoc-collect
...) in the ewoc.el file after the above defadvice is evaluated and
continues to work even if I byte-compile the (defun ewoc-collect...)
after that (though I still don't understand why it works after
byte-compiling), but then it's both easier and cleaner to just re-define
ewoc-collect to a correct version.

-- Sergei.






--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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