From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: questions about define-minor-mode Date: Thu, 8 Apr 2010 08:51:59 -0700 Message-ID: <4576E95FD8124CC1B0C77C7DECF45EE7@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1270741965 10065 80.91.229.12 (8 Apr 2010 15:52:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 8 Apr 2010 15:52:45 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 08 17:52:42 2010 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.69) (envelope-from ) id 1Nzu22-00074k-Oz for ged-emacs-devel@m.gmane.org; Thu, 08 Apr 2010 17:52:39 +0200 Original-Received: from localhost ([127.0.0.1]:37982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzu22-0003N6-AX for ged-emacs-devel@m.gmane.org; Thu, 08 Apr 2010 11:52:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nzu1x-0003Mx-Qq for emacs-devel@gnu.org; Thu, 08 Apr 2010 11:52:33 -0400 Original-Received: from [140.186.70.92] (port=48774 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzu1w-0003Mm-NJ for emacs-devel@gnu.org; Thu, 08 Apr 2010 11:52:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nzu1v-0002ry-0R for emacs-devel@gnu.org; Thu, 08 Apr 2010 11:52:32 -0400 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:33321) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nzu1u-0002rl-NV for emacs-devel@gnu.org; Thu, 08 Apr 2010 11:52:30 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet12.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o38FqR26009782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 8 Apr 2010 15:52:29 GMT Original-Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o38FM3PQ018946 for ; Thu, 8 Apr 2010 15:52:16 GMT Original-Received: from abhmt008.oracle.com by acsmt353.oracle.com with ESMTP id 158238271270741920; Thu, 08 Apr 2010 08:52:00 -0700 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Apr 2010 08:52:00 -0700 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcrXM2yKrA7PqFh1SxWlv8Q+YmLXHw== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: acsmt354.oracle.com [141.146.40.154] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090209.4BBDFBB9.016E:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:123347 Archived-At: 1. `define-minor-mode' defines a defcustom if the mode is declared global, but it does not otherwise. Why not? I'm sure there is a good reason, but it's not clear to me. Why shouldn't a user be able to customize the (default) value for a non-global minor mode? I understand that if the user changes the value in some buffer then that would change the option's value, but that's not a big deal, in itself. What would be ideal, I'd think, would be for the option to control only the default value (at least when not global), and thus have any value changes not affect the option value (i.e. the default value). 2. Also, the Elisp manual documentation for this (node `Defining Minor Modes') is a bit unclear. Although it states clearly that the custom variable is created only if you use `global', the following paragraph appears at the end of the macro description, and not within the description's `:global' subsection: Any other keyword arguments are passed directly to the `defcustom' generated for the variable MODE. It would be clearer if it were pointed out here (again) that this variable is a defcustom only if the mode is global. Or if this sentence were moved to the `:global' subsection. 3. The explanation of "initial value must (!) be `nil'" is not clear to me at all. I don't understand either the "exceptional" conditions under which non-nil is permitted (!) or the reasoning behind this rule. 4. FWIW, I recently defined a minor mode for use with Info. It makes sense that the mode be turned on by default, by anyone who would be using my code, but it also makes sense to let users easily override this default behavior - e.g. via Customize. In order to do that, I ended up changing the mode to be global. Yes, that might be a silly hack, since this minor mode makes sense only for Info (although you don't need it to be different for different Info buffers, but for purposes of illustration, suppose that you do). But it is also harmless to make it global since it has an effect only for Info mode. The reason I made it global, however, was just so that users would have an option to customize, in case they did want to turn it off by default for some reason. An option is easier for many users to deal with than adding Lisp code to .emacs. I mention this example to indicate better my confusion wrt why (a) only `global' creates an option and (b) why the init value "must" be nil. Coincidentally, I got an email today from a user of another of my minor modes, this one legitimately (!) global. He proposed to send me a patch to add a defcustom for the minor mode. In the file header I had only mentioned putting `(foo-mode 1)' in .emacs as a way to turn it on (the init value is nil), and he thought it would be good to also let users use Customize. I replied to him that there is in fact already a custom variable for this (since it's a global mode), and I updated the file header to make this clearer. The point is that even for users (and this person is apparently in charge of maintaining 3rd-party Emacs libraries for Debian) it is not necessarily clear that customization is possible, even for global modes. Also, I don't see any mention of Customize in the Emacs manual node `Minor Modes' (which is the first node in the `Customization' section of the manual). No mention that global modes have associated user options, which you can customize. Why not always define a defcustom for a minor mode, and advertise to users the use of Customize for minor modes? What am I missing?