From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch] Date: Fri, 18 Jan 2013 17:09:24 +0000 Message-ID: <20130118170924.GA4719@acm.acm> References: <20130113192854.GA4853@acm.acm> <20130114163003.GC3274@acm.acm> <20130115140855.GA3430@acm.acm> <20130117175159.GA3114@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1358530002 4179 80.91.229.3 (18 Jan 2013 17:26:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jan 2013 17:26:42 +0000 (UTC) Cc: Chong Yidong , =?iso-8859-1?Q?Jo=E3o_T=E1vora?= , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 18 18:27:00 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TwFiO-0008Me-Hz for ged-emacs-devel@m.gmane.org; Fri, 18 Jan 2013 18:26:52 +0100 Original-Received: from localhost ([::1]:55422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwFi7-0002l9-Sd for ged-emacs-devel@m.gmane.org; Fri, 18 Jan 2013 12:26:35 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwFi4-0002kP-H6 for emacs-devel@gnu.org; Fri, 18 Jan 2013 12:26:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwFi3-0003Ny-9k for emacs-devel@gnu.org; Fri, 18 Jan 2013 12:26:32 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:52422 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwFY5-0000nE-Ml for emacs-devel@gnu.org; Fri, 18 Jan 2013 12:16:13 -0500 Original-Received: (qmail 43764 invoked by uid 3782); 18 Jan 2013 17:16:10 -0000 Original-Received: from acm.muc.de (pD951A88D.dip.t-dialin.net [217.81.168.141]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 18 Jan 2013 18:16:08 +0100 Original-Received: (qmail 4763 invoked by uid 1000); 18 Jan 2013 17:09:24 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156461 Archived-At: Hello, Stefan. On Thu, Jan 17, 2013 at 01:31:32PM -0500, Stefan Monnier wrote: > > I'm still trying to come up with a reason somebody might want to turn on > > the minor mode _before_ the major mode's hook has been run. > The issue is how to locally turn off the globalized minor mode from > a major-mode hook. If the globalized mode is enabled after the > major-mode hook, you basically can't do it without resorting to > ugly gymnastics. Ah, OK. > I'm not completely sure what happens (and what should happen instead) in > your scenario, but for the case described by Joćo, where you don't just > want to disable it in some modes, but you want to prevent it from ever > being enabled in such modes, obviously the current approach > fails similarly. > A simple solution is to activate the minor mode late, and provide > a `disable-foo-mode' variable, that can be set in the major mode hook. > But it's kind of ugly because it requires another var and the user needs > to know about that magic var. Not enabling a globally-enabled mode in particular buffers is essentially ugly, so whatever solution we come up with will be ugly too. > Maybe we could do it this way: > for a globalized minor mode `foo', before running the major-mode hook, a magic > `disable-foo-mode' is set to nil. A function is added to `foo-mode-hook' > which sets this var to t when foo-mode is disabled. And after running > the major-mode hook, the globalized minor mode code checks the magic var > to decide whether to enable the minor mode. !!!!!!!!!!!!!!! > This way, the user doesn't need to know about the extra magic var; she > can just call (foo-mode -1) in her major-mode hook as she can now, but > the minor-mode is really only activated late. > It's also kind of ugly because of all the magic, but it's the best I can > come up with so far. I can't come up with anything better at the moment, either, but I can't help feeling that there's something more fundamental about global minor modes that we're missing. > Stefan -- Alan Mackenzie (Nuremberg, Germany).