help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Easier way to edit a splitted long string


From: Lele Gaifax
Subject: Easier way to edit a splitted long string
Date: Fri, 04 Oct 2013 00:55:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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: [
        '<div class="header">',
        '    <div class="top">',
        '        <div class="profession">{profession}</div>',
        '        <span class="fullname">{fullname}</span>',
        '        <span class="location">{city} &mdash; {country}</span>',
        '        <span class="state">{state_label}</span>',
        '    </div>',
        '</div>'
    ],
    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:

<div class="header">
    <div class="top">
        <div class="profession">{profession}</div>
        <span class="fullname">{fullname}</span>
        <span class="location">{city} &mdash; {country}</span>
        <span class="state">{state_label}</span>
    </div>
</div>

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.

Any hint will be very appreciated,
thanks a lot,
bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it  |                 -- Fortunato Depero, 1929.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]