Search code examples
emacsmatchcapitalizationabbreviation

Emacs abbreviation with capitals


Normally when I use abbreviations in Emacs the abbreviations are expanded such that depending on how you capitalize your abbreviation you get a different output (see table 3.7 in http://flylib.com/books/en/2.27.1.40/1/ for example). I use a huge number of abbreviations and this is rarely useful for me. I would much prefer to have Emacs not expand the abbreviation unless it perfectly matched the case for the way I wrote the abbreviation. For example if I wrote that "lc" -> lambchop, I want Emacs to not expand "lC" or "Lc" but just "lc".

I don't have very much experience using Lisp and I've spent hours and hours trying to change this. Anyone have any ideas?


Solution

  • According to the docstring of define-abbrev:

    • `:case-fixed': non-nil means that abbreviations are looked up without case-folding, and the expansion is not capitalized/upcased.

    To disable case folding, set :case-fixed to true on the abbrev tables you use:

    (abbrev-table-put global-abbrev-table :case-fixed t)
    

    Or, to do it for all abbrev tables:

    (dolist (tbl abbrev-table-name-list)
      (abbrev-table-put tbl :case-fixed t))