From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Can el-search-query-replace replace mapcar with --map ? Date: Sat, 23 Dec 2017 15:03:36 +0100 Message-ID: <87a7y94k3r.fsf@web.de> References: <87a7yahebe.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1514037754 32485 195.159.176.226 (23 Dec 2017 14:02:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 23 Dec 2017 14:02:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Chunyang Xu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 23 15:02:30 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSkNi-0007dj-8p for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 15:02:30 +0100 Original-Received: from localhost ([::1]:42096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSkPa-0003KA-9L for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 09:04:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSkP1-0003Jz-F0 for help-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:03:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSkOw-0006ex-Hw for help-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:03:51 -0500 Original-Received: from mout.web.de ([212.227.17.12]:64324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eSkOw-0006eE-81 for help-gnu-emacs@gnu.org; Sat, 23 Dec 2017 09:03:46 -0500 Original-Received: from drachen.dragon ([88.74.120.211]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MNcIg-1eLcaR0Aaw-007Hba; Sat, 23 Dec 2017 15:03:37 +0100 In-Reply-To: (Chunyang Xu's message of "Sat, 23 Dec 2017 14:17:25 +0800") X-Provags-ID: V03:K0:AsZSWcm4V3QctNNV7xQOuz6cizcqwv0y8fHP95Qm1nBz7IeRww8 QOThsEIK+rdkAZsV5puq3URekU9gFDYJ8SP0KWl/cDuZPLqlOt62TSir2Z30zoVlJt9c5n+ SMOoRi0l1J612EbHnMfcIjCWwi4dl0gPnZ6mLoTb4qSjx73Gb7itWSpIqqGU3M/kTUbR6Ds Q4+Z7XqU28VfnOM+1p0sw== X-UI-Out-Filterresults: notjunk:1;V01:K0:QlBnAcJnDkI=:ERuhthBVttiEwjmCi8MmuK QLr0ypVTPvILcgpETMfrDu7P2/WnVKPMc8dJx4V30NRMoDRGh6P7D8lY080wE4btgj459ApHo WEYKh97JqXBSdM/xOEU5PBHUTCX6FlvHLa1e5ub8dYUvQx+lpr+mTVSczKSPpYe8Wknv/1yMn aNWQv90lpa9kQQPSbV+XvQETb/p02NzwtpBLvRvZdKc3ybFnEuEEcOWEoWcxmNWDjcbvF39pC iZR1Cke4+izPwrHCg2i86rJrcdrDM3hkA/1Jn5YBaV+rVx+Hp0VH1c2fgFonFx0DfPbS6JE9w wxHCixRfaLBgmS/uGa5Yfdf2QrlFvIFKUeW44M3RhaNxWicbVQBxF96Hk+oj30GVCe5MOR46s BLYNUQN6RqDpFm/hlWX35bH3LM/1KKh5JsPnf4JDNtkKhoVivI3WkO31YbDaaKK89Y7X3/Kud hwGhv3b85wYTEOWEs4EF8MrzSGFzR38BJuUpD4+IS83d1E4jF95DE6Bec0cCsPYZAjd9BcrTi nPlo4veNPsJq5+BV3L6fcLNc1bajlRdwhs4faAIhNr4fr4JDMrXi2eF/0FhImnv3PxeSrM3Tf 9mlTHmBSyV/UBFqmhKfRYSXaGanr8RwYHBiepxLahzRHmoCRFEqS4InxUi5VYjlx2P+EjJ2G1 9IG9e0+hGLNFGEOfCgET2ToLqo6gVslfCwXgJi1z+JTRXVi5fqdvXsHkAyFvZK3DkkIqFLx8/ jE6DKgfIGnDXldjEDZ4ZtM5YwCprc6nO5kF7+Wy7/fp5hm6l/hlFejaYNMJvvoSeUG/GRD5+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:115436 Archived-At: Chunyang Xu writes: > It works fine for my example: > > (mapcar (lambda (x) (* x x)) '(1 2 3)) > > but not > > (mapcar (lambda (x) (let ((x (1+ x))) (* x x))) '(1 2 3)) > > with the exact same patterns, 'el-search-query-replace' reports > > el-search--format-replacement: Error in > =E2=80=98el-search--format-replacement=E2=80=99 - please make a bug rep= ort > > I guess this is excepted by you, even though > 'transform-lambda-form-for---map' is correct for both cases: > > (transform-lambda-form-for---map > (lambda (x) (* x x))) > =3D> (* it it) > > (transform-lambda-form-for---map > (lambda (x) (let ((x (1+ x))) (* x x)))) > =3D> (let ((x (1+ it))) (* x x)) It's not that simple. If you bind print-circle and print-gensym to t, you see that `symbol-macrolet' renames the let-bound variable x to an uninterned symbol: #+begin_src emacs-lisp (transform-lambda-form-for---map '(lambda (x) (let ((x (1+ x))) (* x x)))) =3D=3D> (let ((#1=3D#:x (1+ it))) (* #1# #1#)) #+end_src The current version of el-search doesn't yet allow uninterned symbols in the replacement. The result is not what you want in your case anyway. As I said - making every case work correctly would need something more complicated than what I had suggested. > By the way, is there a way to tidy the code after > 'el-search-query-replace' ? For the same example above, it produces > > (--map > (* it it) > '(1 2 3)) > > but I want > > (--map (* it it) '(1 2 3)) > > right now I have to do it manually via M-^ ('delete-indentation'), which > is not very convenient. I know about that problem, but currently, you must do it manually. el-search currently use "pp.el" to format the replacement. It is not very sophisticated, I want to replace it with something better in the future. Nobody has written a nicer printer yet. Printing an expression that is lisp code in a way that is appealing to humans is a challenge of its own. Regards, Michael.