Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a Follow-Up question to auctex does not parse own sty file

I can use C-c C-m to use mytext from this MWE

\documentclass{article}
\newcommand{\mytext}{This is a simple text.}
\begin{document}
\mytext{}
\end{document}

However, I'm looking for a possibility to include the entire command on the current position, for instance to change something.

Is it possible, without copy and paste from the command definition, but with a hotkey (I'm looking for such a solution for commands from style files)?

share|improve this question
    
Do you mean that C-c C-m, when fed \myimage should insert in the text not something like \myimage[]{}{} but what that command literally stands for? Does it need to jump cleverly from #1 to #2, etc. as well? I can't help with that, but you could use emacs' registers: highlight the region, M-x copy-to-register <RET> <reg.> <RET> (or: C-x r s <reg.>; e.g.: C-x r s i = 'copy to register "i"' [for image]); then to insert the "i register" use M-x insert-register or C-x r i i. If you are going to be inserting the same basic thing repeatedly, registers are very convenient. –  jon Mar 19 '13 at 19:07
    
Looking at your other question: You want to define arbitrary commands and then have AUCTeX parse and expand them? Normally that is a job we leave to TeX. It also would decrease the maintainability of your code/documents: changing one instance of how graphics are inserted via the command \myimage is much easier than changing many instances of its 'expanded' form scattered throughout your document(s). –  jon Mar 19 '13 at 19:14
    
AUCTeX should not parse and expand them, only input the command at the current position (no expand of #1 and so on). I update the MWE. –  Micha Mar 19 '13 at 23:36
    
I think we can agree that TeX 'replaces' \mytext with its definition ('This is ...') when it processes the file, but you want AUCTeX to do something similar? To me, it sounds like AUCTeX would need to 'parse' \mytext so it knows what to replace automagically. (If you think in terms of keystrokes, emacs' registers is quicker by the way.) Another possibility would be to use yasnippet, which 'allows you to type an abbreviation and automatically expand it into function templates'. –  jon Mar 20 '13 at 3:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.