I use Emacs auto-capitalize-mode, which works perfectly most of the time except for ... (ellipsis), and words like e.g. and i.e..

If I write a sentence... and then another part... and then another part... auto-capitalize-mode mistakenly capitalizes it like so:

"If I write a sentence... And then another part... And then another part..."

How do I tell auto-capitalize-mode not to capitalize after ellipsis?

Same question for e.g. and i.e.

  • 3
    auto-capitalize-mode uses the Emacs default mechanism for determining the end of a sentence, which in turn relies on some regexps customizable in the paragraphs group; try M-x customize-group RET paragraphs RET and examine the values of the 'Sentence End.*' variables, in particular 'Sentence End Base'. I can't suggest a possible change to the value, but that'd be a likely place to start; if you need to change just the behavior of auto-capitalize-mode, rather than that of Emacs as a whole, you'd want to look at advising the function auto-capitalize-sentence-end. – Aaron Miller Jun 10 '13 at 19:16
  • Is there a way to make typing e.g. or i.e. automatically call a function? A function which would insert those characters and then automatically lowercase the following word? – incandescentman Mar 15 '14 at 21:48
  • Yup! Emacs abbrevs support hooks. The best way I know to define one is to M-x edit-abbrevs, which visits the abbrevs table list. Each abbrev is defined as NAME USECOUNT EXPANSION HOOK, where HOOK is empty by default; you'd define "i.e." as an abbrev which expands to itself, and whose hook finds the word following the abbrev and downcases it. Once you're done editing the abbrev table entry, C-c C-c will apply the change in your current session, and C-x C-s saves the file. – Aaron Miller Mar 27 '14 at 4:20
  • 1
    In any case, so that my effort doesn't go entirely to waste, here's what I came up with for a hook function which downcases the word following the expansion: (lambda nil (save-excursion (forward-word) (push-mark) (backward-word) (downcase-region (point) (mark)))) Of course this only works on things Emacs recognizes as a "word", so a hyphenated compound, for example, would only have its first part downcased; if that's a concern, you probably want to replace this simple-minded effort with something that looks at whitespace and non-infix punctuation instead. – Aaron Miller Mar 27 '14 at 4:35
  • 1
    Sure! What I added to the abbrev table was basically this: "e.g." 0 "e.g." (lambda nil (...)), with the placeholder filled by the lambda given in my previous comment. FYI, entering e.g. into a buffer, followed by C-x a i g (INVERSE-ADD-GLOBAL-ABBREV), tries to add an abbrev on g.; C-u 2 C-x a i g, which should add an abbrev on the two "words" preceding point, instead tries to add an abbrev on e.. I'm not sure why that doesn't work the way it seems like it should, but the misbehavior might offer some insight, which is why I mention it here. Hope this helps! – Aaron Miller Mar 31 '14 at 2:20
(setq auto-capitalize-predicate
  (lambda () (not (looking-back
       "\\([Ee]\\.g\\|[Ii]\\.e\\|\\.\\.\\)\\.[^.]*" (- (point) 20)))))

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.