From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sergei Organov Newsgroups: gmane.emacs.help Subject: Re: Problem advising nreverse. Date: Mon, 14 Dec 2009 22:59:02 +0300 Message-ID: References: <87skbg8jww.fsf@galatea.local> <87bpi1n1z7.fsf@galatea.local> <873a3dmvef.fsf@galatea.local> <87pr6hl9s4.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1260820814 4658 80.91.229.12 (14 Dec 2009 20:00:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Dec 2009 20:00:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 14 21:00:04 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NKH5P-0005E3-Mp for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Dec 2009 21:00:04 +0100 Original-Received: from localhost ([127.0.0.1]:52344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKH5P-0002Cn-7n for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Dec 2009 15:00:03 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKH51-0002CG-3h for help-gnu-emacs@gnu.org; Mon, 14 Dec 2009 14:59:39 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKH4w-0002Ag-B7 for help-gnu-emacs@gnu.org; Mon, 14 Dec 2009 14:59:38 -0500 Original-Received: from [199.232.76.173] (port=41500 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKH4w-0002Ad-5N for help-gnu-emacs@gnu.org; Mon, 14 Dec 2009 14:59:34 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:34315) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NKH4v-0005Nk-Le for help-gnu-emacs@gnu.org; Mon, 14 Dec 2009 14:59:33 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1NKH4o-0004yr-Jw for help-gnu-emacs@gnu.org; Mon, 14 Dec 2009 20:59:26 +0100 Original-Received: from 89.175.180.246 ([89.175.180.246]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 14 Dec 2009 20:59:26 +0100 Original-Received: from osv by 89.175.180.246 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 14 Dec 2009 20:59:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 89.175.180.246 User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70644 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) writes: > Sergei Organov 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.