all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alexandre Adolphe <alexandre.adolphe@gmail.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 31551@debbugs.gnu.org
Subject: bug#31551: 27.0.50; emacs hangs in hexl-mode on modula2 files
Date: Tue, 05 Jun 2018 18:30:57 +0300	[thread overview]
Message-ID: <83r2ll9rny.fsf@gnu.org> (raw)
In-Reply-To: <CAK73JcA28eiOcWFQcCraEru1fwVOoC0Gth6BrO6TTT7nceHsQA@mail.gmail.com> (message from Alexandre Adolphe on Tue, 22 May 2018 15:24:09 +0200)

> From: Alexandre Adolphe <alexandre.adolphe@gmail.com>
> Date: Tue, 22 May 2018 15:24:09 +0200
> 
> I run into an issue lately while trying to use the hexl-mode with
> a modula2 file that I found and emacs starts to hang after the
> hexl-mode starts. I tested it on emacs 24.5, 25.2 and master.
> 
> To reproduce the issue you can use :
> echo "abcd" > test.MOD
> emacs -Q --eval '(show-paren-mode 1)' test.MOD
> M-x hexl-mode
> 
> --> emacs hangs and use 100% cpu. It only happen on the first character so
> we can run out the hang with multiple C-g + an arrow key.
> 
> I dig into the issue and it appears that the was because of the
> show-paren-mode and the fact that the ":" character have meaning in
> modula-2-mode. Emacs is stuck in the loop of the
> m2-smie-refine-colon function because after the "00000000" that start
> the hexl buffer there is no more sexp to parse so the tok variable is
> empty but the (forward-sexp -1) call does not fail.
> 
> I fixed that myself by stopping the loop if the point is at the beginning
> of the buffer. Not sure if it correct but here is the diff :

Hmm... I think there's a more serious issue at hand here.  Hexl mode
is not a normal major mode: it doesn't undo the effects of the
previous major mode.  So what happens here is that the display is
entirely inappropriate for Modula2 sources, but the syntactic setup
made by m2-mode is still in effect, and that setup attaches special
meaning to ':' when scanning for parentheses.

In addition, Hexl mode does nothing to prevent point from entering the
parts of the buffer that are "outside the Hexl region", such as the
address column (which ends in a colon ':').  Hexl mode only redefines
some interactive cursor movement commands to avoid entering the
non-Hexl portions, but try "C-u 1 M-x goto-char RET", and Emacs will
happily go to the "forbidden" area.  (Even some cursor motion commands
are not intercepted: e.g., try backward-word.)  So Lisp programs can
easily move point into portions of the buffer that have nothing to do
with the actual file contents.

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.

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.

Stefan, can you take a look and comment?





  reply	other threads:[~2018-06-05 15:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 13:24 bug#31551: 27.0.50; emacs hangs in hexl-mode on modula2 files Alexandre Adolphe
2018-06-05 15:30 ` Eli Zaretskii [this message]
2018-06-06 14:00   ` Stefan Monnier
2018-06-06 15:17     ` Eli Zaretskii
2018-06-06 19:27       ` Stefan Monnier
2018-06-07  2:32         ` Eli Zaretskii
2018-06-06 20:51       ` Stefan Monnier
2018-06-20 14:27         ` Stefan Monnier
2018-06-20 15:56           ` Eli Zaretskii
2018-06-22  3:31           ` Stefan Monnier

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=83r2ll9rny.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=31551@debbugs.gnu.org \
    --cc=alexandre.adolphe@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /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.