unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: William Stevenson <yhvh2000@gmail.com>
To: 10772@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	[thread overview]
Message-ID: <87fwektsb4.fsf@gmail.com> (raw)

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.






             reply	other threads:[~2012-02-09  6:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09  6:49 William Stevenson [this message]
2012-02-09 15:18 ` bug#10772: 24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode Juanma Barranquero
2012-02-09 22:09 ` Stefan Monnier
2012-02-11 15:27   ` William Stevenson
2012-02-12  5:12     ` Stefan Monnier
2014-02-25 13:30       ` Xue Fuqiao
2014-02-25 14:30         ` Stefan Monnier
2014-02-25 22:25           ` Xue Fuqiao
2014-02-26 15:40             ` Stefan Monnier
2014-02-26 22:40               ` Xue Fuqiao
2014-02-27  2:55                 ` Stefan Monnier
2014-02-27 17:00                 ` Glenn Morris
2014-02-27 22:33                   ` Xue Fuqiao
2016-02-24  6:42                     ` Lars Ingebrigtsen
2017-06-03  3:45                 ` npostavs
2017-06-28  0:38                   ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fwektsb4.fsf@gmail.com \
    --to=yhvh2000@gmail.com \
    --cc=10772@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).