Re: Please help with abbrev - problem

"David A. Panariti" <[email protected]> Wed, 09 Feb 2005 09:25:14 -0500 (EST)
Newsgroups gmane.emacs.xemacs.general
Message-ID <[email protected]>
>>>>> "Markus" == Markus Grunwald <[email protected]> writes:
What does (skeleton-insert) look like?

You could add a (backward-char) after the (skeleton-insert) in
(mg-skel-c-bool), but it would probably be best to fix (skeleton-insert) if
it is *mistakenly* adding the trailing space.  But from the looks of the
other abbrevs, you probably want the trailing space in the other cases, so
the bw-char may be right... or you could specify trailing spaces in the
string passed to (skeleton-insert).

davep

   Markus> Hello,

   Markus> Since I am an ugly lazy typer, I have several abbrevs for c
   Markus> keywords. They are all working fine. Now I wanted to become a bit
   Markus> more lazy and create an abbrev for the following:

   Markus> When I type

   Markus> bool

   Markus> this should bee expanded to:

   Markus> bool m_b

   Markus> With the cursor directly after the trailing 'b', so that I can
   Markus> type the name. I got quite close:

   Markus> (defun load-c++-mode-abbrev-table ()
   Markus>   (clear-abbrev-table c++-mode-abbrev-table) (define-abbrev-table
   Markus>   'c++-mode-abbrev-table
   Markus>     '(
   Markus>       ( "for" "" mg-skel-c-for 0 ) ( "if" "" mg-skel-c-if 0 ) (
   Markus>       "else" "" mg-skel-c-else 0 ) ( "while" "" mg-skel-c-while 0
   Markus>       ) ( "do" "" mg-skel-c-do 0 ) ( "switch" "" mg-skel-c-switch
   Markus>       0 ) ( "case" "" mg-skel-c-case 0 ) ( "bool" ""
   Markus>       mg-skel-c-bool 0 ) )
   Markus>     )
   Markus>   (put 'c++-mode-abbrev-table 'no-self-insert t) )

   Markus> (defun mg-skel-c-bool()
   Markus>   "Inserts a boolean according to coding conventions.\n This sould
   Markus>   be
   Markus> called from an abbrev."
   Markus>   ( skeleton-insert
   Markus>     '( nil "bool m_b" _ ))
   Markus>   )

   Markus> What I get when I type 'bool ' is ( '_' marks the cursor)

   Markus> bool m_b _

   Markus> So there is a space between the trailing 'b' and the cursor. I did
   Markus> not manage to get rid of this &*%$£ space ...  Can you help me,
   Markus> please ?

   Markus> Mit freundlichen Grüßen

   Markus> Markus Grunwald Softwareentwicklung

   Markus> PRÜFTECHNIK Condition Monitoring GmbH Oskar-Messter-Straße 19-21
   Markus> 85737 Ismaning www.pruftechnik.com
   Tel> +49 (0)89 99616177
   Fax> +49 (0)89 99616200

--
       /  I hate quotations.
davep (|)                 -- Ralph Waldo Emerson
       /  
$$