Re: Auto-inserting <![CDATA[ ... ]]>
Peter Flynn <[email protected]> Mon, 23 Feb 2004 22:09:57 +0000
| Newsgroups | gmane.emacs.psgml.user |
|---|---|
| Organization | Silmaril Consultants |
| Message-ID | <[email protected]> |
On Mon, 2004-02-23 at 10:46, D. D. Brierton wrote:
> /*<![CDATA[*/
> if (i < foo && j < bar) {
Ah. Can't you just say if (i < foo && j < bar) {
Or do browsers screw it up even in XHTML?
> > I've never investigated Custom Markup. Why not just record the
> > relevant keystrokes and save them in your .emacs bound to an
> > unused key (eg F12)?
>
> Because I don't now how to do that! Also, I'd really like something I
> didn't have to memorise, but instead was available from a menu.
I don't know how to poke recorded keystroke macros into the menus,
maybe one of the mode authors can reply.
To DIY:
C-x ( <![CDATA[]]> C-b C-b C-b C-x )
that records the insert sequence and leaves the cursor in the
marked section. To replay this to test it, use C-x e
Now give it a name:
M-x name-last-kbd-macro RET sgml-insert-CDATA RET
Then bind it to a key, eg F12
M-x local-set RET F12 sgml-insert-CDATA RET
(that's the F12 key there, not the separate keystrokes).
Now you can press F12 to insert a CDATA marked section.
Finally open your .emacs and go to the bottom and type
M-x insert-kbd-macro RET sgml-insert-CDATA RET
and then
(global-set-key [f12] 'sgml-insert-CDATA)
Unfortunately I don't know how to do this and make it active
ONLY in sgml-mode or xml-mode. The above makes it globally
active in all modes. I think it's something to do with one
of the -hook variables: doubtless someone else can explain.
Save .emacs and type M-x eval-buffer to make it work now
(it will auto-load in future sessions).
///Peter
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click