[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: |
William Stevenson |
Subject: |
bug#10772: 24.0.93; [patch] Convert tcl-auto-fill-mode to use define-minor-mode |
Date: |
Sat, 11 Feb 2012 15:27:18 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) |
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> 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.
The correct behavior seems to be if the tcl-auto-fill-mode is enabled
then calling auto-fill-mode will turn *auto-fill-mode off.
> Maybe we could use an approach like the one I used for
> (binary-)overwrite-mode.
I've been looking at this for the past day or so, and I'm still not sure
I know exactly what to do, but I've come up with 2 options.
This option works as I expect, ie when tcl-auto-fill-mode is enabled,
calling auto-fill-mode disables tcl-auto-fill-mode and auto-fill-mode.
--8<---------------cut here---------------start------------->8---
;; Docstrings elided
(define-minor-mode tcl-auto-fill-mode
:variable (eq auto-fill-function normal-auto-fill-function)
(if auto-fill-function
(kill-local-variable 'comment-auto-fill-only-comments)
(set (make-local-variable 'comment-auto-fill-only-comments) t)))
--8<---------------cut here---------------end--------------->8---
Or something more like this, which seems more in the spirit of binary
overwrite mode.
--8<---------------cut here---------------start------------->8---
;; Docstrings elided
(defun tcl-do-auto-fill ()
(if auto-fill-function
(kill-local-variable 'comment-auto-fill-only-comments)
(set (make-local-variable 'comment-auto-fill-only-comments) t))
(do-auto-fill))
(defvar tcl-auto-fill-function 'tcl-do-auto-fill)
(define-minor-mode tcl-auto-fill-mode
:variable (eq auto-fill-function tcl-auto-fill-function))
--8<---------------cut here---------------end--------------->8---
However other progmodes define f90-do-auto-fill, c-do-auto-fill,
cperl-do-auto-fill but tend to do the following.
--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.
William