* Don't you think this would be a nice feature? (Place holder) @ 2008-09-27 15:28 Weiwei 2008-09-27 15:49 ` Lennart Borgman (gmail) ` (3 more replies) 0 siblings, 4 replies; 11+ messages in thread From: Weiwei @ 2008-09-27 15:28 UTC (permalink / raw) To: help-gnu-emacs 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! Weiwei ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-27 15:28 Don't you think this would be a nice feature? (Place holder) Weiwei @ 2008-09-27 15:49 ` Lennart Borgman (gmail) 2008-09-27 16:01 ` harven ` (2 subsequent siblings) 3 siblings, 0 replies; 11+ messages in thread From: Lennart Borgman (gmail) @ 2008-09-27 15:49 UTC (permalink / raw) To: Weiwei; +Cc: help-gnu-emacs Weiwei wrote: > 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! Hi Weiwei Maybe this page is will help http://www.emacswiki.org/cgi-bin/wiki/CategoryTemplates ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-27 15:28 Don't you think this would be a nice feature? (Place holder) Weiwei 2008-09-27 15:49 ` Lennart Borgman (gmail) @ 2008-09-27 16:01 ` harven 2008-09-27 16:12 ` Weiwei 2008-09-27 22:58 ` Andreas Politz 2008-09-27 23:52 ` Tim X 3 siblings, 1 reply; 11+ messages in thread From: harven @ 2008-09-27 16:01 UTC (permalink / raw) To: help-gnu-emacs Weiwei <shuww1980@gmail.com> writes: > 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: My first guess was doing a macro. F3 C-M-s \[\]\|{} RET C-b F4 Unfortunatly it fails on your first example at some point for some strange reason. So here is the lisp code to put in your .emacs: (defun jump-next-bracket-pair () "jump inside the next [] or {}" (interactive) (when (re-search-forward "\\[\\]\\|{}" nil t) (backward-char))) (add-hook 'TeX-mode-hook (lambda () (define-key TeX-mode-map (kbd "<f4>") 'jump-next-bracket-pair)) This binds the command to the F4 key in tex editing modes only. Cheers. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-27 16:01 ` harven @ 2008-09-27 16:12 ` Weiwei 0 siblings, 0 replies; 11+ messages in thread From: Weiwei @ 2008-09-27 16:12 UTC (permalink / raw) To: help-gnu-emacs This small code does exactly what I wanted. Thanks Harven!!! On Sep 27, 11:01 am, harven <har...@free.fr> wrote: > Weiwei <shuww1...@gmail.com> writes: > > 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: > > My first guess was doing a macro. > F3 C-M-s \[\]\|{} RET C-b F4 > Unfortunatly it fails on your first example at some point > for some strange reason. So here is the lisp code to put in your .emacs: > > (defun jump-next-bracket-pair () > "jump inside the next [] or {}" > (interactive) > (when (re-search-forward "\\[\\]\\|{}" nil t) > (backward-char))) > > (add-hook 'TeX-mode-hook (lambda () > (define-key TeX-mode-map (kbd "<f4>") 'jump-next-bracket-pair)) > > This binds the command to the F4 key in tex editing modes only. > Cheers. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-27 15:28 Don't you think this would be a nice feature? (Place holder) Weiwei 2008-09-27 15:49 ` Lennart Borgman (gmail) 2008-09-27 16:01 ` harven @ 2008-09-27 22:58 ` Andreas Politz 2008-09-27 23:52 ` Tim X 3 siblings, 0 replies; 11+ messages in thread From: Andreas Politz @ 2008-09-27 22:58 UTC (permalink / raw) To: help-gnu-emacs Weiwei wrote: > 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! > > > Weiwei > > > There are better ways in emacs to do this, instead of inserting literal text. For example using text properties to mark regions of interest (`jumpspots'). I am not familiar with the various abbrev/template packages, but I could imagine that at least some of them are taking advantage of this. -ap ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-27 15:28 Don't you think this would be a nice feature? (Place holder) Weiwei ` (2 preceding siblings ...) 2008-09-27 22:58 ` Andreas Politz @ 2008-09-27 23:52 ` Tim X 2008-09-28 2:31 ` Weiwei 3 siblings, 1 reply; 11+ messages in thread From: Tim X @ 2008-09-27 23:52 UTC (permalink / raw) To: help-gnu-emacs 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-27 23:52 ` Tim X @ 2008-09-28 2:31 ` Weiwei 2008-09-28 6:37 ` Tim X ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Weiwei @ 2008-09-28 2:31 UTC (permalink / raw) To: help-gnu-emacs Thanks Tim. The problem I try to state is how to quickly jump to places which is already there. I never used tempo, but have a little bit of experience with skeleton. I defined a skeleton which helps me to insert the following environment by typing "isub" followed by space: \begin{figure}[H] \centering \subfigure[]{\includegraphics[width=3.1in]{}} \subfigure[]{\includegraphics[width=3.1in]{}} \caption{} \label{fig:} \end{figure} Now the cursor is in between the first "[]". After I type something, I want to jump to "{}" in the same line to fill the eps filename. Can skeleton or tempo do this job? I have used a third-party template mode before (not tempo though), and it let me fill staff such as date, author, etc. in the minibuffer, which I feel not that convenient. Correct me if skeleton or tempo is able to do the job and I will give them a try. Thanks! Weiwei On Sep 27, 6:52 pm, Tim X <t...@nospam.dev.null> wrote: > Weiwei <shuww1...@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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-28 2:31 ` Weiwei @ 2008-09-28 6:37 ` Tim X 2008-09-28 7:58 ` Nicolas Goaziou 2008-09-28 11:41 ` Martin Dahl [not found] ` <mailman.20110.1222608284.18990.help-gnu-emacs@gnu.org> 2 siblings, 1 reply; 11+ messages in thread From: Tim X @ 2008-09-28 6:37 UTC (permalink / raw) To: help-gnu-emacs Weiwei <shuww1980@gmail.com> writes: > Thanks Tim. The problem I try to state is how to quickly jump to > places which is already there. I never used tempo, but have a little > bit of experience with skeleton. I defined a skeleton which helps me > to insert the following environment by typing "isub" followed by > space: > > \begin{figure}[H] > \centering > \subfigure[]{\includegraphics[width=3.1in]{}} > \subfigure[]{\includegraphics[width=3.1in]{}} > \caption{} > \label{fig:} > \end{figure} > > Now the cursor is in between the first "[]". After I type something, I > want to jump to "{}" in the same line to fill the eps filename. Can > skeleton or tempo do this job? I have used a third-party template mode > before (not tempo though), and it let me fill staff such as date, > author, etc. in the minibuffer, which I feel not that convenient. > Correct me if skeleton or tempo is able to do the job and I will give > them a try. Thanks! > > Weiwei > OK, now I understand what your after a bit better. The standard way to do this would be to have the template prompt you for the values in the mini-buffer and then it would insert them in the appropriate place. This is also how many of the pre-defined environment insertion facilities of auctex work. However, from what you say, you don't like this approach. Off the top of my head, I can't see how this could be done easily using existing template facilities. However, both tempo and skeleton do provide ways of incorporating elisp into the definition, so it should be possible, but perhaps not trivial, especially if you wanted something fairly generic rather than coded for specific examples. For example, how can emacs know when you have filled in the first value and then automatically move you to the next value. This is why using the mini-buffer to get the values is so convenient. All the template needs to know is where to insert the values. There is no need to try and find a mechanism to tell emacs when you have finished putting in the first value and then to jump to the next spot to let you fill in the next value and so on. I personally don't have a problem with being prompted for values in the mini-buffer. I find that as long as you have the template bound to a convenient key or triggered by an abbrev, the use of the mini-buffer doesn't interrupt my workflow or thoughts at all. In fact, as you can also take advantage of completion and default values, it can be very convenient and it certainly simplifies matters. Sorry I couldn't provide more substantial help. Tim > -- tcross (at) rapttech dot com dot au ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-28 6:37 ` Tim X @ 2008-09-28 7:58 ` Nicolas Goaziou 0 siblings, 0 replies; 11+ messages in thread From: Nicolas Goaziou @ 2008-09-28 7:58 UTC (permalink / raw) To: help-gnu-emacs Hello, Tempo has 2 functions : tempo-forward-mark and tempo-backward-mark. I think it's what the original poster is looking for. Hope this helps. -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Don't you think this would be a nice feature? (Place holder) 2008-09-28 2:31 ` Weiwei 2008-09-28 6:37 ` Tim X @ 2008-09-28 11:41 ` Martin Dahl [not found] ` <mailman.20110.1222608284.18990.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 11+ messages in thread From: Martin Dahl @ 2008-09-28 11:41 UTC (permalink / raw) To: Weiwei; +Cc: help-gnu-emacs Weiwei <shuww1980@gmail.com> writes: > Thanks Tim. The problem I try to state is how to quickly jump to > places which is already there. I never used tempo, but have a little > bit of experience with skeleton. I defined a skeleton which helps me > to insert the following environment by typing "isub" followed by > space: > > \begin{figure}[H] > \centering > \subfigure[]{\includegraphics[width=3.1in]{}} > \subfigure[]{\includegraphics[width=3.1in]{}} > \caption{} > \label{fig:} > \end{figure} > > Now the cursor is in between the first "[]". After I type something, I > want to jump to "{}" in the same line to fill the eps filename. Can > skeleton or tempo do this job? I have used a third-party template mode > before (not tempo though), and it let me fill staff such as date, > author, etc. in the minibuffer, which I feel not that convenient. > Correct me if skeleton or tempo is able to do the job and I will give > them a try. Thanks! > > Weiwei > I think yasnippet might be what you are looking for. It allows you to jump beetween predefined points in inserted text with the tab key. http://code.google.com/p/yasnippet/ -- Martin Dahl ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.20110.1222608284.18990.help-gnu-emacs@gnu.org>]
* Re: Don't you think this would be a nice feature? (Place holder) [not found] ` <mailman.20110.1222608284.18990.help-gnu-emacs@gnu.org> @ 2008-09-28 16:48 ` Weiwei 0 siblings, 0 replies; 11+ messages in thread From: Weiwei @ 2008-09-28 16:48 UTC (permalink / raw) To: help-gnu-emacs Thank you all guys!! Feel very good seeing so many replies and useful information. You guys are really helpful!! On Sep 28, 6:41 am, Martin Dahl <martin.d...@gmail.com> wrote: > Weiwei <shuww1...@gmail.com> writes: > > Thanks Tim. The problem I try to state is how to quickly jump to > > places which is already there. I never used tempo, but have a little > > bit of experience with skeleton. I defined a skeleton which helps me > > to insert the following environment by typing "isub" followed by > > space: > > > \begin{figure}[H] > > \centering > > \subfigure[]{\includegraphics[width=3.1in]{}} > > \subfigure[]{\includegraphics[width=3.1in]{}} > > \caption{} > > \label{fig:} > > \end{figure} > > > Now the cursor is in between the first "[]". After I type something, I > > want to jump to "{}" in the same line to fill the eps filename. Can > > skeleton or tempo do this job? I have used a third-party template mode > > before (not tempo though), and it let me fill staff such as date, > > author, etc. in the minibuffer, which I feel not that convenient. > > Correct me if skeleton or tempo is able to do the job and I will give > > them a try. Thanks! > > > Weiwei > > I think yasnippet might be what you are looking for. It allows you to > jump beetween predefined points in inserted text with the tab key. > > http://code.google.com/p/yasnippet/ > > -- > Martin Dahl ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-09-28 16:48 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-09-27 15:28 Don't you think this would be a nice feature? (Place holder) Weiwei 2008-09-27 15:49 ` Lennart Borgman (gmail) 2008-09-27 16:01 ` harven 2008-09-27 16:12 ` Weiwei 2008-09-27 22:58 ` Andreas Politz 2008-09-27 23:52 ` Tim X 2008-09-28 2:31 ` Weiwei 2008-09-28 6:37 ` Tim X 2008-09-28 7:58 ` Nicolas Goaziou 2008-09-28 11:41 ` Martin Dahl [not found] ` <mailman.20110.1222608284.18990.help-gnu-emacs@gnu.org> 2008-09-28 16:48 ` Weiwei
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).