How to instruct Emacs auto-capitalize-mode to automatically lowercase any word that follows e.g. or i.e.?

StackOverflow https://stackoverflow.com/questions/22430229

Question

Emacs auto-capitalize-mode misinterprets the words i.e. and e.g. to signify the end of a sentence, and, accordingly, erroneously capitalizes any word that follows them.

Does anyone have a function that can be called by entering, say, eg or ie, that will insert the characters e.g. and i.e. and then automatically lowercase whatever word gets typed next?

Bonus: Do the same thing... for ellipses.

Was it helpful?

Solution

Add this to your .emacs:

(setq auto-capitalize-predicate
      (lambda () (not (looking-back
           "\\([Ee]\\.g\\|[Ii]\\.e\\)\\.[^.]*" (- (point) 20)))))

Remember that the I in i.e. will be capitalized to I.e if your auto-capitalize-words variable is set to contain “I”.

(setq auto-capitalize-words '()) This sets it to nothing.

Here’s a version that also deals with ellipses:

(setq auto-capitalize-predicate
      (lambda () (not (looking-back
           "\\([Ee]\\.g\\|[Ii]\\.e\\|\\.\\.\\)\\.[^.]*" (- (point) 20)))))

But you might want to look into some abbrev magic that turns three periods into a unicode ellipsis instead. It's up to you.

OTHER TIPS

From auto-capitalize.el:

;; To prevent a word in the `auto-capitalize-words' list from being
;; capitalized or upcased in a particular context (e.g.
;; "GNU.emacs.sources"), insert the following whitespace or
;; punctuation character with `M-x quoted-insert' (e.g. `gnu C-q .').

I use it and it is a comfortable approach.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top