[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#10772: 24.0.93; [patch] Convert tcl-auto-fill-mode to use define-min
From: |
Stefan Monnier |
Subject: |
bug#10772: 24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode |
Date: |
Thu, 09 Feb 2012 17:09:36 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
> -(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))))
The problem with this approach is that it creates new possible states,
e.g. if the user enables tcl-auto-fill-mode and then disables
auto-fill-mode.
Maybe we could use an approach like the one I used for
(binary-)overwrite-mode.
Stefan