5

Let's say I use abbrev to expand eq into equation.

Now I want eq to always expand, except when followed by a colon (:).

The logic is that in LaTeX I do not want equation identifiers (e.g., eq:xyz) to be expanded.

Any ideas about how to selectively disable abbrev expansion?

Dan
  • 32,584
  • 6
  • 98
  • 168
scaramouche
  • 1,772
  • 10
  • 24

1 Answers1

5

You could either hack the syntax table so as not to treat the : as a non-word constituent, or you could write an :enable-function that will prevent expansion on the basis of :. This one works:

(define-abbrev-table 'text-mode-abbrev-table
  '(("eq" "equation"))
  "My table."
  :enable-function (lambda ()
                     (let* ((vec  (this-command-keys-vector))
                            (char (aref vec (1- (length vec)))))
                       (not (eq ?: char)))))
Dan
  • 32,584
  • 6
  • 98
  • 168