From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Easier way to edit a splitted long string Date: Fri, 04 Oct 2013 23:55:33 +0200 Organization: Informatimago Message-ID: <877gdswvje.fsf@informatimago.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380924034 31066 80.91.229.3 (4 Oct 2013 22:00:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Oct 2013 22:00:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 05 00:00:38 2013 Return-path: Envelope-to: geh-help-gnu-emacs@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 1VSDQL-0005GW-MC for geh-help-gnu-emacs@m.gmane.org; Sat, 05 Oct 2013 00:00:37 +0200 Original-Received: from localhost ([::1]:49738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSDQL-0008Eg-D3 for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Oct 2013 18:00:37 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 529 Original-X-Trace: individual.net wTkNxhbB5JPtr8VOSeqHMQjgDa6tSxT7VMLG2eKti/bSsBdrXB Cancel-Lock: sha1:M2FkNmVjZjE0MGUzNWVmMjMwMmZiMmUyNmViZjRiNDg2MDRkN2U5Yg== sha1:gfc2XjY+3vY3P3hMQ2GgKPDXuj4= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:201576 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93847 Archived-At: Lele Gaifax writes: > Hi all, > > I'm looking for an easier way to edit a "template", that is a long > string representing a "prototype" text used to generate an HTML page, > contained in JavaScript source. > > As an brief example, consider the following piece of code: > > { > xtype: 'container', > itemId: 'header', > tpl: [ > '
', > '
', > '
{profession}
', > ' {fullname}', > ' {city} — {country}', > ' {state_label}', > '
', > '
' > ], > layout: { > type: 'hbox' > } > }, > > As you can see, the template is just a JS array of strings, one for each > line: before use, all the strings are "joined" (that is, concatenated) > together into a single big one. > > As you may imagine, editing the template as is is very boring! > > Today, chatting with a friend about it, I had a flashback about some > Emacs mode I used very long ago which I'm not able to find: it allowed > to edit long C comments in a recursive edit, "stripping" away the "box" > decoration (or just the start-comment and end-comment markers) as well > as the text indentation on enter, and restoring the same kind of > decoration on exit. > > Applied to my case, that would mean entering into a recursive edit > buffer with the following content: > >
>
>
{profession}
> {fullname} > {city} — {country} > {state_label} >
>
> > It does not seem so difficult to achieve (even for an elisp newbie as I > am) and I could give it a try, but I wonder if something similar already > exists. Yes, something similar already exists. It's a little more complex than what you need, but I guess it'll be a good example. In some CASE tool, there's this 'J' scripting language that let you evaluate code that's stored in strings, but that doesn't have functions and function calls. (Yeah, silly isn't it! Why couldn't they just use lisp as any sane application would do, from emacs to autocad). Anyways, imagine having to edit "subroutines" in strings like this (where ~ is the escape character): // FUNCTION: computeCxxClassName // Given the pathName of a class, computes the fully qualified C++ // name, ignoring the packages that have the C++NoNameSpace tag. // EXAMPLE: classPathName=other.OwnerClass.pathName;eval(computeCxxClassName);otherClassName=cxxClassName; String computeCxxClassName=" this{ Package currentPackage=rootPackage; string sep=~"~"; string s=classPathName; string[] items=s.segment(~":~"); int i; cxxClassName=~"~"; for(i=1; i