From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Harry Putnam Newsgroups: gmane.emacs.help Subject: Re: multiple inserts within skeletons Date: Tue, 29 Apr 2003 23:13:26 GMT Organization: Still searching... 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=us-ascii Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1051658416 11415 80.91.224.249 (29 Apr 2003 23:20:16 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 29 Apr 2003 23:20:16 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 30 01:20:06 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 19AeOM-0002xZ-00 for ; Wed, 30 Apr 2003 01:20:06 +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 19AeKF-0004vb-03 for gnu-help-gnu-emacs@m.gmane.org; Tue, 29 Apr 2003 19:15:51 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!diablo.voicenet.com!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr19.news.prodigy.com.POSTED!cbca52ab!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:yXo/MfRl2tP1Gf4HrQJ39de0nis= Original-Lines: 126 Original-NNTP-Posting-Host: 63.202.233.138 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: newssvr19.news.prodigy.com 1051658005 ST000 63.202.233.138 (Tue, 29 Apr 2003 19:13:25 EDT) Original-NNTP-Posting-Date: Tue, 29 Apr 2003 19:13:25 EDT X-UserInfo1: FKPO@MC@@S@CRUH[N[O@_WH@YR_B@EXLLBWLOOAFWIWTEPIB_NVUAH_[BL[\IRKIANGGJBFNJF_DOLSCENSY^U@FRFUEXR@KFXYDBPWBCDQJA@X_DCBHXR[C@\EOKCJLED_SZ@RMWYXYWE_P@\\GOIW^@SYFFSWHFIXMADO@^[ADPRPETLBJ]RDGENSKQQZN Original-Xref: shelby.stanford.edu gnu.emacs.help:112543 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:9039 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9039 Oliver Scholz writes: Oliver... I must have some language setting that will help me read your response. I see quite a lot of unusual chars, back slashes and three diget number in your text.I'm running a fairly recent cvs emacs: GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) I've set no language var away from what ever is default. I've included quite a lot of your answer hoping to show what I see on this end, but not sure it will come to you as I see it. Can you suggest a setting that will allow me to see in english what you've said? Afterwards please ignore the hefty inclusion and have a look at my clumsy attempt at the end I think I'm getting the gist of what you intend... thanks. > 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: I meant actual current time when skeleton is fired. > (define-skeleton my-test-skel > "Insert the current time and date." > nil > "Date: " (current-time-string) ".") Yeah, like that.. > 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 “#”? Commonly called a pound sign (#). > If so, I believe, you want something like this: > > (define-skeleton my-comment > "Insert keywords formatted input." > "Keywords: " > "# Keywords: " str \n > ("Comment: " "# " str "\n")) > Yup, again... Thanks > 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. :-) Thank you. Yes this is what I was after. Putting all you told me together I come up with an almost working skeleton. It fails to handle the style of closure unlike your example. My code produces a double ending if I choose to close with but works if I close with C-g. I'm pretty sure its got some parens arranged wrong or not enough `lists withing lists', but since my lisp skills are non-existent I've resorted to dozens of trials... so far none have worked like your example. Maybe you can spot the short comming? (define-skeleton hp-com_keywords "Insert commented keywords formatted input." "Keywords: " "# Keywords: " str \n ("Comment: " "# " str "\n") & "# "(format-time-string "%b %d %Y %w %T\n") & "# && CLOSED WITH " | resume: & "# "(format-time-string "%b %d %Y %w %T\n")"# && CLOSED WITH C-g") Using style closure produces: # Keywords: SOME KEY WORDS # Commentary -> # More commentary -> # Apr 29 2003 2 16:08:22 # && CLOSED WITH Apr 29 2003 2 16:08:22 # && CLOSED WITH C-g Using C-g produces: # Keywords: SOME KEY WORDS # Commentary -> # More commentary -> # Apr 29 2003 2 16:09:02 # && CLOSED WITH C-g I'm missing how to setup the body of the skeleton so it works like your example.