home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / emacs / help / 3988 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.2 KB  |  49 lines

  1. Path: sparky!uunet!pipex!warwick!str-ccsun!strath-cs!prlhp1!glenn
  2. From: glenn@prl.philips.co.uk (Glenn Coombs)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Can I expand an abbrev without the space getting added on the end ?
  5. Message-ID: <1723@prlhp1.prl.philips.co.uk>
  6. Date: 3 Sep 92 11:45:31 GMT
  7. Sender: nntp@prlhp1.prl.philips.co.uk
  8. Organization: Philips Research Labs, Redhill, England
  9. Lines: 37
  10. Nntp-Posting-Host: prsun10q
  11.  
  12.  
  13. I have just written the following bit of code:
  14.  
  15. (defun magic-main ()
  16.   "insert a main () construct automatically"
  17.   (beginning-of-line)        ; put main at margin
  18.   (delete-horizontal-space)
  19.   (end-of-line)
  20.   (insert-string "\n{\n\t\n}")
  21.   (search-backward ")"))
  22.  
  23. (define-abbrev c-mode-abbrev-table "main" "main ()" 'magic-main)
  24.  
  25. which should expand a main to:
  26.  
  27. main ()
  28. {
  29.  
  30. }
  31.  
  32. and leave the cursor just before the close bracket.  However, the
  33. space that I type after main in order to get it expanded gets added
  34. in after the expansion call has been executed.  This means that I end
  35. up with:
  36.  
  37. main ( )
  38. {
  39.  
  40. }
  41.  
  42. and I have to manually delete a space.  Does anyone know of a way to
  43. stop this space from appearing or a way to work round it ?
  44.  
  45. -- 
  46.  
  47. -
  48. Glenn   ...   glenn@prl.philips.co.uk
  49.