From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: turning on minor modes from hooks Date: Sat, 29 Aug 2009 23:59:09 -0400 Message-ID: References: <200908292125.n7TLPCdp005058@godzilla.ics.uci.edu> <87eiqui4yx.fsf@catnip.gol.com> <9CA8B839B73049A6A7B1AD1C4D92BFC3@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1251604771 31774 80.91.229.12 (30 Aug 2009 03:59:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Aug 2009 03:59:31 +0000 (UTC) Cc: 'Dan Nicolaescu' , emacs-devel@gnu.org, 'Miles Bader' To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 30 05:59:24 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MhbZc-0003Ku-1n for ged-emacs-devel@m.gmane.org; Sun, 30 Aug 2009 05:59:24 +0200 Original-Received: from localhost ([127.0.0.1]:44679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhbZb-0005O4-Jj for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2009 23:59:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MhbZW-0005Nr-5P for emacs-devel@gnu.org; Sat, 29 Aug 2009 23:59:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MhbZR-0005N9-6Y for emacs-devel@gnu.org; Sat, 29 Aug 2009 23:59:17 -0400 Original-Received: from [199.232.76.173] (port=50133 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MhbZR-0005N6-1r for emacs-devel@gnu.org; Sat, 29 Aug 2009 23:59:13 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:38200 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MhbZP-0008Sh-Ch; Sat, 29 Aug 2009 23:59:11 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiEFAHCVmUpFpYuS/2dsb2JhbACBU9QlhBoFh2g X-IronPort-AV: E=Sophos;i="4.44,298,1249272000"; d="scan'208";a="44522115" Original-Received: from 69-165-139-146.dsl.teksavvy.com (HELO ceviche.home) ([69.165.139.146]) by ironport2-out.teksavvy.com with ESMTP; 29 Aug 2009 23:58:08 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 9BF6EB40F3; Sat, 29 Aug 2009 23:59:09 -0400 (EDT) In-Reply-To: <9CA8B839B73049A6A7B1AD1C4D92BFC3@us.oracle.com> (Drew Adams's message of "Sat, 29 Aug 2009 17:14:53 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114869 Archived-At: >> Stephen has long advocated that non-interactive invocation of mode ^^^^^^^ Was that meant to be me? >> commands should always turn on the mode instead of toggling. > So interactively a nil arg will toggle, but in Lisp a nil arg will > turn it on? And just why is that a great idea? No: currently, minor modes defined with `define-minor-mode' will never receive nil when invoked interactively. They'll either get a prefix arg, or the symbol `toggle'. The patch below would change define-minor-mode as suggested. Stefan --- lisp/emacs-lisp/easy-mmode.el 2009-01-05 10:18:22 +0000 +++ lisp/emacs-lisp/easy-mmode.el 2009-07-24 02:11:35 +0000 @@ -225,12 +225,7 @@ (cond ((eq arg 'toggle) (not ,mode)) (arg (> (prefix-numeric-value arg) 0)) - (t - (if (null ,mode) t - (message - "Toggling %s off; better pass an explicit argument." - ',mode) - nil)))) + (t))) ,@body ;; The on/off hooks are here for backward compatibility only. (run-hooks ',hook (if ,mode ',hook-on ',hook-off))