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: Wed, 24 Jan 2007 23:57:28 -0500 Message-ID: References: <4581996F.3050700@student.lu.se> <87y7nxmqzh.fsf@stupidchicken.com> <45B6A179.9020604@gmail.com> <45B7B3AE.9020000@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1169701087 21564 80.91.229.12 (25 Jan 2007 04:58:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Jan 2007 04:58:07 +0000 (UTC) Cc: cyd@stupidchicken.com, rms@gnu.org, emacs-devel@gnu.org To: "Lennart Borgman \(gmail\)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 25 05:57:59 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 1H9wgQ-0007La-NX for ged-emacs-devel@m.gmane.org; Thu, 25 Jan 2007 05:57:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H9wgP-0001gE-PV for ged-emacs-devel@m.gmane.org; Wed, 24 Jan 2007 23:57:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H9wgE-0001g9-E5 for emacs-devel@gnu.org; Wed, 24 Jan 2007 23:57:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H9wgB-0001fx-Hi for emacs-devel@gnu.org; Wed, 24 Jan 2007 23:57:45 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H9wgB-0001fu-CD for emacs-devel@gnu.org; Wed, 24 Jan 2007 23:57:43 -0500 Original-Received: from bc.sympatico.ca ([209.226.175.184] helo=tomts22-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H9wg4-0003Ml-R5; Wed, 24 Jan 2007 23:57:37 -0500 Original-Received: from pastel.home ([74.12.211.125]) by tomts22-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070125045729.LLKJ8030.tomts22-srv.bellnexxia.net@pastel.home>; Wed, 24 Jan 2007 23:57:29 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id BB9C782DF; Wed, 24 Jan 2007 23:57:28 -0500 (EST) In-Reply-To: <45B7B3AE.9020000@gmail.com> (Lennart Borgman's message of "Wed\, 24 Jan 2007 20\:29\:50 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux) X-detected-kernel: Solaris 8 (1) 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:65455 Archived-At: > I previously used defcustom variables to manage something similar to > define-globalized-mode MY-GLOBAL-MODE MY-MODE. This worked ok. I then used > the :set function to turn on the minor mode MY-MODE. > Using define-minor-mode there is no way to do something similar. There is no > code that is run when the library file is loaded, even if the minor mode is > global and that is in my opinion a bug (or at least a very inconvenient > inconsistency). Yes, there is code that runs the minor-mode function if it is global and has been set. This *should* work. So please tell us what you tried that failed to work. > Actually define-minor-mode says that "other keywords will be passed to > defcustom if the minor mode is global". Should not this mean that :set > should be passed to defcustom and therefore be run when loading the library > file if the minor mode as been customized to be on? I can not see that :set > is run however. Try to look at the macro expansion of (define-minor-mode foo-mode "Foo" :global t) and you'll see it's got a :set. > Please test it with the defcustom and define-minor-mode set. I don't know what the above sentence means. > (define-minor-mode html-site-temp-mode > "dummy" > :init-value nil > :lighter nil > :global t > :keymap (let ((m (make-sparse-keymap))) > (define-key m [f11] (lambda() (interactive) (message > "html-site-mode-temp f11 here"))) > m) > :set (lambda(sym val) > (message ":set html-site-temp-mode: sym=%s, val=%s" sym val) > (set-default sym val)) > (message "body html-site-temp-mode=%s, current-buffer=%s" html-site-mode > (current-buffer))) Passing a :set here is likely to lead to surprises. > As I use to say: I do not want to touch the CVS this close to the release > since I am unfamiliar with cvs. It's never too late to learn. You can start by posting a patch generated from "cvs diff", at which point "cvs commit -m " should be all that's needed. > I would be glad if you changed the name. So would I, but I don't have much time, Stefan