[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: |
Mon, 14 Dec 2009 22:59:02 +0300 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
pjb@informatimago.com (Pascal J. Bourguignon) writes:
> Sergei Organov <osv@javad.com> writes:
>
>> You see, I wanted automatic elisp-only solution to "fixing"
>> ewoc-collect, but only if it indeed happens to be buggy. Manual
>> reloading is not an option then. Alternate approach would be to execute
>> simple test-case to determine if ewoc-collect is indeed buggy and then
>> re-define it to the correct version if so. That's what I'm going to
>> implement now, provided there doesn't seem to be a way to do what I want
>> by means of advising ewoc-collect and nreverse.
>
> I see.
>
[...]
> or else, if you can detect the broken version with a test:
>
> (require 'ewoc)
> (unless (equal 'expected-result
> (ewoc-collect 'test-arguments))
> (defun ewoc-collect (...)
> ...))
>
> (you can add a (byte-compile 'ewoc-collect) after the defun in either
> case if you need it fast).
Exactly. After realizing with your help that I'll have no luck with
defadvicing nreverse, I finally ended up with the following simple
solution:
;; Fix buggy `ewoc-collect' by reversing its result. Nothing will be
;; changed if `ewoc-collect' is fine.
(require 'ewoc)
(with-temp-buffer
(let ((ewoc (ewoc-create (lambda (elem) ()))))
(ewoc-enter-last ewoc 0) (ewoc-enter-last ewoc 1)
(if (equal 1 (car (ewoc-collect ewoc (lambda (elem) t))))
(defadvice ewoc-collect (after ewoc-collect-reverse activate compile)
"Reverse the result to compensate for buggy implementation."
(setq ad-return-value (nreverse ad-return-value))))))
I still wonder if it's documented somewhere in some manual when
defadvice doesn't actually work. It seems it is not there in the Elisp
manual, or did I miss it?
--
Sergei.
- Problem advising nreverse., Sergei Organov, 2009/12/11
- Re: Problem advising nreverse., Pascal J. Bourguignon, 2009/12/12
- Message not available
- Re: Problem advising nreverse., Pascal J. Bourguignon, 2009/12/14
- Re: Problem advising nreverse., Sergei Organov, 2009/12/14
- Message not available
- Re: Problem advising nreverse., Pascal J. Bourguignon, 2009/12/14
- Re: Problem advising nreverse.,
Sergei Organov <=
- Message not available
- Re: Problem advising nreverse., Pascal J. Bourguignon, 2009/12/14
- Re: Problem advising nreverse., Sergei Organov, 2009/12/15
- Re: Problem advising nreverse., Sergei Organov, 2009/12/15
- Message not available
- Re: Problem advising nreverse., Pascal J. Bourguignon, 2009/12/15
- Message not available
- Re: Problem advising nreverse., Barry Margolin, 2009/12/15
- Re: Problem advising nreverse., Sergei Organov, 2009/12/16
- Message not available
- Re: Problem advising nreverse., Barry Margolin, 2009/12/17