Yes, you can tell the
abbrev table to use an explicit function
to test whether or not to fire in a given instance. The relevant
according to the docstring, reads:
(define-abbrev-table TABLENAME DEFINITIONS &optional DOCSTRING &rest PROPS)
Define TABLENAME (a symbol) as an abbrev table name.
Define abbrevs in it according to DEFINITIONS, which is a list of elements
of the form (ABBREVNAME EXPANSION ...) that are passed to
PROPS is a property list to apply to the table.
Properties with special meaning:
(blah blah blah)
:enable-function can be set to a function of no argument which returns
non-nil if and only if the abbrevs in this table should be used for this
So: the following toy example (untested) should work:
'(("test1" "this is a test")
("test2" "this is also a test"))
"Table of abbrevs that should NOT fire when in a source block."
:enable-function (lambda ()