all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 27639@debbugs.gnu.org
Subject: bug#27639: 25.2; Fix syntax for minor mode enabling in dir locals in manual
Date: Tue, 11 Jul 2017 16:57:32 +0000	[thread overview]
Message-ID: <CAFyQvY3Yt_hx+wDFyVY7SSf-yhW6BC4yziKqBtuo0TyAtp_d4w@mail.gmail.com> (raw)
In-Reply-To: <83wp7fhquh.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2984 bytes --]

Hi Eli,

Thanks for reviewing this.

On Tue, Jul 11, 2017 at 12:38 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Kaushal Modi <kaushal.modi@gmail.com>
> > Date: Mon, 10 Jul 2017 11:55:58 +0000
> >
> > I recently stumbled across this Reddit post[1] where a user is trying to
> enable a minor mode in .dir-locals.el.
> > But he was doing that by setting the mode name to `t'.
>
> indent-tabs-mode is the mode variable, so setting it to t is not a
> mistake.
>

The mistake (as explained in the Reddit post) was setting a 'custom-mode'
to t and expecting that that would rightaway enable that 'custom-mode'
minor mode. The OP on that Reddit thread later confirms[2] that doing (mode
. custom) worked easily, while trying to do (custom-mode . t) needed him to
mark that var as safe.


> > We generally(?) enable minor modes by doing (mode . MINOR) in
> .dir-locals.el.
>
> You could do it either way.  Also, some modes don't have such a
> variable, so only the latter way will work.
>

Almost all the user minor modes are created using define-minor-mode. At
least I have not to come across one where that's not the case in the user
land.

But why do you think we should only advertise one method, but not the
> other?


From (emacs) Minor Modes

=====
   Most minor modes also have a "mode variable", with the same name as
the mode command.  Its value is non-‘nil’ if the mode is enabled, and
‘nil’ if it is disabled.  In general, you should not try to enable or
disable the mode by changing the value of the mode variable directly in
Lisp; you should run the mode command instead.

(Reading further: Does below apply to setting minor mode variables via
.dir-locals.el?)

However, setting the
mode variable through the Customize interface (*note Easy
Customization::) will always properly enable or disable the mode, since
Customize automatically runs the mode command for you.
=====

In any case, as a user, I find it clearer to understand that you must never
enable minor modes by just setting their var; you should call that minor
mode fn instead. That realization also lead me to summarize minor mode
enabling conventions here[1] few years ago.

Also, if a user uses the (mode . minor) convention instead of (minor-mode .
t), they do not have to worry about declaring them safe.

There's no magic here, just legitimate use of public
> documented variables: 'mode' is a variable and so is 'indent-tabs-mode'.
>
> So I think I don't get your motivation for the report and for the
> patch you provided.


It just sets a convention that does not cause confusion (or create hurdle
like marking vars safe).

- If you want to set a plain var: do (var . value)
- If you want to enable a minor-mode: do (mode . minor)

[1]: https://emacs.stackexchange.com/a/10971/115
[2]:
https://www.reddit.com/r/emacs/comments/6malb6/disable_warning_message_when_enabling_minor_modes/dk0yxur/
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 4447 bytes --]

  reply	other threads:[~2017-07-11 16:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 11:55 bug#27639: 25.2; Fix syntax for minor mode enabling in dir locals in manual Kaushal Modi
2017-07-10 22:36 ` Kaushal Modi
2017-07-11 16:37 ` Eli Zaretskii
2017-07-11 16:57   ` Kaushal Modi [this message]
2017-07-11 17:32     ` Eli Zaretskii
2019-11-08  1:31       ` Stefan Kangas
2017-07-15  3:14 ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY3Yt_hx+wDFyVY7SSf-yhW6BC4yziKqBtuo0TyAtp_d4w@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=27639@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.