From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: William Stevenson Newsgroups: gmane.emacs.bugs 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 Message-ID: <87r4y1pezt.fsf@gmail.com> References: <87fwektsb4.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1328974130 24960 80.91.229.3 (11 Feb 2012 15:28:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 11 Feb 2012 15:28:50 +0000 (UTC) To: 10772@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 11 16:28:49 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RwEsZ-0008He-S8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Feb 2012 16:28:48 +0100 Original-Received: from localhost ([::1]:59770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwEsZ-0000Ly-4K for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Feb 2012 10:28:47 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwEsW-0000Ln-9I for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:28:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwEsV-0008U0-4X for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:28:44 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwEsV-0008Tv-2r for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:28:43 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1RwEtm-0000x0-30 for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:30:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87fwektsb4.fsf@gmail.com> Resent-From: William Stevenson Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Feb 2012 15:30:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10772 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13289741493566 (code B ref -1); Sat, 11 Feb 2012 15:30:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Feb 2012 15:29:09 +0000 Original-Received: from localhost ([127.0.0.1]:36307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RwEsu-0000vT-Oc for submit@debbugs.gnu.org; Sat, 11 Feb 2012 10:29:09 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:36486) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RwEsr-0000ux-Np for submit@debbugs.gnu.org; Sat, 11 Feb 2012 10:29:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwErU-0008Lu-8N for submit@debbugs.gnu.org; Sat, 11 Feb 2012 10:27:41 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:47267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwErU-0008Lq-3T for submit@debbugs.gnu.org; Sat, 11 Feb 2012 10:27:40 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:34850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwErT-0000J7-06 for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:27:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwErR-0008LP-LQ for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:27:38 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:33580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwErR-0008LE-GD for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 10:27:37 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1RwErL-0007St-Fc for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2012 16:27:31 +0100 Original-Received: from cpc10-belf9-2-0-cust411.2-1.cable.virginmedia.com ([86.24.57.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 11 Feb 2012 16:27:31 +0100 Original-Received: from yhvh2000 by cpc10-belf9-2-0-cust411.2-1.cable.virginmedia.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 11 Feb 2012 16:27:31 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 61 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: cpc10-belf9-2-0-cust411.2-1.cable.virginmedia.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) Cancel-Lock: sha1:+4EqMkfuK4KWSJuN1Q8JsAxamEs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:56795 Archived-At: Stefan Monnier 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