From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bill Wohler Newsgroups: gmane.emacs.devel,gmane.mail.mh-e.devel Subject: Re: Where to put fix for #22317, mh-e: wrong usage of cl-flet Date: Mon, 30 May 2016 17:04:51 -0700 Organization: Newt Software Message-ID: <87vb1vqeho.fsf@olgas.newt.com> References: <83602.1462155588@olgas.newt.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1464653138 10456 80.91.229.3 (31 May 2016 00:05:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 31 May 2016 00:05:38 +0000 (UTC) Cc: mh-e-devel@lists.sourceforge.net To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 31 02:05:28 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b7XBW-00064N-S7 for ged-emacs-devel@m.gmane.org; Tue, 31 May 2016 02:05:27 +0200 Original-Received: from localhost ([::1]:33673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7XBW-000437-0C for ged-emacs-devel@m.gmane.org; Mon, 30 May 2016 20:05:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7XBI-0003zU-JD for emacs-devel@gnu.org; Mon, 30 May 2016 20:05:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7XBD-0005IB-KF for emacs-devel@gnu.org; Mon, 30 May 2016 20:05:12 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:58149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7XBD-0005Gj-DT for emacs-devel@gnu.org; Mon, 30 May 2016 20:05:07 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b7XB9-0005tt-Lx for emacs-devel@gnu.org; Tue, 31 May 2016 02:05:03 +0200 Original-Received: from c-73-15-2-218.hsd1.ca.comcast.net ([73.15.2.218]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 31 May 2016 02:05:03 +0200 Original-Received: from wohler by c-73-15-2-218.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 31 May 2016 02:05:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 45 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-73-15-2-218.hsd1.ca.comcast.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:OnfykfwxJBqUCxMrmA9ZHARlqKM= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204152 gmane.mail.mh-e.devel:13895 Archived-At: Stefan Monnier writes: >> +(defmacro mh-flet (bindings &rest body) >> + "Make temporary overriding function definitions. >> +This is an analogue of a dynamically scoped `let' that operates on >> +the function cell of FUNCs rather than their value cell. >> + >> +\(fn ((FUNC ARGLIST BODY...) ...) FORM...)" >> + (if (fboundp 'cl-letf) >> + `(cl-letf ,(mapcar (lambda (binding) >> + `((symbol-function ',(car binding)) >> + (lambda ,@(cdr binding)))) >> + bindings) >> + ,@body) >> + `(flet ,bindings ,@body))) > > As long as you use (require 'cl), then I see no reason to stop using `flet'. > If you're annoyed by the warning, then add a `with-no-warnings'. > Or use `letf' unconditionally. > > The other option is to stop using (require 'cl) and start using (require > 'cl-lib) instead, in which case you'll want to always use cl-letf. > `cl-lib' is distributed in GNU ELPA and should work on XEmacs and Emacsā‰„22. > > In neither of those 3 solutions do you need to switch between > 2 different expansions. > >> +(put 'mh-flet 'lisp-indent-function 1) >> +(put 'mh-flet 'edebug-form-spec >> + '((&rest (sexp sexp &rest form)) &rest form)) > > I think even the oldest emacsen you support can handle > > (declare (indent 1) (debug ((&rest (sexp sexp &rest form)) &rest form))) > > so I recommend you use that instead. I just committed Katsumi's version to the emacs-25 branch as it had been well tested. I'd be interested in hearing his opinion on your suggestions to improve the code. -- Bill Wohler aka http://www.newt.com/wohler/ GnuPG ID:610BD9AD