Subject: bug#31551: 27.0.50; emacs hangs in hexl-mode on modula2 files

From: Eli Zaretskii <[email-masked]>
Date: Wed, 06 Jun 2018 18:17:14 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: Alexandre Adolphe <[email-masked]>, [email-masked]
> Date: Wed, 06 Jun 2018 10:00:04 -0400
> 
> > On top of that, show-paren-mode will happily turn itself on in a
> > buffer under Hexl mode, although it makes no sense to me: the Hexl
> > display shows no parens to work with.
> 
> At the same time, it's only enabled if the user explicitly requests it
> (as is the case in the OP's recipe), so I think we can consider this
> a pilot error.

I thought so too, until I turned on show-paren-mode _before_ switching
to Hexl, and saw it still turned on when in Hexl.

> > The fact that syntactical customizations of a mode stay in effect when
> > the display changes so radically sounds like a potential cause of many
> > trouble.  So perhaps the right solution would be to temporarily
> > disable mode syntax while in Hexl mode.
> 
> Agreed.  Hexl-mode should use a "normal" major mode (e.g. calling
> kill-all-local-variables).  In order to properly reset the previous
> major mode, it could either save&restore all previous local-vars, or
> just save the previous major-mode and call that major-mode
> function to restore the state.

Well, this is a much larger job than I hoped will be necessary.  The
problem with "switching off SMIE" is that there doesn't seem to be a
way of doing that: I see no function to "undo" smie-setup, at least
not a documented way (maybe some clever call to smie-setup will undo
the previous one, but I couldn't see how).

> BTW, this "save previous major mode and then restore it" is something
> done in other places (at least doc-view-mode comes to mind, but
> I believe there are others as well) and we should try and avoid
> duplicating that code (i.e. develop a "standard" way to do it).

In the long run, certainly.