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: How global is a define-global-minor-mode mode? Date: Sun, 21 Jan 2007 18:11:00 -0500 Message-ID: References: <4581996F.3050700@student.lu.se> <87y7nxmqzh.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1169421083 16594 80.91.229.12 (21 Jan 2007 23:11:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 21 Jan 2007 23:11:23 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 22 00:11:20 2007 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 1H8lqI-000597-OQ for ged-emacs-devel@m.gmane.org; Mon, 22 Jan 2007 00:11:19 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H8lqI-00028g-E2 for ged-emacs-devel@m.gmane.org; Sun, 21 Jan 2007 18:11:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H8lq4-00026W-4J for emacs-devel@gnu.org; Sun, 21 Jan 2007 18:11:04 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H8lq2-00022e-CE for emacs-devel@gnu.org; Sun, 21 Jan 2007 18:11:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H8lq2-00022C-5G for emacs-devel@gnu.org; Sun, 21 Jan 2007 18:11:02 -0500 Original-Received: from [209.226.175.34] (helo=tomts13-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H8lq1-0001P2-IT for emacs-devel@gnu.org; Sun, 21 Jan 2007 18:11:01 -0500 Original-Received: from pastel.home ([70.55.144.55]) by tomts13-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070121231100.DZHK1773.tomts13-srv.bellnexxia.net@pastel.home> for ; Sun, 21 Jan 2007 18:11:00 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id C14888C69; Sun, 21 Jan 2007 18:11:00 -0500 (EST) Original-To: Chong Yidong In-Reply-To: <87y7nxmqzh.fsf@stupidchicken.com> (Chong Yidong's message of "Sat\, 20 Jan 2007 14\:34\:58 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux) 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:65356 Archived-At: >> I am trying to use define-global-minor-mode, see below. I have >> customized the global mode to be t, but when I open new buffers the >> minor mode is not set in them. Is this a bug in >> define-global-minor-mode? > Seems to be working fine. Your recipe is a little vague, but here is > a simple example: > 1. Evaluate the following in *scratch* buffer: > (define-minor-mode foo-mode > "Foo." > nil > " foo" > :group 'foo) > (define-global-minor-mode html-site-global-mode foo-mode > (lambda () (foo-mode 1)) > :group 'foo) > 2. M-x customize-option RET foo RET > 3. Click on "Toggle" (global-foo-mode is turned on) > 4. Click on "Set for Current Session" > 5. C-x C-f asdf RET (open a new file) > 6. Observe the presence of the " foo" lighter in the modeline. > There is one subtlety, which is that if you save the custom option for > future sessions, it won't activate foo-mode in future sessions unless > the above code defining foo-mode and global-foo-mode is already > loaded. But I don't think that's necessary a bug; it's a flaw but not > one that's easily avoidable. Isn't it the case that it works if the minor mode function corresponding to the variable is autoloaded? Otherwise, IIRC you need to add a :require to the definition of the minor mode. Stefan