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

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

Re: Don't you think this would be a nice feature? (Place holder)


From: Tim X
Subject: Re: Don't you think this would be a nice feature? (Place holder)
Date: Sun, 28 Sep 2008 09:52:31 +1000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Weiwei <shuww1980@gmail.com> writes:

> Hi guys,
>
> I'm a Emacs newbie, just jumped into it from Vim. I'm using AUCTeX to
> write LaTeX files. In Vim, it has a very nice feature -- placeholder.
> For example, you have the following skeleton in inserting figures:
>
> \begin{figure}[H]
>   \centering
>   \subfigure[]{\includegraphics[width=3.1in]{}}
>   \subfigure[]{\includegraphics[width=3.1in]{}}
>   \caption{}
>   \label{fig:}
> \end{figure}
>
> Now your cursor is in the third line between the first square brackets
> [], after you type something, you want to jump to the brackets at the
> end of the same line {}, and so forth. Vim LaTeX suite has this
> function with a single key-stroke. In AUCTeX, I didn't find such one,
> or maybe I missed it. Could anybody kindly point it to me if it
> exists?
>
> Now lets look at this feature a little bit further. Can we have (Or do
> we already have) a universal place-holder in Emacs? For example, we
> have a block of text/program as this:
>
> foofoofoo<>foofoofoofoofoofoofoofoofoofoofoofoo
> foo<>foofoofoofoofoofoofoo<>foofoofoofoofoofoo
> foofoofoofoofoo<>foofoofoofoofoofoofoofoofoofoo
>
> The <> indicates a place-holder in which you want to jump quickly. The
> function I proposed is to find next <>, and then delete the left "<"
> and right ">", and leave cursor there.
>
> I'm not sure if any similar functions are already there. I think it
> should be easy with regular expressions. Simply I'm not a regexp guy.
> What do you guys think? And anybody want to have a try? Thanks!
>
If I understand you correctly, I think everything you need is therre, it
just needs to be configured for your particular needs. Emacs has two
standard template systems, tempo and skeleton mode. There are also a
number of other template modes, varying in features and flexibility,
that you can use that are not standard parts of emacs. 

You can create very powerful 'electric' behavior by combining these
template modes with abbrevs. For example, some of the programming modes
use this technique for common constructs, such as an if statement. When
you type if and hit space, an abbrev executes that has a template
definition that fills in the rest of the construct and leave the cursor
in a 'useful' place, often wehre you need to enter the test. 

For my own work, I have various templates to setup the latex preamble
that prompt me for the document title. It then inserts or the
documentclass, title, date, author etc puts in the start/end document
pair and leaves my cursor between them. I have some other templates for
common latex constructs that I use that are not already built into
auctex. 

The other emacs feature which can be useful is macros. You can define a
macro and associate it with a key. then, hitting that binding will
execute the macro, which can in turn execute various emacs commands. 

I would suggest that making such templates part of auctex probably won't
have much value. There is too much variation in the way people like to
write their documents and as latex has a wealth of packages to do almost
everything, the combination of options is probably too great to do much
more than it already has. I find the default auctex commands for
inserting sections, various standard/common envrionments, font
attributes etc meet 99% of what I need. the templates are probably best
left for individuals to derive for themselves based on their own
requirements. 

HTH

Tim



-- 
tcross (at) rapttech dot com dot au


reply via email to

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