4

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?

4

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)))))
  • Very nice solution. – scaramouche May 6 '15 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.