Subject: bug#10772: 24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode

From: Stefan Monnier <[email-masked]>
Date: Sun, 12 Feb 2012 00:12:26 -0500

> --8<---------------cut here---------------start------------->8---
> (set (make-local-variable 'normal-auto-fill-function) 'foo-do-auto-fill)
> --8<---------------cut here---------------end--------------->8---

> These 3 modes (and some others from cursory checking) don't define
> foo-auto-fill-mode and just let the user call auto-fill-mode - which
> makes me wonder if defining tcl-auto-fill-mode is the right thing to do
> anyway.

Actually, thinking about it some more, maybe tcl-auto-fill-mode should
be renamed (it has nothing specific to Tcl) and I think it could be
implemented along the lines of (100% untested):

  (define-minor-mode auto-fill-noncode-mode
    :variable
    ((and auto-fill-function comment-auto-fill-only-comments)
     . (lambda (x)
         (auto-fill-mode (if x 1 -1))
         (if auto-fill-function
             (set (make-local-variable 'comment-auto-fill-only-comments) t)
           (kill-local-variable 'comment-auto-fill-only-comments)))))

-- Stefan