GNU bug report logs - #10772
24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode

Previous Next

Package: emacs;

Reported by: William Stevenson <yhvh2000 <at> gmail.com>

Date: Thu, 9 Feb 2012 06:51:01 UTC

Severity: minor

Tags: fixed, patch

Found in version 24.0.93

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: William Stevenson <yhvh2000 <at> gmail.com>
To: 10772 <at> debbugs.gnu.org
Subject: bug#10772: 24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode
Date: Thu, 09 Feb 2012 06:49:19 +0000
In the documentation of auto-fill-mode it says:
"When `auto-fill-mode' is on, the `auto-fill-function' variable is
non-`nil'."
Which makes the `if' redundant in this case, the THEN & ELSE bodies can
be placed below the call to turn auto-fill-mode on/off.

Also updated the documentation to reflect the auto generated
`tcl-auto-fill-mode-hook'.


=== modified file 'lisp/progmodes/tcl.el'
--- lisp/progmodes/tcl.el	2012-01-19 07:21:25 +0000
+++ lisp/progmodes/tcl.el	2012-02-09 06:18:32 +0000
@@ -1408,13 +1408,18 @@
 		     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-minor-mode tcl-auto-fill-mode
+  "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'.
+Turning the mode on or off runs `tcl-auto-fill-mode-hook'."
+  :init-value nil
+  (cond ((null tcl-auto-fill-mode)
+	 ;; Turn mode off
+	 (auto-fill-mode 0)
+	 (kill-local-variable 'comment-auto-fill-only-comments))
+	(t
+	 ;; Turn mode on
+	 (auto-fill-mode)
+	 (set (make-local-variable 'comment-auto-fill-only-comments) t))))
 
 (defun tcl-electric-hash (&optional count)
   "Insert a `#' and quote if it does not start a real comment.





This bug report was last modified 8 years and 46 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.