From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: multiple inserts within skeletons Date: Tue, 29 Apr 2003 18:22:08 +0200 Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1051634537 10539 80.91.224.249 (29 Apr 2003 16:42:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 29 Apr 2003 16:42:17 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 29 18:42:15 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19AY9r-0002cA-00 for ; Tue, 29 Apr 2003 18:40:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19AY9U-0001dl-06 for gnu-help-gnu-emacs@m.gmane.org; Tue, 29 Apr 2003 12:40:20 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-192-018.arcor-ip.NET!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 104 Original-NNTP-Posting-Host: dialin-145-254-192-018.arcor-ip.net (145.254.192.18) Original-X-Trace: fu-berlin.de 1051634331 11815363 145.254.192.18 (16 [87814]) X-Attribution: os X-Face: "HgH2sgK|bfH$; PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6;Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:CtJMHZPGJIkIvB3MiYAjWPSwZWM= Original-Xref: shelby.stanford.edu gnu.emacs.help:112523 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9020 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9020 [Note: skeletons are not Lisp, but a special purpose language. The various parts of a skeleton program are called “elements”. Elements may be strings, sexpr (which are either sub-skeletons or Lisp expressions) or special skeleton commands like >, _, @, \n, | or &. Have a look at `C-h f skeleton-insert RET' or at the “Autotype” info manual.] Harry Putnam writes: > Oliver Scholz writes: [define-skeleton] > This is close to something I've tried to do a few times. Maybe you > can coach me a little here. > > I'd like to produce and insert that looks like: > > # Keywords: Some Key words > # More commentary > # yet more comentary > # CURRENT_DATE > # && > > Trying to rework your example like this comes sort of close.: > > (define-skeleton my-comment > "Keywords formatted input" > nil > "# Keywords: " > ("Type descriptive comments: " "# " str & \n | -15) > "END NONSENSE") > > # Keywords: # some key words > # more commentary > # yet more commentary > # CURRENT_DATE > # && > > NOTE: Current Date and closing ampersands added by hand but I'd like > the skeleton to do that for me. By “current date” do you mean the current date or the literal text “CURRENT_DATE”? If the former: skeletons may contain abitrary Lisp expressions as elements, which are then evaluated and the return value is inserted into the buffer. You could use this feature together with the function `current-time-string'. for example: (define-skeleton my-test-skel "Insert the current time and date." nil "Date: " (current-time-string) ".") If you mean just the literal “CURRENT_DATE”: just add a string to the skeleton language. > 1) How can I make the octothorpe begin to appear only after the > keywords line, so it doesn't appear after `Keywords'. I don't know what an “octothorpe” is; it's not im my Webster's. I assume that you mean the “#”? If so, I believe, you want something like this: (define-skeleton my-comment "Insert keywords formatted input." "Keywords: " "# Keywords: " str \n ("Comment: " "# " str "\n")) Basically the difference is, that this uses the combination of PROMPT + “str” two times in two different ways: "Keywords: " and the first occurence of “str” in the top-skeleton; "Comment: " and the second “str” in the sub-skeleton. [The “str & \n | -15” stuff that I recommended earlier is pointless, as I realize now: sub-skeletons are inserted *only*, if the user has entered something at the prompt.] > 2) Can I arrange the skeleton so that when I press C-g to break out, > it inserts the CURRENT_DATE followed by `# &&' on a separate line? > Or in some other way cause those last two items to be inserted > automatically Well, for one you could simply hit RET, when prompted for a “descriptive comment”. The skeleton program then leaves the sub-skeleton loop and resumes the top skeleton. But if you have (like me) the bad habit to type `C-g' all the time to get out of the minibuffer, you can use the `resume:' keyword to specify a place where the skeleton should resume execution after the user hit `C-g'. For example. (define-skeleton my-repeat-ad-nauseam "" nil ("Type something, please: " str "\n") & "Allright, we finished in a normal way." | resume: & "Aha, you lost temper and hit `C-g'.") I hope this sets you on the track. :-) Oliver -- 10 Floréal an 211 de la Révolution Liberté, Egalité, Fraternité!