GNU bug report logs -
#13641
24.3.50; `minibuffer-inactive-mode' - hook seems wrong
Previous Next
Reported by: "Drew Adams" <drew.adams <at> oracle.com>
Date: Wed, 6 Feb 2013 23:07:02 UTC
Severity: minor
Tags: moreinfo
Found in version 24.3.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13641 in the body.
You can then email your comments to 13641 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Wed, 06 Feb 2013 23:07:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Drew Adams" <drew.adams <at> oracle.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 06 Feb 2013 23:07:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I don't have the C sources, so cannot see just how/when
the hook `minibuffer-inactive-mode-hook' gets called.
I see this behavior with my own setup, which has a standalone minibuffer
frame: It seems like the hook is invoked for each toggle between
states active & inactive, i.e., including from inactive to active,
which would be wrong. I would expect the hook to be invoked only
when the minibuffer becomes inactive.
E.g.:
(defun move-frame-right (&optional n frame)
(interactive "p")
(unless n (setq n 1))
(setq n (* n (frame-char-width frame)))
(modify-frame-parameters frame
(list (list 'left '+ (new-frame-position frame 'left n)))))
(add-hook 'minibuffer-inactive-mode-hook #'move-frame-right)
Start with the minibuffer inactive and some frame other than the
minibuffer frame selected, and do M-x. That selected frame moves to the
right. Why? Then hit C-g to cancel M-x. The minibuffer frame moves to
the right.
The latter makes sense, because C-g inactivates the minibuffer. The
former invocation of the hook seems like a bug to me.
Then remove that hook function and do this instead:
Show buffer *Messages* in its own frame, then:
(add-hook 'minibuffer-inactive-mode-hook
(lambda ()
(message "fr: %S, active: %S"
(selected-frame) (active-minibuffer-window))))
Then, with frame *Messages* selected, do M-x, then C-g. This confirms
the double invocation. This is what I see (my minibuffer frame has a
long name):
fr: #<frame *Messages* 03F9CC10>, active: #<window 6 on *Minibuf-0*> [2 times]
fr: #<frame Emacs minibuffer - show/hide: hold CTRL + click in window 03FDDA48>,
active: nil
The first message, including the [2 times], appears after M-x. The
second message appears after C-g. Note that the first message indicates that
the minibuffer is _active_ - so why is the hook firing?
Now remove that hook function and then do this:
(add-hook 'minibuffer-inactive-mode-hook #'make-frame-invisible)
This is how I started. I was expecting the minibuffer frame to
essentially stay hidden except when the minibuffer was activated.
With *Messages* selected, M-x makes *Messages* disappear. Then C-g
makes the minibuffer frame disappear and brings back *Messages*.
Seems broken to me, but perhaps I'm missing something.
In GNU Emacs 24.3.50.1 (i386-mingw-nt5.1.2600)
of 2013-01-30 on ODIEONE
Bzr revision: 111631 michael.albinus <at> gmx.de-20130130192046-nx4rskw7jemmtrw8
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
`configure --with-gcc (4.7) --no-opt --enable-checking --cflags
-IC:/Devel/emacs/build/include --ldflags -LC:/Devel/emacs/build/lib'
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Wed, 06 Feb 2013 23:58:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 13641 <at> debbugs.gnu.org (full text, mbox):
> (add-hook 'minibuffer-inactive-mode-hook #'make-frame-invisible)
>
> This is how I started. I was expecting the minibuffer frame to
> essentially stay hidden except when the minibuffer was activated.
>
> With *Messages* selected, M-x makes *Messages* disappear. Then C-g
> makes the minibuffer frame disappear and brings back *Messages*.
Thinking it might have something to do with the minibuffer level, I tried this:
(add-hook 'minibuffer-inactive-mode-hook
(lambda ()
(message "fr: %S, active: %S, depth: %S"
(selected-frame)
(active-minibuffer-window)
(minibuffer-depth))
(unless (> (minibuffer-depth) 0)
(make-frame-invisible))))
Then M-x followed by C-g works, but only every other time.
The inactive minibuffer reappears every other time (why?).
It reappears even when the message shows that the depth is 0 and the minibuffer
is inactive.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Thu, 07 Mar 2013 03:00:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 13641 <at> debbugs.gnu.org (full text, mbox):
Any chance someone could please take a look at this behavior and explain what is
going on? Thx.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Thu, 15 Jul 2021 06:50:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 13641 <at> debbugs.gnu.org (full text, mbox):
"Drew Adams" <drew.adams <at> oracle.com> writes:
> I don't have the C sources, so cannot see just how/when
> the hook `minibuffer-inactive-mode-hook' gets called.
It seems that it's called twice. To test:
(add-hook 'minibuffer-inactive-mode-hook 'debug)
M-x
Debugger entered: nil
(closure (t) nil (debug) (message "foo"))()
run-hooks(change-major-mode-after-body-hook minibuffer-inactive-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook minibuffer-inactive-mode-hook))
run-mode-hooks(minibuffer-inactive-mode-hook)
minibuffer-inactive-mode()
read-from-minibuffer("M-x " nil (keymap (10 . minibuffer-complete-and-exit) (
completing-read-default("M-x " #f(compiled-function (string pred action) #<by
completing-read("M-x " #f(compiled-function (string pred action) #<bytecode -
read-extended-command()
The mode is called both on entering and exiting the minibuffer, which
sounds slightly surprising (but it doesn't really say anything about
when it's invoked, either). I guess it's this:
/* In case the previous minibuffer displayed in this miniwindow is
dead, we may keep displaying this buffer (tho it's inactive), so reset it,
to make sure we don't leave around bindings and stuff which only
made sense during the read_minibuf invocation. */
call0 (Qminibuffer_inactive_mode);
Perhaps the doc string of `minibuffer-inactive-mode' should mention that
it may be called several times, and that people looking at the mode's
hook should probably be looking at minibuffer-exit-hook instead? Any
opinions?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 15 Jul 2021 06:50:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Thu, 15 Jul 2021 07:23:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 13641 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Thu, 15 Jul 2021 08:49:38 +0200
> Cc: 13641 <at> debbugs.gnu.org
>
> The mode is called both on entering and exiting the minibuffer, which
> sounds slightly surprising
Isn't it generally true that a mode function is called both when
turning a mode on and when turning it off? Then why is the above
surprising?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Thu, 15 Jul 2021 07:27:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 13641 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> The mode is called both on entering and exiting the minibuffer, which
>> sounds slightly surprising
>
> Isn't it generally true that a mode function is called both when
> turning a mode on and when turning it off? Then why is the above
> surprising?
`minibuffer-inactive-mode' is a major mode, so I don't know whether the
concept "turning it off" makes sense?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13641
; Package
emacs
.
(Thu, 12 Aug 2021 15:17:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 13641 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Perhaps the doc string of `minibuffer-inactive-mode' should mention that
> it may be called several times, and that people looking at the mode's
> hook should probably be looking at minibuffer-exit-hook instead?
Now done in Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 28.1, send any further explanations to
13641 <at> debbugs.gnu.org and "Drew Adams" <drew.adams <at> oracle.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 12 Aug 2021 15:17:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 10 Sep 2021 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 288 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.