home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help
- Path: sparky!uunet!mcsun!sunic!liuida!curofix!les
- From: les@IDA.LiU.SE (Lennart Staflin)
- Subject: Re: Can I expand an abbrev without the space getting added on the end ?
- In-Reply-To: jbw@bigbird.bu.edu's message of 5 Sep 92 17: 47:20 GMT
- Message-ID: <LES.92Sep5201201@pan8.IDA.LiU.SE>
- Sender: news@ida.liu.se
- Organization: CIS Dept, University of Linkoping, Sweden
- References: <1723@prlhp1.prl.philips.co.uk>
- <WMESARD.92Sep4121833@tofu.oracle.com>
- <JBW.92Sep5124720@bigbird.bu.edu>
- Date: Sat, 5 Sep 1992 18:12:05 GMT
- Lines: 35
-
- You can also bind the space-key to something that expands an eventual
- abbreviation but doesn't insert a space.
-
- In tex-mode i use the following function:
-
- (defun TeX-insert-space (arg)
- (interactive "p")
- (expand-abbrev)
- (if (and (= arg 1)
- skip-space)
- nil
- (if (and last-abbrev last-abbrev-location
- (< last-abbrev-location (point))
- (< (- (point) last-abbrev-location) 200))
- (let ((here (point)))
- (goto-char last-abbrev-location)
- (if (search-forward "\C-b" here 'noerr)
- (delete-char -1)
- (self-insert-command arg)))
- (self-insert-command arg)))
- (setq skip-space nil))
-
- [Ignore the skip-space variable, its an old left-over.]
-
- With this function bound to space, the abbreviations expansion can
- contain a C-b, if it does the point will be moved to the C-b and no
- space will be inserted. If the expansion does not contain a C-b a
- normal space will be inserted.
-
- Some typical abbreviations:
-
- "csref" 14 "\\ref{}"
- "setof" 3 "\\setof{}{}"
-
- -- Lennart Staflin
-