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


Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: William Stevenson <yhvh2000 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: 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
Stefan Monnier <monnier <at> 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





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.