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

From: Xue Fuqiao <[email-masked]>
Date: Tue, 25 Feb 2014 21:30:05 +0800

What about the following patch:

=== modified file 'lisp/progmodes/tcl.el'
--- lisp/progmodes/tcl.el	2014-02-10 01:34:22 +0000
+++ lisp/progmodes/tcl.el	2014-02-25 13:22:36 +0000
@@ -1410,13 +1410,8 @@
 		     tcl-application file tcl-command-switches)
 	(if and-go (switch-to-tcl t)))))))
 
-(defun tcl-auto-fill-mode (&optional arg)
-  "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
-  (interactive "P")
-  (auto-fill-mode arg)
-  (if auto-fill-function
-      (set (make-local-variable 'comment-auto-fill-only-comments) t)
-    (kill-local-variable 'comment-auto-fill-only-comments)))
+(define-obsolete-function-alias tcl-auto-fill-mode
+  auto-fill-noncode-mode "24.4")
 
 (defun tcl-electric-hash (&optional count)
   "Insert a `#' and quote if it does not start a real comment.

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2014-02-21 13:22:14 +0000
+++ lisp/simple.el	2014-02-25 13:26:54 +0000
@@ -6146,6 +6146,16 @@
              . (lambda (v) (setq auto-fill-function
                             (if v normal-auto-fill-function)))))
 
+(define-minor-mode auto-fill-noncode-mode
+  "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
+  :variable
+  ((and auto-fill-function comment-auto-fill-only-comments)
+   . (lambda (x)
+       (auto-fill-mode (if x 1 -1))
+       (if auto-fill-function
+	   (setq-local comment-auto-fill-only-comments t)
+	 (kill-local-variable 'comment-auto-fill-only-comments)))))
+
 ;; This holds a document string used to document auto-fill-mode.
 (defun auto-fill-function ()
   "Automatically break line at a previous space, in insertion of text."