GNU bug report logs - #29081
25.1; define-globalized-minor-mode does not respect :variable of original mode

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: k@HIDDEN (Chris Stj); Keywords: confirmed easy; dated Tue, 31 Oct 2017 15:41:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) confirmed and easy. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 29081 <at> debbugs.gnu.org:


Received: (at 29081) by debbugs.gnu.org; 2 Dec 2017 19:04:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 02 14:04:36 2017
Received: from localhost ([127.0.0.1]:42195 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eLD5X-0003iL-Qs
	for submit <at> debbugs.gnu.org; Sat, 02 Dec 2017 14:04:36 -0500
Received: from mail-io0-f178.google.com ([209.85.223.178]:36239)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>)
 id 1eLD5V-0003i3-V8; Sat, 02 Dec 2017 14:04:34 -0500
Received: by mail-io0-f178.google.com with SMTP id 81so14644893iof.3;
 Sat, 02 Dec 2017 11:04:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=8Mh3B6RAbhdRAr6ad1YQ12WNzw/q90VGT3kL4iHtrTY=;
 b=RhOgwnkW43OSRkrIG5Zy6Ax3ns5bKTUg1IfFl006uEfp9O80VmSMthxjfj18qAYijJ
 XyBzqfI4lnG68+G3qlhXPJFBNC08aebshg5/2kkv3wC1Fjjehb+yJAtyEsI2ym1y7kUr
 kIUYih4RzscoR39+PvNJPhlNsP9BewNXYvGxZX6JDep8KYzVz9S51e9GTUP0Ir+6X+7q
 4E4DoB2AfXPCmgnRWr5I19kyMey+scuKonOenTT5u0OiPWqVjC7gn37tGHgjuaf+aMTo
 BCvUPIEOImgI3Skl7ywcgXkYGnrqpFebwQ00vuQzLMBZUyMO5kZsA4evgCC6KSd+zxFv
 3bCg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:references:date
 :in-reply-to:message-id:user-agent:mime-version;
 bh=8Mh3B6RAbhdRAr6ad1YQ12WNzw/q90VGT3kL4iHtrTY=;
 b=rLXBQvyjyxo5qx99llJtASC+v6xLiOPDXv35wKq72dHPKgvx8MCHQSGLUU+yZeDyY2
 /Izf8vWjPovSaKi4S7dIfbiczuO3/nvUX2uS8tckNysg+faw4N81O4YTujBE99wWjz7R
 in7PXdAA74o0uBzcF/1tn0U+vBmYTVVhp4caxWI2hUr/0+tG/YfEIqI8kNTJP3Zoqgn6
 pz/T3qrndKcMomCCXR9EP+NdN61gQ8YKkI1+bSKC49cGtxoUbqBqJOcbkOS/ir8znfWw
 wi6Mz0pwKq4omrXyS72uJlBj0EFE4Jn4TFwLbw/kEkovoBHBxQ41OspU8AFEcQYEuFpx
 HNsA==
X-Gm-Message-State: AJaThX4rp5IHQXYQK49qsr8im+WT0WqEAtH7FoikPnpK4WvzsUxycvd9
 f7EUUq7uawD4ZbzU5KxhwjAKbg==
X-Google-Smtp-Source: AGs4zMboxkZ454qWRxcjibmHrjKNu9iL8OrL7sMzWy64aYfp932m5y8lY9CsWuRwpr8iYNi+lhBE1w==
X-Received: by 10.107.25.204 with SMTP id 195mr18438706ioz.67.1512241468177;
 Sat, 02 Dec 2017 11:04:28 -0800 (PST)
Received: from zebian ([45.2.119.34])
 by smtp.googlemail.com with ESMTPSA id o73sm2109307ito.4.2017.12.02.11.04.26
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Sat, 02 Dec 2017 11:04:27 -0800 (PST)
From: Noam Postavsky <npostavs@HIDDEN>
To: k@HIDDEN (Chris Stj)
Subject: Re: bug#29081: 25.1;
 define-globalized-minor-mode does not respect :variable of original
 mode
References: <87efpjijp6.fsf@HIDDEN>
Date: Sat, 02 Dec 2017 14:04:26 -0500
In-Reply-To: <87efpjijp6.fsf@HIDDEN> (Chris Stj's message of "Tue, 31 Oct 2017
 13:29:57 +0100")
Message-ID: <874lp9j6it.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 29081
Cc: 29081 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

tags 29081 + confirmed easy
quit

k@HIDDEN (Chris Stj) writes:

> The problem lies in the "if ,mode" condition. This assumes the minor
> mode variable has the same name as the minor mode itself; which is
> clearly not true when something else is specified with the :variable
> keyword in the minor mode definition.

> I guess the best solution may be to allow users of
> define-globalized-minor-mode to specify the place in which the minor
> mode stores its state, since I can't find a good, generic way to extract
> this from the minor mode definition itself, after the fact.

Makes sense to me.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#29081; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Oct 2017 15:40:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 31 11:40:51 2017
Received: from localhost ([127.0.0.1]:44384 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e9Yeo-0005GP-JH
	for submit <at> debbugs.gnu.org; Tue, 31 Oct 2017 11:40:51 -0400
Received: from eggs.gnu.org ([208.118.235.92]:57492)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <k@HIDDEN>) id 1e9VgP-00073L-Rh
 for submit <at> debbugs.gnu.org; Tue, 31 Oct 2017 08:30:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <k@HIDDEN>) id 1e9VgF-00085w-Si
 for submit <at> debbugs.gnu.org; Tue, 31 Oct 2017 08:30:12 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:53665)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <k@HIDDEN>) id 1e9VgF-00085q-PJ
 for submit <at> debbugs.gnu.org; Tue, 31 Oct 2017 08:30:07 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48424)
 by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <k@HIDDEN>)
 id 1e9VgE-0007JN-FI
 for bug-gnu-emacs@HIDDEN; Tue, 31 Oct 2017 08:30:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <k@HIDDEN>) id 1e9Vg8-00081Y-Fp
 for bug-gnu-emacs@HIDDEN; Tue, 31 Oct 2017 08:30:06 -0400
Received: from shelly.rdw.se ([188.226.220.149]:41832)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <k@HIDDEN>)
 id 1e9Vg8-00080v-9K
 for bug-gnu-emacs@HIDDEN; Tue, 31 Oct 2017 08:30:00 -0400
Received: from localhost (vps.xkqr.org [109.74.206.55])
 by shelly.rdw.se (Postfix) with ESMTPSA id EDE8E400E9
 for <bug-gnu-emacs@HIDDEN>; Tue, 31 Oct 2017 13:29:58 +0100 (CET)
From: k@HIDDEN (Chris Stj)
To: bug-gnu-emacs@HIDDEN
Subject: 25.1;
 define-globalized-minor-mode does not respect :variable of original
 mode
Date: Tue, 31 Oct 2017 13:29:57 +0100
Message-ID: <87efpjijp6.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 31 Oct 2017 11:40:49 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

I tried to define a global version of auto-fill mode by evaluating

  (define-globalized-minor-mode global-auto-fill-mode auto-fill-mode
    turn-on-auto-fill)

The problem is that when the define-globalized-minor-mode macro expands,
it defines the function

       (defun ,MODE-enable-in-buffers ()
	 (dolist (buf ,MODE-buffers)
	   (when (buffer-live-p buf)
	     (with-current-buffer buf
               (unless ,MODE-set-explicitly
		 (unless (eq ,MODE-major-mode major-mode)
		   (if ,mode
		       (progn
			 (,mode -1)
			 (funcall #',turn-on))
		     (funcall #',turn-on))))
	       (setq ,MODE-major-mode major-mode)))))

The problem lies in the "if ,mode" condition. This assumes the minor
mode variable has the same name as the minor mode itself; which is
clearly not true when something else is specified with the :variable
keyword in the minor mode definition.

I noticed this with auto-fill-mode, since it calls its status variable
auto-fill-function rather than auto-fill-mode.

I guess the best solution may be to allow users of
define-globalized-minor-mode to specify the place in which the minor
mode stores its state, since I can't find a good, generic way to extract
this from the minor mode definition itself, after the fact.

Regards,
Chris




Acknowledgement sent to k@HIDDEN (Chris Stj):
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#29081; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 2 Dec 2017 19:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.