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: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch] Date: Thu, 17 Jan 2013 13:31:32 -0500 Message-ID: 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: quoted-printable X-Trace: ger.gmane.org 1358447504 20843 80.91.229.3 (17 Jan 2013 18:31:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Jan 2013 18:31:44 +0000 (UTC) Cc: Chong Yidong , =?iso-8859-1?Q?Jo=E3o_T=E1vora?= , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 17 19:32:02 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 1TvuFr-0008Rl-LT for ged-emacs-devel@m.gmane.org; Thu, 17 Jan 2013 19:31:59 +0100 Original-Received: from localhost ([::1]:58407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvuFa-0002dL-TQ for ged-emacs-devel@m.gmane.org; Thu, 17 Jan 2013 13:31:42 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvuFY-0002dD-Kr for emacs-devel@gnu.org; Thu, 17 Jan 2013 13:31:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvuFX-0008MU-Fp for emacs-devel@gnu.org; Thu, 17 Jan 2013 13:31:40 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:32129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvuFU-0008LG-C0; Thu, 17 Jan 2013 13:31:36 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtkGAG6Zu09FpZpV/2dsb2JhbABEgXuyFoEIghUBAQQBViMFCwsOJhIUGA0kLoduBboJkEQDiEKacYFYgwc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="212802640" Original-Received: from 69-165-154-85.dsl.teksavvy.com (HELO pastel.home) ([69.165.154.85]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 17 Jan 2013 13:31:33 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 096B759537; Thu, 17 Jan 2013 13:31:32 -0500 (EST) In-Reply-To: <20130117175159.GA3114@acm.acm> (Alan Mackenzie's message of "Thu, 17 Jan 2013 17:51:59 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 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:156450 Archived-At: > 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. I'm not completely sure what happens (and what should happen instead) in your scenario, but for the case described by Jo=E3o, 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. Maybe we could do it this way: for a globalized minor mode `foo', before running the major-mode hook, a ma= gic `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. Stefan