From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#31551: 27.0.50; emacs hangs in hexl-mode on modula2 files Date: Wed, 06 Jun 2018 10:00:04 -0400 Message-ID: References: <83r2ll9rny.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1528293560 24547 195.159.176.226 (6 Jun 2018 13:59:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 6 Jun 2018 13:59:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31551@debbugs.gnu.org, Alexandre Adolphe To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 06 15:59:16 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQYy2-0006Fg-UR for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jun 2018 15:59:16 +0200 Original-Received: from localhost ([::1]:52616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQZ09-0003nq-HP for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jun 2018 10:01:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQYzp-0003l4-EF for bug-gnu-emacs@gnu.org; Wed, 06 Jun 2018 10:01:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQYzm-00037B-CH for bug-gnu-emacs@gnu.org; Wed, 06 Jun 2018 10:01:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQYzm-00036t-8t for bug-gnu-emacs@gnu.org; Wed, 06 Jun 2018 10:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fQYzl-0004UL-Jb for bug-gnu-emacs@gnu.org; Wed, 06 Jun 2018 10:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Jun 2018 14:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31551 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31551-submit@debbugs.gnu.org id=B31551.152829360917182 (code B ref 31551); Wed, 06 Jun 2018 14:01:01 +0000 Original-Received: (at 31551) by debbugs.gnu.org; 6 Jun 2018 14:00:09 +0000 Original-Received: from localhost ([127.0.0.1]:36910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQYyv-0004T4-7Y for submit@debbugs.gnu.org; Wed, 06 Jun 2018 10:00:09 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:60533) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQYys-0004S5-Dr for 31551@debbugs.gnu.org; Wed, 06 Jun 2018 10:00:07 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w56E0UKS008440; Wed, 6 Jun 2018 10:00:30 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 58EF5660C7; Wed, 6 Jun 2018 10:00:04 -0400 (EDT) In-Reply-To: <83r2ll9rny.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 05 Jun 2018 18:30:57 +0300") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6302=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6302> : inlines <6683> : streams <1788907> : uri <2653654> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147089 Archived-At: >> 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. Clearly, this is a bug in m2-smie-refine-colon, indeed (not a big surprise: you're the first user of Modual-2 I encounter since I wrote that indentation code). > 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. Indeed, it fails to call kill-all-local-variables. It justifies it with: ;; We do not turn off the old major mode; instead we just ;; override most of it. That way, we can restore it perfectly. which I find unconvincing. > 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. Right, it failed to "unsetup" SMIE. > 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. > 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. 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). Stefan