[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: abbrevs, skeletons, and comments
From: |
nobrowser |
Subject: |
Re: abbrevs, skeletons, and comments |
Date: |
Sat, 02 Jun 2007 21:44:09 -0700 |
User-agent: |
G2/1.0 |
Tim X wrote:
> nobrowser@gmail.com writes:
>
> > In a module I'm writing, I'd like to bind abbrevs to code skeletons,
> > similar to what is done e.g. by sml-mode. But expanding the abbrevs
> > makes no sense when the point is inside a comment (or a string
> > literal). So I'd like to conditionally stop expansion. The main
> > opportunity for that seems to be pre-abbrev-expand-hook, but there are
> > only two ways it can stop an expansion: 1, throw an error, 2, change
> > the abbrev bindings (either by making changes in the current table or
> > by swapping in a whole new table). 1 is unacceptable - how many errors
> > before user gets mad and disables abbrevs altogether? 2, how to undo
> > the changes when the point leaves the comment or string?
> >
>
> maybe use an error handler that catches that specific error and ignores it?
>
Well, there's no point where I get control, that's the problem.
Abbrev expansion can be triggered just by the user typing a space or
period, if they have Abbrev minor mode on.
I see a way to do what I want. It involves hooking both pre-abbrev-
expand-hook and post-command-hook. I can restore the abbrev bindings
in the latter. But I am afraid what this could do to Emacs speed or
even stability.
What I've decided on so far is I won't do anything by default (so
users who avoid Abbrev minor mode are not penalized) and have a
customize flag that turns on the above solution.
Other suggestions still welcome.
- abbrevs, skeletons, and comments, nobrowser, 2007/06/02
- Re: abbrevs, skeletons, and comments, Johan Bockgård, 2007/06/11
- Re: abbrevs, skeletons, and comments, Stefan Monnier, 2007/06/12