help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiple inserts within skeletons


From: Oliver Scholz
Subject: Re: multiple inserts within skeletons
Date: Wed, 30 Apr 2003 11:23:16 +0200
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3.50 (windows-nt)

Harry Putnam <hgp@sbcglobal.net> writes:

> Oliver Scholz <alkibiades@gmx.de> 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.
[...]

That sounds as if the text is interpreted as unibyte text. What is the
value of `enable-multibyte-characters' in this buffer? -- But if it is
t, what does `C-u C-x =' return with point on such a character?

> 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?

You didn't loose any information. I just have used typographical
English quotations marks (from the Unicode charset) in some places
instead of the usual ASCII-ones. Perhaps I should turn this off
again, it is probably sufficient that I annoy the people in the German
Usenet with this fancy of mine. :-)

[...]
> 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 <RET> style  of closure unlike your example.  
>
> My code produces a double ending if I choose to close with <RET> 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 <RET>"
>   | resume: & "# "(format-time-string "%b %d %Y %w %T\n")"# && CLOSED WITH 
> C-g")
                   ^^^                                   ^^^

There's an `&' missing in those places. You have to "tye" elements
together that you want to insert conditionally (that is: based on the
*same* condition). An `&' means: "Insert the following element only if
point was moved due to processing of the previous element." (Which
usually means that the previous element caused some insertion.)

An IF-THEN-ELSE statement would look like this:

ELEMENT & ELEMENT [& ELEMENT] | ELEMENT [& ELEMENT]

^         ^
if        then                  ^ else

For example:

(define-skeleton hunt-the-snark 
  "Insert a silly example sentence."
  "Enter the name of a person: "
  str    & " hunts " & "the " & "snark."
  | "Nobody " & "is hunting " &  "anyone.")

Delete the `|' or any of the `&'s and you'll probably see what I mean.
(To get through to the THEN-part, hit RET immediately when you are
prompted for the name of a person.)

Of course, if you simply want "&&" at the end, you don't need all
those `&' and `|':

(define-skeleton hp-com_keywords
  "Insert commented keywords formatted input."
  "Keywords: "
  "# Keywords: " str \n
  ("Comment: " "# " str "\n")
  resume:
  "# "(format-time-string "%b %d %Y %w %T\n")
  "# &&")

    Oliver
-- 
11 Floréal an 211 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]