From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: multiple inserts within skeletons
Date: Tue, 29 Apr 2003 18:22:08 +0200 [thread overview]
Message-ID: <usms1uvdb.fsf@ID-87814.user.dfncis.de> (raw)
In-Reply-To: m2bryp1hn7.fsf@sbcglobal.net
[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 <hgp@sbcglobal.net> writes:
> Oliver Scholz <alkibiades@gmx.de> 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é!
next prev parent reply other threads:[~2003-04-29 16:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.5300.1051558114.21513.help-gnu-emacs@gnu.org>
2003-04-29 9:58 ` multiple inserts within skeletons Oliver Scholz
2003-04-29 10:52 ` Oliver Lohmann
2003-04-29 14:51 ` Harry Putnam
2003-04-29 16:22 ` Oliver Scholz [this message]
2003-04-29 23:13 ` Harry Putnam
2003-04-30 9:23 ` Oliver Scholz
2003-05-07 20:24 ` Multibyte chars [was Re: multiple inserts within skeletons] Harry Putnam
2003-05-08 7:34 ` Multibyte chars Oliver Scholz
2003-05-09 4:33 ` Harry Putnam
2003-04-28 19:29 multiple inserts within skeletons Oliver Lohmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=usms1uvdb.fsf@ID-87814.user.dfncis.de \
--to=alkibiades@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.