bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47150: [External] : bug#47150: 28.0.50; Incorrect major-mode in mini


From: Stefan Monnier
Subject: bug#47150: [External] : bug#47150: 28.0.50; Incorrect major-mode in minibuffer
Date: Mon, 12 Apr 2021 16:46:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> OK, what you say is true, what I said above is also true - active
> minibuffers ran in minibuffer-inactive-mode

That was true "in name only" (i.e. only the value of the variable
`major-mode` reflected that).

>> The keymap and the hook are the main two features of
>> `minibuffer-inactive-mode`.
> Yes.  Possibly they're the only features.

Pretty much, yes.

> Am I right in thinking that your main worry is the hook not getting
> called at the end of every MB action?

No.  My worries are:
- not having the minibuffer-inactive-mode-map active when the minibuffer
  is inactive.
- running minibuffer-inactive-mode-hook at other times than when the
  minibuffer becomes inactive.

>> > The idea here is to avoid the proliferation of unneeded major modes.
>> Major modes are cheap.  There is no problem with proliferation.
> That's not true - the OP has found a problem, in that some minor modes
> switch themselves on when (memq major-mode foo-mode-list).
> The current situation, fundamental-mode (active),
> minibuffer-inactive-mode (inactive) is causing problems with that
> scheme, hence this bug.

Their code was buggy/naive, will be broken no matter what we choose
to do (except for sticking to what we had in Emacs<28), and is easy to
fix in a backward compatible way using `minibufferp`.
So I don't think this matters very much.

Most cases of (eq major-mode <foo>) are bugs waiting to bite you.

> How about having just minibuffer-mode, and calling it at the end of
> every MB action (as was previously done with minibuffer-inactive-mode),
> but not at the start of a MB action?  This will call the mode hook at
> the same times as the m-inactive-m-hook used to be called, and reset the
> MB's keymap to the inactive map at the same time.

IOW just renaming `minibuffer-inactive-mode` to `minibuffer-mode` and
calling it one extra time at the very beginning?

Technically, it won't break any of my uses, of course, but then it leads
to rather counter-intuitive situations where "the keymap of
`minibuffer-mode`" is almost never used (it's only active when the
minibuffer is inactive), "the hook of `minibuffer-mode`" is run not when
entering a minibuffer but when leaving it, ...

Also, there's a natural desire to occasionally use other major modes in
the minibuffer (e.g. for `M-:`), so it would be very natural to make
them derived modes of `minibuffer-mode` except that it would then
inherit from a keymap which makes no sense in an active minibuffer.

It just doesn't seem right at all.

What's wrong with just making a new mode

    (define-derived-mode minibuffer-mode nil "Minibuffer"
      "Mode used inside minibuffers.")

and using that instead of `fundamental-mode`.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]