home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / emacs / help / 4013 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.5 KB  |  50 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!mcsun!sunic!liuida!curofix!les
  3. From: les@IDA.LiU.SE (Lennart Staflin)
  4. Subject: Re: Can I expand an abbrev without the space getting added on the end ?
  5. In-Reply-To: jbw@bigbird.bu.edu's message of 5 Sep 92 17: 47:20 GMT
  6. Message-ID: <LES.92Sep5201201@pan8.IDA.LiU.SE>
  7. Sender: news@ida.liu.se
  8. Organization: CIS Dept, University of Linkoping, Sweden
  9. References: <1723@prlhp1.prl.philips.co.uk>
  10.     <WMESARD.92Sep4121833@tofu.oracle.com>
  11.     <JBW.92Sep5124720@bigbird.bu.edu>
  12. Date: Sat, 5 Sep 1992 18:12:05 GMT
  13. Lines: 35
  14.  
  15. You can also bind the space-key to something that expands an eventual
  16. abbreviation but doesn't insert a space.
  17.  
  18. In tex-mode i use the following function:
  19.  
  20. (defun TeX-insert-space (arg)
  21.   (interactive "p")
  22.   (expand-abbrev)
  23.   (if (and (= arg 1)
  24.        skip-space)
  25.       nil
  26.     (if (and last-abbrev last-abbrev-location
  27.          (< last-abbrev-location (point))
  28.          (< (- (point) last-abbrev-location) 200))
  29.     (let ((here (point)))
  30.       (goto-char last-abbrev-location)
  31.       (if (search-forward "\C-b" here 'noerr)
  32.           (delete-char -1)
  33.         (self-insert-command arg)))
  34.       (self-insert-command arg)))
  35.   (setq skip-space nil))
  36.  
  37. [Ignore the skip-space variable, its an old left-over.]
  38.  
  39. With this function bound to space, the abbreviations expansion can
  40. contain a C-b, if it does the point will be moved to the C-b and no
  41. space will be inserted.  If the expansion does not contain a C-b a
  42. normal space will be inserted.
  43.  
  44. Some typical abbreviations:
  45.  
  46. "csref"           14   "\\ref{}"
  47. "setof"           3    "\\setof{}{}"
  48.  
  49. -- Lennart Staflin
  50.