3

How can I tweak Emacs auto-fill to fill when a period is inserted?

For example, with a (setq fill-column 10) the following will auto-fill when I press the space after "fill".

;; good fill

;; good
;; fill on

This example doesn't fill when I press the period. I have to invoke fill-paragraph manually

;; bad fillllllllllllllllll.

;; bad
;; fillllllllllllllllll.
5

The elisp manual section about auto-filling describes the auto-fill-chars variable.

-- Variable: auto-fill-chars

 A char table of characters which invoke ‘auto-fill-function’ when
 self-inserted—space and newline in most language environments.
 They have an entry ‘t’ in the table.

About char tables it says:

A char-table is much like a vector, except that it is indexed by character codes. Any valid character code, without modifiers, can be used as an index in a char-table. You can access a char-table’s elements with ‘aref’ and ‘aset’, as with any array.

So you could simply do:

(aset auto-fill-chars ?. t)

to add the . character to the ones triggering auto filling.

  • Two times the same answer does not make much sense. So I delete mine. – Tobias Aug 23 '16 at 10:02
  • @Tobias Oh yes you were 7 minutes ahead of me... it would be nice that SX shows information such as "someone is currently writing an answer" to avoid such "clashes". – JeanPierre Aug 23 '16 at 11:37

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.