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
argument in define-abbrev-table
is :enable-function
, which,
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 define-abbrev
.
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
instance of expand-abbrev
.
So: the following toy example (untested) should work:
(define-abbrev-table 'org-mode-abbrev-table
'(("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 ()
(not (org-in-src-block-p))))