From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#37137: Setting font-lock-case-fold-search to t causes hangs on certain types in c-mode Date: 25 Aug 2019 10:22:26 -0000 Organization: muc.de e.V. Message-ID: <20190825102226.52674.qmail__8184.66323414526$1566731831$gmane$org@mail.muc.de> References: Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="222448"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p9 (amd64)) Cc: 37137@debbugs.gnu.org To: Zachary Napier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 25 13:17:06 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i1qW8-000viL-Kl for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Aug 2019 13:17:04 +0200 Original-Received: from localhost ([::1]:41840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1qW7-000150-7P for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Aug 2019 07:17:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55428) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1qVN-00014s-DD for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 07:16:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1qVI-0005jP-Fr for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 07:16:14 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1qV8-0005h5-Fl; Sun, 25 Aug 2019 07:16:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1qV8-0001nX-90; Sun, 25 Aug 2019 07:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 25 Aug 2019 11:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37137 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 37137-submit@debbugs.gnu.org id=B37137.15667317186855 (code B ref 37137); Sun, 25 Aug 2019 11:16:02 +0000 Original-Received: (at 37137) by debbugs.gnu.org; 25 Aug 2019 11:15:18 +0000 Original-Received: from localhost ([127.0.0.1]:43670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1qUQ-0001mV-77 for submit@debbugs.gnu.org; Sun, 25 Aug 2019 07:15:18 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:64862 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1i1qUN-0001mL-7V for 37137@debbugs.gnu.org; Sun, 25 Aug 2019 07:15:16 -0400 Original-Received: (qmail 52675 invoked by uid 3782); 25 Aug 2019 10:22:26 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug 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: 209.51.188.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:165823 Archived-At: Hello, Zachary. In article you wrote: > [-- text/plain, encoding 7bit, charset: UTF-8, 31 lines --] > I have in my .emacs file only these two lines: > (custom-set-variables > '(font-lock-keywords-case-fold-search t)) May I ask why you're making this setting? I think font-lock-keywords-case-fold-search is really intended to be set by major modes, rather than as a user customisation. > Then if I visit an empty or nonexistent C file and just type "LONG" > (in all caps or with at least one letter being capital), Emacs will > hang after typing the final G but before the G appears on > screen. Typing C-g a couple of times gets Emacs unstuck until I > continue to type. The same behavior also happens if I type "SHORT". Yes. The keywords in all the CC Mode languages are case sensitive. Almost exactly the same bug came up in 2013, when the solution was to bind case-fold-search to nil at every "entry point" to CC Mode. I missed font-lock-keywords-case-fold-search at the time. > This happens in both Emacs 26.1 in text mode on a Linux machine and in > Emacs 25.3 in GUI mode on Windows. > After messing with GDB a bit, I am pretty sure the hang is at the > while loop in c-forward-type at cc-engine.el:7657 and its getting > stuck because looking-at matches LONG because its case insensitive, > but the c-forward-keyword-clause doesn't move forward because the > first thing it does is try to find "LONG" in c-keywords-obarray via > `intern-soft` and immediately returns because it doesn't find it > there. Here is the while loop: > (while (progn > (setq safe-pos (point)) > (looking-at c-opt-type-component-key)) > (when (and c-record-type-identifiers > (looking-at c-primitive-type-key)) > (c-record-type-id (cons (match-beginning 1) > (match-end 1)))) > (c-forward-keyword-clause 1)) That's an excellent piece of debugging. :-) I think the best fix for the bug would be for CC Mode to set font-lock-keywords-case-fold-search explicitly to nil (buffer locally) at C Mode (etc.) initialisation. This would undo the effect of your custom-set-variables form in C Mode buffers. Would this be a problem? -- Alan Mackenzie (Nuremberg, Germany).