unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Emacs 28 trigger after-change-major-mode-hook inside mini buffer
@ 2022-08-21 12:22 Jakub T. Jankiewicz
  2022-08-21 12:29 ` Eli Zaretskii
  2022-08-21 14:22 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 6+ messages in thread
From: Jakub T. Jankiewicz @ 2022-08-21 12:22 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

I have this in my .emacs file, which break interactive function in Emacs 28.

```lisp
(defun new-line-and-indent-fix ()
  (interactive)
  (newline)
  (indent-for-tab-command))

(defun after-major-mode ()
  (if (memql major-mode '(yaml-mode
                          python-mode
                          nxml-mode
                          lisp-interaction-mode))
      (electric-indent-mode -1))
  (if (not (memql major-mode
                  '(fundamental-mode
                    erc-mode
                    text-mode
                    eshell-mode
                    shell-mode
                    inferior-js-mode
                    nodejs-repl-mode
                    change-log-mode
                    comint-mode
                    lisp-interaction-mode
                    inferior-scheme-mode
                    sql-mode)))
      (progn
        (local-set-key (kbd "RET")
                       'new-line-and-indent-fix))))

(add-hook 'after-change-major-mode-hook 'after-major-mode)
```

I don't remember why exactly I used this code, somehow the auto indent was
not working for me.

When I run interactive function it trigger new-line-and-indent-fix inside
minibuffer which means that after-change-major-mode-hook is triggered inside
mini buffer. Was this change documented?

So to fix the problem I need to know: what type of major mode does the mini
buffer now have in Emacs 28? So I can filter out that major mode.

I'm using:
GNU Emacs 28.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.34, cairo
version 1.17.6) of 2022-07-15

Thanks,
Jakub

--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs 28 trigger after-change-major-mode-hook inside mini buffer
  2022-08-21 12:22 Emacs 28 trigger after-change-major-mode-hook inside mini buffer Jakub T. Jankiewicz
@ 2022-08-21 12:29 ` Eli Zaretskii
  2022-08-21 14:20   ` Jakub T. Jankiewicz
  2022-08-21 14:22 ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2022-08-21 12:29 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 21 Aug 2022 14:22:50 +0200
> From: "Jakub T. Jankiewicz" <jcubic@onet.pl>
> 
> So to fix the problem I need to know: what type of major mode does the mini
> buffer now have in Emacs 28? So I can filter out that major mode.

It's minibuffer-mode, unsurprisingly.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs 28 trigger after-change-major-mode-hook inside mini buffer
  2022-08-21 12:29 ` Eli Zaretskii
@ 2022-08-21 14:20   ` Jakub T. Jankiewicz
  2022-08-21 14:37     ` Eli Zaretskii
  2022-08-21 14:49     ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 6+ messages in thread
From: Jakub T. Jankiewicz @ 2022-08-21 14:20 UTC (permalink / raw)
  To: help-gnu-emacs



On Sun, 21 Aug 2022 15:29:45 +0300
Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Sun, 21 Aug 2022 14:22:50 +0200
> > From: "Jakub T. Jankiewicz" <jcubic@onet.pl>
> > 
> > So to fix the problem I need to know: what type of major mode does the
> > mini buffer now have in Emacs 28? So I can filter out that major mode.  
> 
> It's minibuffer-mode, unsurprisingly.
> 

Thanks that works. Do you know any use cases when it's useful to have major
mode inside mini buffer?

--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs 28 trigger after-change-major-mode-hook inside mini buffer
  2022-08-21 12:22 Emacs 28 trigger after-change-major-mode-hook inside mini buffer Jakub T. Jankiewicz
  2022-08-21 12:29 ` Eli Zaretskii
@ 2022-08-21 14:22 ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-08-21 14:22 UTC (permalink / raw)
  To: help-gnu-emacs

> I don't remember why exactly I used this code, somehow the auto indent was
> not working for me.

Looks like your replacement is now in the same category :-)


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs 28 trigger after-change-major-mode-hook inside mini buffer
  2022-08-21 14:20   ` Jakub T. Jankiewicz
@ 2022-08-21 14:37     ` Eli Zaretskii
  2022-08-21 14:49     ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2022-08-21 14:37 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 21 Aug 2022 16:20:26 +0200
> From: "Jakub T. Jankiewicz" <jcubic@onet.pl>
> 
> > > So to fix the problem I need to know: what type of major mode does the
> > > mini buffer now have in Emacs 28? So I can filter out that major mode.  
> > 
> > It's minibuffer-mode, unsurprisingly.
> > 
> 
> Thanks that works. Do you know any use cases when it's useful to have major
> mode inside mini buffer?

To have a keymap?  To have font-lock definitions?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Emacs 28 trigger after-change-major-mode-hook inside mini buffer
  2022-08-21 14:20   ` Jakub T. Jankiewicz
  2022-08-21 14:37     ` Eli Zaretskii
@ 2022-08-21 14:49     ` Stefan Monnier via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-08-21 14:49 UTC (permalink / raw)
  To: help-gnu-emacs

Jakub T. Jankiewicz [2022-08-21 16:20:26] wrote:
> On Sun, 21 Aug 2022 15:29:45 +0300
> Eli Zaretskii <eliz@gnu.org> wrote:
>
>> > Date: Sun, 21 Aug 2022 14:22:50 +0200
>> > From: "Jakub T. Jankiewicz" <jcubic@onet.pl>
>> > 
>> > So to fix the problem I need to know: what type of major mode does the
>> > mini buffer now have in Emacs 28? So I can filter out that major mode.  
>> 
>> It's minibuffer-mode, unsurprisingly.

It can be something else, of course.  E.g. for `M-!` the major mode
should be a mix of `minibuffer-mode` and `shell-mode` for completion,
and for `M-:` you'd want a mix of `minibuffer-mode` and `elisp-mode`
(for completion and eldoc).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-21 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-21 12:22 Emacs 28 trigger after-change-major-mode-hook inside mini buffer Jakub T. Jankiewicz
2022-08-21 12:29 ` Eli Zaretskii
2022-08-21 14:20   ` Jakub T. Jankiewicz
2022-08-21 14:37     ` Eli Zaretskii
2022-08-21 14:49     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-08-21 14:22 ` Stefan Monnier via Users list for the GNU Emacs text editor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).