From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#64048: 30.0.50; global-display-line-numbers-mode has no easy way to set modes where it is enabled Date: Wed, 14 Jun 2023 12:48:54 +0000 Message-ID: <87fs6u8b0p.fsf@localhost> References: <87a5x3sa7w.fsf@localhost> <83bkhjweco.fsf@gnu.org> <875y7rs5s5.fsf@localhost> <835y7rwbmb.fsf@gnu.org> <87352vs2g5.fsf@localhost> <83wn07usx7.fsf@gnu.org> <87sfavqhn5.fsf@localhost> <83mt12uufn.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36899"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64048@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 14 14:45:30 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9PsP-0009Pn-G1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Jun 2023 14:45:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9Ps4-0004om-Ek; Wed, 14 Jun 2023 08:45:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9Pry-0004oG-OA for bug-gnu-emacs@gnu.org; Wed, 14 Jun 2023 08:45:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q9Pry-0003qj-8k for bug-gnu-emacs@gnu.org; Wed, 14 Jun 2023 08:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q9Prx-0002uW-PH for bug-gnu-emacs@gnu.org; Wed, 14 Jun 2023 08:45:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Jun 2023 12:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64048 X-GNU-PR-Package: emacs Original-Received: via spool by 64048-submit@debbugs.gnu.org id=B64048.168674665011112 (code B ref 64048); Wed, 14 Jun 2023 12:45:01 +0000 Original-Received: (at 64048) by debbugs.gnu.org; 14 Jun 2023 12:44:10 +0000 Original-Received: from localhost ([127.0.0.1]:43984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9Pr8-0002t9-7m for submit@debbugs.gnu.org; Wed, 14 Jun 2023 08:44:10 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:54155) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9Pr5-0002su-Pd for 64048@debbugs.gnu.org; Wed, 14 Jun 2023 08:44:08 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id D9A9D240101 for <64048@debbugs.gnu.org>; Wed, 14 Jun 2023 14:44:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686746641; bh=tuICx/6eUTyhM7bKmxU9LhMBIsWYYxzIn9OxgV7kbQA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=q7gubrMobyj8o7fb+rV6zMGyx6jhleO2yoc93bvDV8JJq+GRRNrRuybynC1QWasgz SvMYJAmqpZta21Ui2tjSC50BaTSTDS+3ECxtjssEEfjN5Z41G1HeSbkJjnVKyMlx6X +H7XJH1+r3DbnfaDcJJfKG90rUXcYrr1DvR1v1b4nqyd+F0np/j+j0fSuOl3GVW7LC i6YMrVxs6fxi3ik7JZVqKJuPsB4nu47GlKXR3IwQ49JxnL3NEvfLcs/D7gRX1+tOY4 OhOLiL5Pk43tLu7Maank61DgyPwmKFfFd8LWokCNCduDkfPSth/WEJkAjYeUVXdOqR fwgr7BGHtlbFA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qh4qN3zWWz9rxG; Wed, 14 Jun 2023 14:44:00 +0200 (CEST) In-Reply-To: <83mt12uufn.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263370 Archived-At: Eli Zaretskii writes: >> Let me correct my initial suggestion: >> >> (define-globalized-minor-mode global-display-line-numbers-mode >> display-line-numbers-mode display-line-numbers--turn-on >> :predicate t) > > This change is probably harmless, but OTOH what does it give you that > the current code doesn't? AFAIU, you still cannot customize the modes > where line numbers will be off. > > IOW, :predicate is not a means for user customizations of the modes > where the minor mode will be turned on. Or am I missing something? >> :predicate defines the default value of >> `global-display-line-numbers-modes' variable. > > It does? Where is this documented? Yup. It is not documented on API level, but when :predicate is non-nil, `define-globalized-minor-mode' does the following: (setq turn-on-function `(lambda () (require 'easy-mmode) (when (easy-mmode--globalized-predicate-p ,MODE-predicate) (funcall ,turn-on-function)))) ;; Minor mode docstring: (if predicate (concat "\n\n" (internal--format-docstring-line "`%s' is used to control which modes this minor mode is used in." MODE-predicate)) ;; -modes "") ,(when predicate `(defcustom ,MODE-predicate ,(car predicate) ,(format "Which major modes `%s' is switched on in. This variable can be either t (all major modes), nil (no major modes), or a list of modes and (not modes) to switch use this minor mode or not. For instance (c-mode (not message-mode mail-mode) text-mode) means \"use this mode in all modes derived from `c-mode', don't use in modes derived from `message-mode' or `mail-mode', but do use in other modes derived from `text-mode'\". An element with value t means \"use\" and nil means \"don't use\". There's an implicit nil at the end of the list." mode) :type '(repeat sexp) ,@group)) >> One can, of course, disable the minor mode selectively in some major >> modes from that major mode hooks, but it is surprisingly non-obvious >> approach. > > You can either disable it selectively (which is very obvious to me, > FWIW), or you can selectively enable it. Both approaches are not > rocket science, IMO. I partially agree, and I also find the approach obvious once I see it. But the variable is easier (requires less Elisp knowledge) and is already used in _some_ global minor modes. IMHO, controlling global minor modes is one of the basic features that should be better exposed to newbie users who use customize interface and do not know Elisp. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at