From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: general perform-replace REPLACEMENTS arg for regexpquery-replacement? Date: Tue, 18 Nov 2008 15:20:00 -0800 Message-ID: <001701c949d4$2e1d5b20$0200a8c0@us.oracle.com> References: <005901c94752$06ca6e70$0200a8c0@us.oracle.com><005b01c94771$e8129be0$0200a8c0@us.oracle.com><877i73p9ia.fsf@jurta.org><001a01c94853$5a0ee1e0$0200a8c0@us.oracle.com><873ahq3r0k.fsf@jurta.org><000101c94919$250e6440$0ab32382@us.oracle.com> <871vx865ld.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1227050422 29532 80.91.229.12 (18 Nov 2008 23:20:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Nov 2008 23:20:22 +0000 (UTC) Cc: emacs-devel@gnu.org To: "'Juri Linkov'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 19 00:21:23 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L2Zso-0007QU-Fd for ged-emacs-devel@m.gmane.org; Wed, 19 Nov 2008 00:21:22 +0100 Original-Received: from localhost ([127.0.0.1]:41821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2Zrf-0006FB-OQ for ged-emacs-devel@m.gmane.org; Tue, 18 Nov 2008 18:20:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L2Zra-0006F3-VQ for emacs-devel@gnu.org; Tue, 18 Nov 2008 18:20:07 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L2ZrZ-0006EI-V8 for emacs-devel@gnu.org; Tue, 18 Nov 2008 18:20:05 -0500 Original-Received: from [199.232.76.173] (port=49833 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2ZrZ-0006EF-Jk for emacs-devel@gnu.org; Tue, 18 Nov 2008 18:20:05 -0500 Original-Received: from rcsinet11.oracle.com ([148.87.113.123]:52091 helo=rgminet11.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L2ZrZ-00082t-Fo for emacs-devel@gnu.org; Tue, 18 Nov 2008 18:20:06 -0500 Original-Received: from rgminet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rgminet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mAINKd09001654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Nov 2008 23:20:40 GMT Original-Received: from acsmt705.oracle.com (acsmt705.oracle.com [141.146.40.83]) by rgminet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id mAINK4WB021886; Tue, 18 Nov 2008 23:20:05 GMT Original-Received: from dradamslap1 (/141.144.52.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 18 Nov 2008 23:19:58 +0000 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <871vx865ld.fsf@jurta.org> Thread-Index: AclJy7H7n3apHF68RmiOEdnOTh/HcgAAFXEw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Source-IP: acsmt705.oracle.com [141.146.40.83] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090208.49234DA0.00A1:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:105792 Archived-At: > >> The only place currently preventing this is > >> prin1-to-string that turns a list into a string. > >> We could change it to keep the list intact. > > > > Yes, but then you lose the ability to get the current > > behavior: replace by the string, "(\"zzz\" \"aaa\")". > > When you want to replace by the string, you don't need `\,'. What if it's \,(list "zzz" "aaa") or some hairy sexp that evals to the same list ("zzz" "aaa")? You snipped the part about the string being the result of Lisp evaluation. Currently \, evals the sexp that follows it and then `prin1-to-string's it to come up with a replacement string. Is that a useful feature: being able to replace text by the print representation of a Lisp value that is the result of evaluation? If so, shouldn't it still be allowed in case the result of evaluation is a list of strings? I'm not sure it's super important as a feature, but why not keep it? Why lose that just to favor a particular syntax choice? I don't feel strongly about that existing feature, and I don't feel strongly about which syntax we use. I am in favor of the new feature I proposed. Beyond that, I would point out that, IIUC, what you suggest means losing some current functionality. That's all. > > IMO, two different syntaxes are needed to separate the two > > different user intentions: a sexp that evals to a string "(...)" > > and a sexp that evals to a list of strings to pass to > > `perform-replace'. > > There two syntaxes naturally are `\,(' and `\,'('. Perhaps we're miscommunicating. \, evals the sexp that follows it. In your first case, the sexp is presumably a function application or (). In your second case, the sexp is a quoted list. What should \, then do with the result of evaluation? Currently \, just uses prin1 to convert the result to a string to use as replacement. Would you have it do something different depending on the type of evaluation result? Would you have it always pass the result on to `perform-replace', as is, whenever it is a list of strings, but otherwise convert it to a string (as now)? That is, would you treat \,(list "a" "b") and \,'("a" "b") the same (pass two replacement strings to perform-replace) but different from \,(list 2 3) (pass the single string "(2 3)" to perform-replace)? That doesn't sound too reasonable to me. Or are you suggesting to explicitly look for the ( and '( as part of the \, syntax? Do you mean that \,'( would always pass the list that is quoted to `perform-replace', and never convert it to a string for replacement? If so, would you check whether the list elements were strings? Or would you always convert the elements in the quoted list to strings to be sure, so that \,'(2 3) would pass the list of replacement strings ("2" "3")? Just what you're proposing is not clear. If it's something like what I've guessed above, then I'd say: (1) The expressions will be less readable than if we more clearly separate the two syntax possibilities, instead of trying to use \, to introduce both. (2) Its use will be error-prone, because of the similarity in appearance. Maybe you can give a concrete example or two, to make clear what you're saying. I'm open on (1) the syntax to use and (2) whether or not to keep the current possibility of evaling to a Lisp value and then prin1-ing that to a replacement string - including in the case where the eval result is a list of strings. I'd prefer a clean separation of syntax: \, for Lisp evaluation and `prin1-to-string' conversion (always), and something else (dissimilar visually) for passing a list of strings to `perform-replace'. I proposed \@ and later \( for the latter, but I don't much care what we pick. I don't however favor something that starts, as does Lisp evaluation, with \, - too confusing for users, too complex as code, and seemingly a loss of some current functionality. And I don't see any advantage from such a choice.