From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: =?UTF-8?Q?=C3=85smund?= Grammeltvedt Original-Sender: "Debbugs-submit" Resent-CC: help-debbugs@gnu.org Resent-Date: Tue, 05 Jul 2016 20:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23901 X-GNU-PR-Package: debbugs.gnu.org X-GNU-PR-Keywords: To: 23901@debbugs.gnu.org X-Debbugs-Original-To: submit@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.146774900519886 (code B ref -1); Tue, 05 Jul 2016 20:04:02 +0000 Received: (at submit) by debbugs.gnu.org; 5 Jul 2016 20:03:25 +0000 Received: from localhost ([127.0.0.1]:38635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKWYy-0005AZ-IE for submit@debbugs.gnu.org; Tue, 05 Jul 2016 16:03:25 -0400 Received: from pnakotus.big-oil.org ([176.58.114.221]:55948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKW9o-0004Y8-Sr for submit@debbugs.gnu.org; Tue, 05 Jul 2016 15:37:21 -0400 Received: from localhost (localhost [127.0.0.1]) by pnakotus.big-oil.org (Postfix) with ESMTP id 31EB925EE5 for ; Tue, 5 Jul 2016 19:37:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at pnakotus.big-oil.org Received: from pnakotus.big-oil.org ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q6FgG6NLD2sK for ; Tue, 5 Jul 2016 19:37:18 +0000 (UTC) Received: from [IPv6:2001:16d8:ee16:0:35b9:bb3:8ff6:5ea] (unknown [IPv6:2001:16d8:ee16:0:35b9:bb3:8ff6:5ea]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asmundg) by pnakotus.big-oil.org (Postfix) with ESMTPSA id 48F3525ED9 for ; Tue, 5 Jul 2016 19:37:17 +0000 (UTC) From: =?UTF-8?Q?=C3=85smund?= Grammeltvedt Message-ID: <577C0C6B.4000706@big-oil.org> Date: Tue, 5 Jul 2016 21:37:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Tue, 05 Jul 2016 16:03:18 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hi! Running indent-region on the following code produces wrong indentation on all but the first statement in the last switch block. I have included two cases that work correctly for comparison: class Foo { public void Bar(String foo) { int a = 0; switch (a) { case 0: case 1: a += 1; a += 2; break; } switch (foo) { case "foo": a += 1; a += 2; break; } switch (foo) { case "foo": case "bar": a += 1; a += 2; break; } } } Emacs : GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) of 2016-04-15 Package: CC Mode 5.33 (Java/l) Buffer Style: java c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties 1-bit) current state: ============== (setq c-basic-offset 4 c-comment-only-line-offset '(0 . 0) c-indent-comment-alist '((anchored-comment column . 0) (end-block space . 1) (cpp-end-block space . 2)) c-indent-comments-syntactically-p nil c-block-comment-prefix "* " c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (other . "//+\\|\\**")) c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc)) c-cleanup-list '(scope-operator) c-hanging-braces-alist '((brace-list-open) (brace-entry-open) (statement-cont) (substatement-open after) (block-close . c-snug-do-while) (extern-lang-open after) (namespace-open after) (module-open after) (composition-open after) (inexpr-class-open after) (inexpr-class-close before) (arglist-cont-nonempty)) c-hanging-colons-alist nil c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist) c-backslash-column 48 c-backslash-max-column 72 c-special-indent-hook nil c-label-minimum-indentation 1 c-offsets-alist '((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . c-lineup-inexpr-block) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist) (arglist-cont c-lineup-gcc-asm-reg 0) (comment-intro c-lineup-knr-region-comment c-lineup-comment) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (case-label . 0) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-intro . +) (brace-list-close . 0) (brace-list-open . 0) (block-close . 0) (block-open . 0) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (func-decl-cont . c-lineup-java-throws) (inher-cont . c-lineup-java-inher) (access-label . 0) (arglist-close . c-lineup-arglist) (arglist-intro . c-lineup-arglist-intro-after-paren) (statement-cont . +) (statement-case-open . +) (label . +) (substatement-label . +) (substatement-open . +) (knr-argdecl-intro . 5) (statement-block-intro . +) (topmost-intro-cont . +) (inline-open . 0) ) c-buffer-is-cc-mode 'java-mode c-tab-always-indent t c-syntactic-indentation t c-syntactic-indentation-in-macros t c-ignore-auto-fill '(string cpp code) c-auto-align-backslashes t c-backspace-function 'backward-delete-char-untabify c-delete-function 'delete-char c-electric-pound-behavior nil c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu")) c-enable-xemacs-performance-kludge-p nil c-old-style-variable-behavior nil defun-prompt-regexp nil tab-width 4 comment-column 32 parse-sexp-ignore-comments t parse-sexp-lookup-properties t auto-fill-function nil comment-multi-line t comment-start-skip "\\(//+\\|/\\*+\\)\\s *" fill-prefix nil fill-column 70 paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*\\(@[a-zA-Z]+\\>\\|$\\)\\|^\f" adaptive-fill-mode t adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*\\([-–!|#%;>*·•‣⁃◦]+[ ]*\\)*\\)" ) -- Åsmund Grammeltvedt From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 05 16:08:38 2016 Received: (at control) by debbugs.gnu.org; 5 Jul 2016 20:08:38 +0000 Received: from localhost ([127.0.0.1]:38640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKWe6-0005IH-EN for submit@debbugs.gnu.org; Tue, 05 Jul 2016 16:08:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKWe5-0005I4-4q for control@debbugs.gnu.org; Tue, 05 Jul 2016 16:08:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKWdz-0003id-24 for control@debbugs.gnu.org; Tue, 05 Jul 2016 16:08:31 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKWdy-0003i6-Ur for control@debbugs.gnu.org; Tue, 05 Jul 2016 16:08:30 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1bKWdx-0000Da-De for control@debbugs.gnu.org; Tue, 05 Jul 2016 16:08:29 -0400 Subject: control message for bug 23901 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Tue, 05 Jul 2016 16:08:29 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) reassign 23901 cc-mode From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: #23901 CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings References: <577C0C6B.4000706@big-oil.org> In-Reply-To: <577C0C6B.4000706@big-oil.org> Resent-From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Wed, 06 Jul 2016 08:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: 23901@debbugs.gnu.org Cc: Alan Mackenzie , =?UTF-8?Q?=C3=85smund?= Grammeltvedt Reply-To: jostein@kjonigsen.net Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146779497730075 (code B ref 23901); Wed, 06 Jul 2016 08:50:01 +0000 Received: (at 23901) by debbugs.gnu.org; 6 Jul 2016 08:49:37 +0000 Received: from localhost ([127.0.0.1]:38855 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKiWX-0007p1-Ju for submit@debbugs.gnu.org; Wed, 06 Jul 2016 04:49:37 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:58330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKiWV-0007oq-DY for 23901@debbugs.gnu.org; Wed, 06 Jul 2016 04:49:35 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id AB1DD20479; Wed, 6 Jul 2016 04:49:34 -0400 (EDT) Received: from web5 ([10.202.2.215]) by compute2.internal (MEProxy); Wed, 06 Jul 2016 04:49:34 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:content-transfer-encoding :content-type:date:from:message-id:mime-version:reply-to:subject :to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=A/D22D5v/XVaQSoaQ1CkcrKl OXI=; b=kjaTxQ1+3oVYwPd20AndPgJ2K4WtTVeAIYGlSTMlBEgt1VupWE7/zj4Q CU17YZ1fRmoMF3K/2bchwO1xcF5QcQdlsktWSc0jM/rxeMg4CYnoDaLxrP4TD64u 2js1j4Ry/cObvG+V9PdtsAXgOrfLg4O/snBXvqrQvp1i5Z5caHE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:reply-to:subject:to :x-sasl-enc:x-sasl-enc; s=smtpout; bh=A/D22D5v/XVaQSoaQ1CkcrKlOX I=; b=tyDCUo01wzDotCNOLUXUu5/7FKM+XI93RGX+En83GKeZpm59b57K8plej1 48KeJ/C0iL91+5sMBBj387xn7Wq+F2Y2S6qdugT28kVuSIwa69zxsHuFbYP9Pm6Q fj5/yzTQy5w8uqSNO20dEaNOQ+MoFKvHWX+lPo7ZXaYwsDn9A= Received: by mailuser.nyi.internal (Postfix, from userid 99) id 77BE4A864C; Wed, 6 Jul 2016 04:49:34 -0400 (EDT) Message-Id: <1467794974.423635.658189489.19470CAF@webmail.messagingengine.com> X-Sasl-Enc: JoSzFAFZ3T7t9vORyHi/NQH0o7cyBOtDmPXw2caX4WAO 1467794974 From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: MessagingEngine.com Webmail Interface - ajax-22cd3445 Date: Wed, 06 Jul 2016 10:49:34 +0200 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Just thought I'd chip in and say that this bug has also been observed in other third-party cc-mode derivatives, like csharp-mode. As such it may affect quite a few c-like languages which has switch/case-statements. -- Jostein Kj=F8nigsen jostein@kjonigsen.net / jostein@secure.kjonigsen.net From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Wed, 06 Jul 2016 11:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: =?UTF-8?Q?=C3=85smund?= Grammeltvedt Cc: 23901@debbugs.gnu.org, Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146780613220285 (code B ref 23901); Wed, 06 Jul 2016 11:56:01 +0000 Received: (at 23901) by debbugs.gnu.org; 6 Jul 2016 11:55:32 +0000 Received: from localhost ([127.0.0.1]:38888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKlQS-0005H7-F0 for submit@debbugs.gnu.org; Wed, 06 Jul 2016 07:55:32 -0400 Received: from mail.muc.de ([193.149.48.3]:43538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKlQQ-0005Gy-DH for 23901@debbugs.gnu.org; Wed, 06 Jul 2016 07:55:30 -0400 Received: (qmail 85282 invoked by uid 3782); 6 Jul 2016 11:55:28 -0000 Received: from acm.muc.de (p4FC4640A.dip0.t-ipconnect.de [79.196.100.10]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 06 Jul 2016 13:55:26 +0200 Received: (qmail 2792 invoked by uid 1000); 6 Jul 2016 11:55:40 -0000 Date: Wed, 6 Jul 2016 11:55:40 +0000 Message-ID: <20160706115540.GA2471@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <577C0C6B.4000706@big-oil.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hello, smund. On Tue, Jul 05, 2016 at 09:37:15PM +0200, smund Grammeltvedt wrote: > Hi! > Running indent-region on the following code produces wrong indentation > on all but the first statement in the last switch block. OK. > I have included two cases that work correctly for comparison: Thank you for such a clear description of the fault, and thanks also for including a CC Mode configuration dump (from C-c C-b). > class Foo { > public void Bar(String foo) { > int a = 0; > switch (a) { > case 0: > case 1: > a += 1; > a += 2; > break; > } > switch (foo) { > case "foo": > a += 1; > a += 2; > break; > } > switch (foo) { > case "foo": > case "bar": > a += 1; > a += 2; > break; > } > } > } The problem appears to be in the CC Mode variable `c-nonlabel-token-key', which specifies things which can't be in a label. The Java value includes the character '"', presumably from a period in ancient history when strings in Java couldn't be case labels. Please try out the following fix, and please confirm that it has fixed the bug, or tell me what is still not right. The file cc-langs.el is in the directory ..../lisp/progmodes/. Note that after applying the patch, you need to recompile, at the very least, cc-langs.el, cc-fonts.el, cc-engine.el, cc-mode.el. (Or just recompile all of cc-*.el). diff -r 2fcfc6e054b3 cc-langs.el --- a/cc-langs.el Sun Jul 03 17:54:20 2016 +0000 +++ b/cc-langs.el Wed Jul 06 11:45:48 2016 +0000 @@ -3233,8 +3233,8 @@ (append (c-lang-const c-label-kwds) (c-lang-const c-protection-kwds)) :test 'string-equal))) - ;; Don't allow string literals, except in AWK. Character constants are OK. - (c objc java pike idl) (concat "\"\\|" + ;; Don't allow string literals, except in AWK and Java. Character constants are OK. + (c objc pike idl) (concat "\"\\|" (c-lang-const c-nonlabel-token-key)) ;; Also check for open parens in C++, to catch member init lists in ;; constructors. We normally allow it so that macros with arguments > Emacs : GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) > of 2016-04-15 > Package: CC Mode 5.33 (Java/l) > Buffer Style: java > c-emacs-features: (pps-extended-state col-0-paren posix-char-classes > gen-string-delim gen-comment-delim syntax-properties 1-bit) [ CC Mode state appreciated and snipped. ] > -- > smund Grammeltvedt -- Alan Mackenzie (Nuremberg, Germany). From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Wed, 06 Jul 2016 13:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie , =?UTF-8?Q?=C3=85smund?= Grammeltvedt Cc: 23901@debbugs.gnu.org Reply-To: jostein@kjonigsen.net Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146781340431645 (code B ref 23901); Wed, 06 Jul 2016 13:57:02 +0000 Received: (at 23901) by debbugs.gnu.org; 6 Jul 2016 13:56:44 +0000 Received: from localhost ([127.0.0.1]:39599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKnJk-0008EK-Gq for submit@debbugs.gnu.org; Wed, 06 Jul 2016 09:56:44 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:44659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKnJh-0008EC-KP for 23901@debbugs.gnu.org; Wed, 06 Jul 2016 09:56:43 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9D8E920394; Wed, 6 Jul 2016 09:56:39 -0400 (EDT) Received: from web5 ([10.202.2.215]) by compute5.internal (MEProxy); Wed, 06 Jul 2016 09:56:39 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:content-transfer-encoding :content-type:date:from:in-reply-to:message-id:mime-version :references:reply-to:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=TZt9Z1X2OU8juGJoJ0ScbZTH2tU=; b=Pp1PkYCuRdGFpR/foOZxh4Pst4Bn t1hoM9mmRzNCkSWwdfulAXRmWCil/g5nRxkf2Lo9+u78Qr1ZmLELfxgVIrLN40mP QUFXQG+UI9YWzUxMltLl3v6rhKDkBQLQUXiZy06uaAMyJRikWSwawyGEfHFZz1VO s+87WsB8Qp4hV7s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :reply-to:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=TZt9Z1 X2OU8juGJoJ0ScbZTH2tU=; b=NGT0U7PzT/PFSqNUPjLxz2Rt38KfbTNgy8DrD4 dkR8zQbN4UHI2mbPFGGTvlwSRSXDJCDstzCzYi0ii/ufd6QxDYzsz1Jaao/JU6Ah AB1z4p1jx8apslEdK1t7moJbLojT0vfyJyQ5W6wF8f/PRcHNhkBhorBo/h7QvG7i 5sZR0= Received: by mailuser.nyi.internal (Postfix, from userid 99) id 63D72A864C; Wed, 6 Jul 2016 09:56:39 -0400 (EDT) Message-Id: <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> X-Sasl-Enc: eqHI1v48bj0lPmh5ScdAU3Xkvpw88kYi0EfrLK35wJrH 1467813399 From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: MessagingEngine.com Webmail Interface - ajax-22cd3445 Date: Wed, 06 Jul 2016 15:56:39 +0200 In-Reply-To: <20160706115540.GA2471@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Wed, Jul 6, 2016, at 01:55 PM, Alan Mackenzie wrote: > Hello, =C5smund. >=20 > On Tue, Jul 05, 2016 at 09:37:15PM +0200, =C5smund Grammeltvedt wrote: >> Hi! >=20 >> Running indent-region on the following code produces wrong indentation >> on all but the first statement in the last switch block. >=20 > OK. >=20 >> I have included two cases that work correctly for comparison: >=20 > Thank you for such a clear description of the fault, and thanks also for > including a CC Mode configuration dump (from C-c C-b). >=20 >> class Foo { >> =A0 =A0 public void Bar(String foo) { >> =A0 =A0 =A0 =A0 int a =3D 0; >=20 >> =A0 =A0 =A0 =A0 switch (a) { >> =A0 =A0 =A0 =A0 case 0: >> =A0 =A0 =A0 =A0 case 1: >> =A0 =A0 =A0 =A0 =A0 =A0 a +=3D 1; >> =A0 =A0 =A0 =A0 =A0 =A0 a +=3D 2; >> =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 } >=20 >> =A0 =A0 =A0 =A0 switch (foo) { >> =A0 =A0 =A0 =A0 case "foo": >> =A0 =A0 =A0 =A0 =A0 =A0 a +=3D 1; >> =A0 =A0 =A0 =A0 =A0 =A0 a +=3D 2; >> =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 } >=20 >> =A0 =A0 =A0 =A0 switch (foo) { >> =A0 =A0 =A0 =A0 case "foo": >> =A0 =A0 =A0 =A0 case "bar": >> =A0 =A0 =A0 =A0 =A0 =A0 a +=3D 1; >> =A0 =A0 =A0 =A0 a +=3D 2; >> =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 } >> =A0 =A0 } >> } >=20 > The problem appears to be in the CC Mode variable > `c-nonlabel-token-key', which specifies things which can't be in a > label.=A0 The Java value includes the character '"', presumably from a > period in ancient history when strings in Java couldn't be case labels. >=20 > Please try out the following fix, and please confirm that it has fixed > the bug, or tell me what is still not right.=A0 The file cc-langs.el is in > the directory ..../lisp/progmodes/. >=20 > Note that after applying the patch, you need to recompile, at the very > least, cc-langs.el, cc-fonts.el, cc-engine.el, cc-mode.el.=A0 (Or just > recompile all of cc-*.el). >=20 >=20 > diff -r 2fcfc6e054b3 cc-langs.el > --- a/cc-langs.el =A0 =A0 =A0 Sun Jul 03 17:54:20 2016 +0000 > +++ b/cc-langs.el =A0 =A0 =A0 Wed Jul 06 11:45:48 2016 +0000 > @@ -3233,8 +3233,8 @@ > (append (c-lang-const c-label-kwds) > (c-lang-const c-protection-kwds)) > :test 'string-equal))) > -=A0 ;; Don't allow string literals, except in AWK.=A0 Character constants > are OK. > -=A0 (c objc java pike idl) (concat "\"\\|" > +=A0 ;; Don't allow string literals, except in AWK and Java.=A0 Character > constants are OK. > +=A0 (c objc pike idl) (concat "\"\\|" > (c-lang-const c-nonlabel-token-key)) > ;; Also check for open parens in C++, to catch member init lists in > ;; constructors.=A0 We normally allow it so that macros with arguments >=20 >=20 >> Emacs=A0 : GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) >> of 2016-04-15 >> Package: CC Mode 5.33 (Java/l) >> Buffer Style: java >> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes >> gen-string-delim gen-comment-delim syntax-properties 1-bit) >=20 > [ CC Mode state appreciated and snipped. ] >=20 >> -- >> =C5smund Grammeltvedt >=20 > -- > Alan Mackenzie (Nuremberg, Germany). Hey Alan. Thanks for the excellent response. Quick dislaimer: I'm the current csharp-mode maintainer, and this bug was originally issued for csharp-mode. As we discovered the same bug was found in java-mode which csharp-mode is based on, we suggested reporting the error upstream. I can confirm that this patch does indeed fix the indentation issue, also in csharp-mode, but unfortunately it seems to have some side-effects besides just indentation. csharp-mode has a small suite of automated test to verify behaviour, fontification, indentation, imenu-results, etc. After applying your patch and recompiling all cc-mode *.el-files, two of our tests which used to be OK are now failing. They're both related to fontification: one for #compiler directives and another for string-literal termination. To me, these kind of side-effects seems a bit unexpected. Would it be OK to ask you for some feedback? Basically all you need to reproduce is doing the following: > git clone https://github.com/josteink/csharp-mode > cd csharp-mode > make clean && make test I don't want to bother you too much with third-party code, but thought you may find it interesting none the less, since this may also affect other cc-mode derived modes. -- Jostein Kj=F8nigsen jostein@kjonigsen.net / jostein@secure.kjonigsen.net From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Wed, 06 Jul 2016 21:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: jostein@kjonigsen.net Cc: 23901@debbugs.gnu.org, =?UTF-8?Q?=C3=85smund?= Grammeltvedt Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146783892719089 (code B ref 23901); Wed, 06 Jul 2016 21:03:01 +0000 Received: (at 23901) by debbugs.gnu.org; 6 Jul 2016 21:02:07 +0000 Received: from localhost ([127.0.0.1]:39926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKtxO-0004xo-NY for submit@debbugs.gnu.org; Wed, 06 Jul 2016 17:02:07 -0400 Received: from mail.muc.de ([193.149.48.3]:19424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKtxL-0004xe-DO for 23901@debbugs.gnu.org; Wed, 06 Jul 2016 17:02:05 -0400 Received: (qmail 81504 invoked by uid 3782); 6 Jul 2016 21:02:01 -0000 Received: from acm.muc.de (p4FC4640A.dip0.t-ipconnect.de [79.196.100.10]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 06 Jul 2016 23:02:00 +0200 Received: (qmail 4258 invoked by uid 1000); 6 Jul 2016 21:02:15 -0000 Date: Wed, 6 Jul 2016 21:02:15 +0000 Message-ID: <20160706210215.GA4165@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hello, Jostein. On Wed, Jul 06, 2016 at 03:56:39PM +0200, Jostein Kjnigsen wrote: > On Wed, Jul 6, 2016, at 01:55 PM, Alan Mackenzie wrote: [ .... ] > > The problem appears to be in the CC Mode variable > > `c-nonlabel-token-key', which specifies things which can't be in a > > label. The Java value includes the character '"', presumably from a > > period in ancient history when strings in Java couldn't be case labels. > > Please try out the following fix, and please confirm that it has fixed > > the bug, or tell me what is still not right. The file cc-langs.el is in > > the directory ..../lisp/progmodes/. > > Note that after applying the patch, you need to recompile, at the very > > least, cc-langs.el, cc-fonts.el, cc-engine.el, cc-mode.el. (Or just > > recompile all of cc-*.el). > > diff -r 2fcfc6e054b3 cc-langs.el > > --- a/cc-langs.el Sun Jul 03 17:54:20 2016 +0000 > > +++ b/cc-langs.el Wed Jul 06 11:45:48 2016 +0000 > > @@ -3233,8 +3233,8 @@ > > (append (c-lang-const c-label-kwds) > > (c-lang-const c-protection-kwds)) > > :test 'string-equal))) > > - ;; Don't allow string literals, except in AWK. Character constants > > are OK. > > - (c objc java pike idl) (concat "\"\\|" > > + ;; Don't allow string literals, except in AWK and Java. Character > > constants are OK. > > + (c objc pike idl) (concat "\"\\|" > > (c-lang-const c-nonlabel-token-key)) > > ;; Also check for open parens in C++, to catch member init lists in > > ;; constructors. We normally allow it so that macros with arguments > >> Emacs : GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) > >> of 2016-04-15 > >> Package: CC Mode 5.33 (Java/l) > >> Buffer Style: java > >> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes > >> gen-string-delim gen-comment-delim syntax-properties 1-bit) > > [ CC Mode state appreciated and snipped. ] > >> -- > >> smund Grammeltvedt > > -- > > Alan Mackenzie (Nuremberg, Germany). > Hey Alan. > Thanks for the excellent response. > Quick dislaimer: I'm the current csharp-mode maintainer, and this bug > was originally issued for csharp-mode. As we discovered the same bug > was found in java-mode which csharp-mode is based on, we suggested > reporting the error upstream. > I can confirm that this patch does indeed fix the indentation issue, > also in csharp-mode, but unfortunately it seems to have some > side-effects besides just indentation. > csharp-mode has a small suite of automated test to verify behaviour, > fontification, indentation, imenu-results, etc. > After applying your patch and recompiling all cc-mode *.el-files, two > of our tests which used to be OK are now failing. They're both related > to fontification: one for #compiler directives and another for > string-literal termination. > To me, these kind of side-effects seems a bit unexpected. Would it be > OK to ask you for some feedback? Basically all you need to reproduce is > doing the following: Things are rarely that simple. :-( > > git clone https://github.com/josteink/csharp-mode > > cd csharp-mode > > make clean && make test On the make test, I get the following messages, the last ones being an error: "/usr/local/bin/emacs" -Q -batch -L . -l csharp-mode-tests.el -f ert-run-tests-batch-and-exit Contacting host: melpa.org:443 Opening TLS connection to `melpa.org'... Opening TLS connection with `gnutls-cli --insecure -p 443 melpa.org'... Opening TLS connection with `gnutls-cli --insecure -p 443 melpa.org'...done Opening TLS connection to `melpa.org'...done Saving file /home/acm/.emacs.d/elpa/archives/melpa/archive-contents... Wrote /home/acm/.emacs.d/elpa/archives/melpa/archive-contents Contacting host: elpa.gnu.org:80 Saving file /home/acm/.emacs.d/elpa/archives/gnu/archive-contents... Wrote /home/acm/.emacs.d/elpa/archives/gnu/archive-contents Package `emacs-24.4' is unavailable makefile:22: recipe for target 'test' failed make: *** [test] Error 255 References to a package `emacs-24.4' aren't conducive to a good night's sleep. ;-) > I don't want to bother you too much with third-party code, but thought > you may find it interesting none the less, since this may also affect > other cc-mode derived modes. Certainly, yes. But maybe it might be simpler if you could describe the two test cases that fail, and how to reproduce the failures starting from emacs -Q, loading csharp-mode. I've got a copy of the csharp-mode repository, including the testing files. > -- > Jostein Kjnigsen > jostein@kjonigsen.net / jostein@secure.kjonigsen.net -- Alan Mackenzie (Nuremberg, Germany). From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Thu, 07 Jul 2016 08:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 23901@debbugs.gnu.org, Vasilij Schneidermann , =?UTF-8?Q?=C3=85smund?= Grammeltvedt Reply-To: jostein@kjonigsen.net Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.14678797479531 (code B ref 23901); Thu, 07 Jul 2016 08:23:01 +0000 Received: (at 23901) by debbugs.gnu.org; 7 Jul 2016 08:22:27 +0000 Received: from localhost ([127.0.0.1]:40191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL4Zn-0002Tf-2U for submit@debbugs.gnu.org; Thu, 07 Jul 2016 04:22:27 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:42148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL4Zl-0002TW-A2 for 23901@debbugs.gnu.org; Thu, 07 Jul 2016 04:22:26 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CB33420392; Thu, 7 Jul 2016 04:22:24 -0400 (EDT) Received: from web5 ([10.202.2.215]) by compute2.internal (MEProxy); Thu, 07 Jul 2016 04:22:24 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:content-transfer-encoding :content-type:date:from:in-reply-to:message-id:mime-version :references:reply-to:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=zp4tpJki8/9ipC44n+5QzKKCmH8=; b=ZE9qV6q6gyRi2mZVjEprl3o7CTUh /zBOdHlKcx/JUBLk5ayuwh+TTvoE3H8qHMyv+9kTXiW2kS9Zm30+j26liw1eWb6m 4Qh1faaQVnnkg/G2rGdST33KR8EbVnHHQSbFs86resgVn2ujDa/ERuKrxTjmSesK 5o52NBmaJZFn0tE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :reply-to:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=zp4tpJ ki8/9ipC44n+5QzKKCmH8=; b=HTVsGT6Ezu/FstiB/Z31N0b/JQK8U2Od/OddBE +BinNp19BAmzLraqY3kzpV0Y584wlB3DtTE4+rQMo1EFAs3HrnYLcvp9/FVc/qp7 PhsC/A4NmW1bq1vx6OJWokRFDOJydCCc6fyExx+qrwqMyR1fPyKMhNxjXarxpmc5 X6evo= Received: by mailuser.nyi.internal (Postfix, from userid 99) id 963FDA8B1B; Thu, 7 Jul 2016 04:22:24 -0400 (EDT) Message-Id: <1467879744.1742795.659259353.5E98E1C1@webmail.messagingengine.com> X-Sasl-Enc: KJ3GyjU32Dg1vRAe0tH6wIwqhDM18r6kmz4jjV3KxDl4 1467879744 From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: MessagingEngine.com Webmail Interface - ajax-22cd3445 In-Reply-To: <20160706210215.GA4165@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> <20160706210215.GA4165@acm.fritz.box> Date: Thu, 07 Jul 2016 10:22:24 +0200 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Wed, Jul 6, 2016, at 11:02 PM, Alan Mackenzie wrote: > Certainly, yes. But maybe it might be simpler if you could describe the > two test cases that fail, and how to reproduce the failures starting from > emacs -Q, loading csharp-mode. I've got a copy of the csharp-mode > repository, including the testing files. >=20 >> -- >> Jostein Kj=F8nigsen >> jostein@kjonigsen.net / jostein@secure.kjonigsen.net >=20 > -- > Alan Mackenzie (Nuremberg, Germany). Thanks for your reply. I certainly agree about your suggestion. I think the absolutely simplest approach is to just observe the fontification of the test-document visually, with and without your patch applied. To see how the document -should- be fontified, run Emacs without any patches or modifications to cc-defs. Then open csharp-mode.el, and run 'M-x eval-buffer'. csharp-mode should now be fully loaded and initialised. After doing this, just try opening the test-document "test-files/fontification-test.cs". It should be fairly obvious from the file what correct fontification should be like. Now exit Emacs, apply your patch to cc-langs.el, and retry the procedure outlined above. You should now observe that fontification of the test-document no longer is applied correctly. I cannot really see how that patch, in cc-langs.el could affect this code so directly, but on the other hand it's hard to argue with what you see. Any ideas on what's going on here? While "fixing" csharp-mode is obviously not going to be your job, you may see things happening, and extrapolate how that may apply to other third-party cc-mode derivatives... And if your patch should be deemed safe or not. csharp-mode has a history for having weird hacks, but we're trying to get rid of them as much as possible. Hopefully this isn't one of those hacks causing (more) compatibility concerns than a maintainer should have to worry about... -- Jostein Kj=F8nigsen jostein@kjonigsen.net / jostein@secure.kjonigsen.net From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Thu, 07 Jul 2016 12:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: jostein@kjonigsen.net Cc: 23901@debbugs.gnu.org, Vasilij Schneidermann , =?UTF-8?Q?=C3=85smund?= Grammeltvedt Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146789478512072 (code B ref 23901); Thu, 07 Jul 2016 12:34:01 +0000 Received: (at 23901) by debbugs.gnu.org; 7 Jul 2016 12:33:05 +0000 Received: from localhost ([127.0.0.1]:40311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL8UL-00038e-0u for submit@debbugs.gnu.org; Thu, 07 Jul 2016 08:33:05 -0400 Received: from mail.muc.de ([193.149.48.3]:37189) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL8UJ-00038D-08 for 23901@debbugs.gnu.org; Thu, 07 Jul 2016 08:33:03 -0400 Received: (qmail 31880 invoked by uid 3782); 7 Jul 2016 12:33:00 -0000 Received: from acm.muc.de (p4FC468F2.dip0.t-ipconnect.de [79.196.104.242]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 07 Jul 2016 14:32:58 +0200 Received: (qmail 4332 invoked by uid 1000); 7 Jul 2016 12:33:11 -0000 Date: Thu, 7 Jul 2016 12:33:11 +0000 Message-ID: <20160707123310.GA4192@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> <20160706210215.GA4165@acm.fritz.box> <1467879744.1742795.659259353.5E98E1C1@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1467879744.1742795.659259353.5E98E1C1@webmail.messagingengine.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hello, Jostein. On Thu, Jul 07, 2016 at 10:22:24AM +0200, Jostein Kjnigsen wrote: > On Wed, Jul 6, 2016, at 11:02 PM, Alan Mackenzie wrote: > > Certainly, yes. But maybe it might be simpler if you could describe the > > two test cases that fail, and how to reproduce the failures starting from > > emacs -Q, loading csharp-mode. I've got a copy of the csharp-mode > > repository, including the testing files. > >> -- > >> Jostein Kjnigsen > >> jostein@kjonigsen.net / jostein@secure.kjonigsen.net > > -- > > Alan Mackenzie (Nuremberg, Germany). > Thanks for your reply. I certainly agree about your suggestion. > I think the absolutely simplest approach is to just observe the > fontification of the test-document visually, with and without your patch > applied. OK. Given that the file is small, this seems reasonable. > To see how the document -should- be fontified, run Emacs without any > patches or modifications to cc-defs. I see the same problems regardless of my latest proposed patch to cc-langs.el. > Then open csharp-mode.el, and run 'M-x eval-buffer'. csharp-mode should > now be fully loaded and initialised. > After doing this, just try opening the test-document > "test-files/fontification-test.cs". > It should be fairly obvious from the file what correct fontification > should be like. I see that the backslash at the end of the Literal2 string acts as an escape character, causing the following lines to get mis-fontifified. > Now exit Emacs, apply your patch to cc-langs.el, and retry the procedure > outlined above. You should now observe that fontification of the > test-document no longer is applied correctly. > I cannot really see how that patch, in cc-langs.el could affect this > code so directly, but on the other hand it's hard to argue with what you > see. > Any ideas on what's going on here? While "fixing" csharp-mode is > obviously not going to be your job, you may see things happening, and > extrapolate how that may apply to other third-party cc-mode > derivatives... And if your patch should be deemed safe or not. Yes, I have a good idea as to what's going wrong. The backslash is not getting marked with a syntax-table text property. The reason for this is, I think, that csharp-mode is trying to use `syntax-propertize-function' to do this. The problem is that nothing is triggering a call to this function. This is one of the reasons that the CC Mode core doesn't use the `syntax-propertize-function' mechanism - it is fairly random when and whether it gets run. Officially it describes itself as a "lazy" function, as if that were a positive aspect. I would recommend you to replace csharp-mode-syntax-propertize-function with a function to be called directly from after-change-functions, and to place this function in the csharp-mode value of `c-before-font-lock-functions'. It should be clear enough from `c-before-font-lock-functions''s doc string, and from the existing functions for other modes (including Java Mode) how this should work. A similar function to be called from before-change-functions could be placed on `c-get-state-before-change-functions', but I don't think you will need this. > csharp-mode has a history for having weird hacks, but we're trying to > get rid of them as much as possible. Hopefully this isn't one of those > hacks causing (more) compatibility concerns than a maintainer should > have to worry about... Let's hope not! > -- > Jostein Kjnigsen > jostein@kjonigsen.net / jostein@secure.kjonigsen.net -- Alan Mackenzie (Nuremberg, Germany). From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Thu, 07 Jul 2016 13:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie , jostein@kjonigsen.net Cc: 23901@debbugs.gnu.org, Vasilij Schneidermann , =?UTF-8?Q?=C3=85smund?= Grammeltvedt Reply-To: jostein@kjonigsen.net Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146789731815853 (code B ref 23901); Thu, 07 Jul 2016 13:16:01 +0000 Received: (at 23901) by debbugs.gnu.org; 7 Jul 2016 13:15:18 +0000 Received: from localhost ([127.0.0.1]:40318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL99C-00047d-E3 for submit@debbugs.gnu.org; Thu, 07 Jul 2016 09:15:18 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL997-00047R-Ib for 23901@debbugs.gnu.org; Thu, 07 Jul 2016 09:15:17 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 30CCD200E9; Thu, 7 Jul 2016 09:15:13 -0400 (EDT) Received: from web5 ([10.202.2.215]) by compute5.internal (MEProxy); Thu, 07 Jul 2016 09:15:13 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:content-transfer-encoding :content-type:date:from:in-reply-to:message-id:mime-version :references:reply-to:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=AdtyWD45VFDLtTPcvPmyASzIijk=; b=w3RG3Au71WG/NKt89kxDJE2M8AcL WZbbl7fGGqvKghqjF40ORHuOvYas52Llh7fFkPQ4inP0OVkVuR5zPCGMyDV/J/Yn fbyDMONsle8KUIeLoiWGO2L276WJZuS55KgljczlnqtHMFEFqsNQs8V/Ku4kY4NB L8pf9ZyaG3xCJdY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :reply-to:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=AdtyWD 45VFDLtTPcvPmyASzIijk=; b=iAtmz4AVbYK66OSg5xC2d6Zv0MkhPga4Du1kim jSQx6HWot9tpxBUArdv/WLIltx4OJVApmGetuXzbec2MLvDqlUCOiGxxt99Q4sdi vtEBVPS7V7InwOtnDAdm59UgzAla13iCEdVsoCfnrhDDs0cksyCbNduO3zpx8JMU yjTJI= Received: by mailuser.nyi.internal (Postfix, from userid 99) id D5469A8CB5; Thu, 7 Jul 2016 09:15:12 -0400 (EDT) Message-Id: <1467897312.1813495.659491913.0C7BF291@webmail.messagingengine.com> X-Sasl-Enc: QvP00TQZSvYvupo3IhUjjaaSQWxShNsbwlxP+JKS3q0M 1467897312 From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: MessagingEngine.com Webmail Interface - ajax-22cd3445 Date: Thu, 07 Jul 2016 15:15:12 +0200 In-Reply-To: <20160707123310.GA4192@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> <20160706210215.GA4165@acm.fritz.box> <1467879744.1742795.659259353.5E98E1C1@webmail.messagingengine.com> <20160707123310.GA4192@acm.fritz.box> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Thu, Jul 7, 2016, at 02:33 PM, Alan Mackenzie wrote: > Yes, I have a good idea as to what's going wrong. The backslash is not > getting marked with a syntax-table text property. The reason for this > is, I think, that csharp-mode is trying to use > `syntax-propertize-function' to do this. The problem is that nothing is > triggering a call to this function. This is one of the reasons that the > CC Mode core doesn't use the `syntax-propertize-function' mechanism - it > is fairly random when and whether it gets run. Officially it describes > itself as a "lazy" function, as if that were a positive aspect. >=20 > I would recommend you to replace csharp-mode-syntax-propertize-function > with a function to be called directly from after-change-functions, and > to place this function in the csharp-mode value of > `c-before-font-lock-functions'. It should be clear enough from > `c-before-font-lock-functions''s doc string, and from the existing > functions for other modes (including Java Mode) how this should work. A > similar function to be called from before-change-functions could be > placed on `c-get-state-before-change-functions', but I don't think you > will need this. >=20 > -- > Alan Mackenzie (Nuremberg, Germany). Thanks again for your help. It's very much appreciated. What you say explain a few inconsistencies we've observed in the past, and I agree with your recommendation about trying to find other functions/hooks to cover our needs. If this has not helped you asses whether your patch is "safe" or not, sorry for wasting your time. :) We'll see if we can work our way around this, and then hopefully when your patch lands, our code should be ready for whatever changes it brings too. -- Jostein Kj=F8nigsen jostein@kjonigsen.net / jostein@secure.kjonigsen.net From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Vasilij Schneidermann Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Thu, 07 Jul 2016 18:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146791714521798 (code B ref 23901); Thu, 07 Jul 2016 18:46:01 +0000 Received: (at 23901) by debbugs.gnu.org; 7 Jul 2016 18:45:45 +0000 Received: from localhost ([127.0.0.1]:41508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLEIz-0005fW-CA for submit@debbugs.gnu.org; Thu, 07 Jul 2016 14:45:45 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:33229) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLEIw-0005fI-Qt for 23901@debbugs.gnu.org; Thu, 07 Jul 2016 14:45:43 -0400 Received: by mail-wm0-f47.google.com with SMTP id r190so4386778wmr.0 for <23901@debbugs.gnu.org>; Thu, 07 Jul 2016 11:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=resent-from:resent-date:resent-message-id:resent-to:date:from:to :subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=8GXBTBBbHYNndPMF2YQUUh00GQWLrLCkuik++OtQuJA=; b=ObmOBDj7Q8eHJOhbQUhj/qzlIoJhKIcfKg7pkcZiESNfvsgHX+sM+fxwqJvXF2XNwr 40L2UWX8qliv6Pe77xYetdkYP9gYeggOBiLdI/c9h6DcxJnQY2m7DqE8alyrWwDYkecO zc6I79WlU49M+5pHP2YgqYXrUrF+5orUJnybJDMQMqncpows9FgYnrWwuMyLLEcrAiwM E+mefUgCF8jJqu5srDk5TuYOtjRJucLhOytjjo3apIaDMTPYwMrkRxzxEASIdFoehZeE 6zIC68j1Cb+BDY9t8uh8WsIuFTfI2NKTYIp2iyVtf8maf3M1sdNoy9bSIinhlp+huD+f ff7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8GXBTBBbHYNndPMF2YQUUh00GQWLrLCkuik++OtQuJA=; b=jAhFflo21iffDarAh+3k3wPavJJyy4gOQYzvhOXOsJwfTcANf0ykx1QDtFrMdApYG/ 3BHy7AuEnGYmDtF0PnPW5u7oWEuSedw7HrIYWvH30b4T6+1fbu9cVo0vSBFAJMlwLlY9 S1juyrB+DtEBPjE9samJAWRDD4AF4BL9fuJgntHaVYkM4zVmisTopn8HcQUZ62euD7s4 i2/tJzBHzh5CHD3QXT401ksxJ5UnYefApd67puD5diIPWI5c0w5ui+9DpeejR/S8bzBs GQLcYJt93sVi6ndMWcsQ+NBDljPMizPX6qdPXuR/2zSy1GIM5UhoFGO8VcMoeDLZGtL9 78mQ== X-Gm-Message-State: ALyK8tLLFKSTrFZ49nlA+oUExazKzgR6rRZ+jzvFV0XP7Paf7UYRM0gr72+B1xkO4grxLg== X-Received: by 10.194.242.39 with SMTP id wn7mr1660195wjc.10.1467917136694; Thu, 07 Jul 2016 11:45:36 -0700 (PDT) Received: from localhost (2001-4dd0-2019-913-21f-16ff-fe2e-5218.ipv6dyn.netcologne.de. [2001:4dd0:2019:913:21f:16ff:fe2e:5218]) by smtp.gmail.com with ESMTPSA id mn2sm3647270wjc.35.2016.07.07.11.45.36 for <23901@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jul 2016 11:45:36 -0700 (PDT) Resent-From: Vasilij Schneidermann Resent-Date: Thu, 7 Jul 2016 20:45:35 +0200 Resent-Message-ID: <20160707184535.GB655@odonien.labor.koeln.ccc.de> Resent-To: 23901@debbugs.gnu.org Received: from localhost ([31.213.160.156]) by smtp.gmail.com with ESMTPSA id q71sm2607698wme.17.2016.07.07.06.13.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jul 2016 06:13:55 -0700 (PDT) Date: Thu, 7 Jul 2016 15:13:53 +0200 From: Vasilij Schneidermann Message-ID: <20160707131353.GA779@odonien.bevuta.com> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> <20160706210215.GA4165@acm.fritz.box> <1467879744.1742795.659259353.5E98E1C1@webmail.messagingengine.com> <20160707123310.GA4192@acm.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160707123310.GA4192@acm.fritz.box> User-Agent: Mutt/1.5.24 (2015-08-30) X-TUID: 9f8SCmeoh7zH X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hello, > Yes, I have a good idea as to what's going wrong. The backslash is not > getting marked with a syntax-table text property. The reason for this > is, I think, that csharp-mode is trying to use > `syntax-propertize-function' to do this. The problem is that nothing is > triggering a call to this function. This is one of the reasons that the > CC Mode core doesn't use the `syntax-propertize-function' mechanism - it > is fairly random when and whether it gets run. Officially it describes > itself as a "lazy" function, as if that were a positive aspect. I doubt this is related as I've changed csharp-mode.el to include the standard definition for c-nonlabel-token-key minus the string delimiter parts and that made the broken tests work again. Judging from my previous experiences with `syntax-propertize-function', unexpected interactions can arise from other places, including the use of `font-lock-syntactic-keywords'. FWIW, I wouldn't rule out an old csharp-mode.elc that's still around or an incorrectly compiled cc-mode. I also doubt that `syntax-propertize-function' is unreliable. If you trace from its definition backwards through the sources of fontification-related files, you'll notice that it is triggered on initial fontification of a region and after buffer modifications. Yes, laziness is a positive aspect. I'd expect it to be self-evident that avoiding any more work than needed for refontification is important for performant display and editing of code. Why would that not apply for modes derived from cc-mode? > I would recommend you to replace csharp-mode-syntax-propertize-function > with a function to be called directly from after-change-functions, and > to place this function in the csharp-mode value of > `c-before-font-lock-functions'. It should be clear enough from > `c-before-font-lock-functions''s doc string, and from the existing > functions for other modes (including Java Mode) how this should work. A > similar function to be called from before-change-functions could be > placed on `c-get-state-before-change-functions', but I don't think you > will need this. This sounds wrong as font-lock is already doing this in a less ad-hoc way. Reusing its API for that solves problems such as having a specified region to refontify after changes (otherwise one would need to guess a suitable one with `after-change-functions' or worse, use the entire buffer). Why exactly would I want to avoid it? Cheers Vasilij From unknown Fri Aug 08 15:19:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-cc-mode@gnu.org Resent-Date: Thu, 07 Jul 2016 18:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23901 X-GNU-PR-Package: cc-mode X-GNU-PR-Keywords: To: Vasilij Schneidermann Received: via spool by 23901-submit@debbugs.gnu.org id=B23901.146791722421962 (code B ref 23901); Thu, 07 Jul 2016 18:48:02 +0000 Received: (at 23901) by debbugs.gnu.org; 7 Jul 2016 18:47:04 +0000 Received: from localhost ([127.0.0.1]:41512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLEKF-0005iA-ND for submit@debbugs.gnu.org; Thu, 07 Jul 2016 14:47:03 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:36306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLEKD-0005hf-U8 for 23901@debbugs.gnu.org; Thu, 07 Jul 2016 14:47:02 -0400 Received: by mail-wm0-f54.google.com with SMTP id f126so221290487wma.1 for <23901@debbugs.gnu.org>; Thu, 07 Jul 2016 11:47:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:resent-from:resent-date:resent-message-id :resent-to:delivered-to:date:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent:from; bh=zjiTn8eVJlksD/diKzc57r204YOwrTj5K9v06EBSbds=; b=KU2S7yMWkdi9CVR1oAuKIcbrLwcAz8Lzhf9CtJkRt1XF69R2VDrDsgbQCvRaSsOB0s tx9TJO2RJSelUype/m6/0DVxlTldY+odqFgyQlnEOfEYmp3UWj3Pk6jQEJyUWAGHLDDe tnSPADOLtCTpNwhiGbJyXVq0vLxD6kCVbnr7WucENMgn7gDh0BAqKdef5p5yy5256EdR Ly7wrjY4Vj8NY7Ogt5pJ4B2EVuQQd+yQ39v4c0VWcB/S/bPTtL6qO0rn52ydsV3EmhFH STCdjbhGut7p/z7W6sxFu0Co3UcD9Rnlflyr9PLprk+qAsv4tkDxbZlchHO8OA/QDsh1 sA2A== X-Gm-Message-State: ALyK8tKXQFb7/Yop1h7VFm2boo9tTyD9aomZhInQUR7sTgr1GD55P2BJrcvRqE4Bv+M8/Q== X-Received: by 10.28.132.149 with SMTP id g143mr29041161wmd.100.1467917215962; Thu, 07 Jul 2016 11:46:55 -0700 (PDT) Received: from localhost (2001-4dd0-2019-913-21f-16ff-fe2e-5218.ipv6dyn.netcologne.de. [2001:4dd0:2019:913:21f:16ff:fe2e:5218]) by smtp.gmail.com with ESMTPSA id p126sm1237158wmp.13.2016.07.07.11.46.55 for <23901@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jul 2016 11:46:55 -0700 (PDT) Resent-From: Vasilij Schneidermann Resent-Date: Thu, 7 Jul 2016 20:46:54 +0200 Resent-Message-ID: <20160707184654.GC655@odonien.labor.koeln.ccc.de> Resent-To: 23901@debbugs.gnu.org Delivered-To: v.schneidermann@gmail.com Received: by 10.157.46.183 with SMTP id w52csp1513638ota; Thu, 7 Jul 2016 11:33:04 -0700 (PDT) X-Received: by 10.194.105.97 with SMTP id gl1mr1412192wjb.131.1467916384836; Thu, 07 Jul 2016 11:33:04 -0700 (PDT) Received: from mail.muc.de (mail.muc.de. [193.149.48.3]) by mx.google.com with ESMTPS id i67si2083186wmg.24.2016.07.07.11.33.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Jul 2016 11:33:02 -0700 (PDT) Received-SPF: pass (google.com: domain of acm@muc.de designates 193.149.48.3 as permitted sender) client-ip=193.149.48.3; Received: (qmail 92438 invoked by uid 3782); 7 Jul 2016 18:33:02 -0000 Received: from acm.muc.de (p4FC468F2.dip0.t-ipconnect.de [79.196.104.242]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 07 Jul 2016 20:33:01 +0200 Received: (qmail 7393 invoked by uid 1000); 7 Jul 2016 18:33:16 -0000 Date: Thu, 7 Jul 2016 18:33:16 +0000 Message-ID: <20160707183316.GD4192@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> <1467813399.486432.658425753.37DC2ACD@webmail.messagingengine.com> <20160706210215.GA4165@acm.fritz.box> <1467879744.1742795.659259353.5E98E1C1@webmail.messagingengine.com> <20160707123310.GA4192@acm.fritz.box> <20160707131353.GA779@odonien.bevuta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160707131353.GA779@odonien.bevuta.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-TUID: PsLjZ2KxO29R X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hello, Vasilij. On Thu, Jul 07, 2016 at 03:13:53PM +0200, Vasilij Schneidermann wrote: > Hello, > > Yes, I have a good idea as to what's going wrong. The backslash is not > > getting marked with a syntax-table text property. The reason for this > > is, I think, that csharp-mode is trying to use > > `syntax-propertize-function' to do this. The problem is that nothing is > > triggering a call to this function. This is one of the reasons that the > > CC Mode core doesn't use the `syntax-propertize-function' mechanism - it > > is fairly random when and whether it gets run. Officially it describes > > itself as a "lazy" function, as if that were a positive aspect. > I doubt this is related as I've changed csharp-mode.el to include the > standard definition for c-nonlabel-token-key minus the string delimiter > parts and that made the broken tests work again. Judging from my > previous experiences with `syntax-propertize-function', unexpected > interactions can arise from other places, including the use of > `font-lock-syntactic-keywords'. These unexpected interactions are another reason CC Mode doesn't use `syntax-propertize-function'. > FWIW, I wouldn't rule out an old csharp-mode.elc that's still around > or an incorrectly compiled cc-mode. Well, I used an interpreted csharp-mode.el, and I think I know quite a bit about correctly compiling CC Mode. ;-) > I also doubt that `syntax-propertize-function' is unreliable. Of itself, it is indeed reliable. But something has to call it, and that part is not reliable. It's arbitrary and random. > If you trace from its definition backwards through the sources of > fontification-related files, you'll notice that it is triggered on > initial fontification of a region and after buffer modifications. Only when fontification is enabled. Even then, after M-x csharp-mode, a critical character in the .../test-files/fontification-test.cs (from the csharp-mode repository) didn't have a syntax-table property on it. After he first buffer change, it acquired that property. Don't forget, font-locking doesn't own syntax-table properties. These properties are needed for other reasons too. > Yes, laziness is a positive aspect. I'd expect it to be self-evident > that avoiding any more work than needed for refontification is important > for performant display and editing of code. Why would that not apply > for modes derived from cc-mode? Because the work has to be done at some stage. The `syntax-propertize-function' mechanism, at a buffer change, wastefully erases all syntax-table properties from that point in the buffer onwards, meaning they have to be recalculated. In CC Mode, these properties are kept up to date directly in before/after-change-functions, and positions distant from point do not have their properties smashed, minimising the work done. > > I would recommend you to replace csharp-mode-syntax-propertize-function > > with a function to be called directly from after-change-functions, and > > to place this function in the csharp-mode value of > > `c-before-font-lock-functions'. It should be clear enough from > > `c-before-font-lock-functions''s doc string, and from the existing > > functions for other modes (including Java Mode) how this should work. A > > similar function to be called from before-change-functions could be > > placed on `c-get-state-before-change-functions', but I don't think you > > will need this. > This sounds wrong as font-lock is already doing this in a less ad-hoc > way. Font-lock can only do this when it is enabled. It is a goal of CC Mode also to work when font-lock is disabled. Font lock can only set these properties during redisplay, which is too late for some uses of them. (For example, when you type in a ">", that instantly matches an opening "<", the determination being done before redisplay.) CC Mode's mechanism here is not "ad-hoc". It is direct and logical. > Reusing its API for that solves problems such as having a specified > region to refontify after changes (otherwise one would need to guess a > suitable one with `after-change-functions' or worse, use the entire > buffer). Font lock on its own cannot determine the region to fontify. It needs input from the major mode in the general case. Font lock has the requisite interfaces for this, and anyhow this point has nothing to do with the use/non-use of `syntax-propertize-function'. > Why exactly would I want to avoid it? Because of the reasons identified by both of us in these posts: The unwanted interactions `syntax-propertize-function' has with other parts of Emacs; the requirement to work when Font lock is disabled; the fact it is not working properly at the moment in csharp-mode.el; the extra run-time the laziness and unneeded erasure of text properties causes. > Cheers > Vasilij -- Alan Mackenzie (Nuremberg, Germany). From unknown Fri Aug 08 15:19:00 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?=C3=85smund?= Grammeltvedt Subject: bug#23901: closed (Re: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings) Message-ID: References: <20160723105507.GA2295@acm.fritz.box> <577C0C6B.4000706@big-oil.org> X-Gnu-PR-Message: they-closed 23901 X-Gnu-PR-Package: cc-mode Reply-To: 23901@debbugs.gnu.org Date: Sat, 23 Jul 2016 10:56:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1469271361-15432-1" This is a multi-part message in MIME format... ------------=_1469271361-15432-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case= with strings which was filed against the cc-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 23901@debbugs.gnu.org. --=20 23901: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D23901 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1469271361-15432-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 23901-done) by debbugs.gnu.org; 23 Jul 2016 10:55:55 +0000 Received: from localhost ([127.0.0.1]:34216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQub5-00040c-5l for submit@debbugs.gnu.org; Sat, 23 Jul 2016 06:55:55 -0400 Received: from mail.muc.de ([193.149.48.3]:39428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQub3-00040T-9U for 23901-done@debbugs.gnu.org; Sat, 23 Jul 2016 06:55:53 -0400 Received: (qmail 55066 invoked by uid 3782); 23 Jul 2016 10:55:52 -0000 Received: from acm.muc.de (p4FC46332.dip0.t-ipconnect.de [79.196.99.50]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 23 Jul 2016 12:55:50 +0200 Received: (qmail 11206 invoked by uid 1000); 23 Jul 2016 10:55:07 -0000 Date: Sat, 23 Jul 2016 10:55:07 +0000 To: 23901-done@debbugs.gnu.org Subject: Re: bug#23901: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings Message-ID: <20160723105507.GA2295@acm.fritz.box> References: <577C0C6B.4000706@big-oil.org> <20160706115540.GA2471@acm.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160706115540.GA2471@acm.fritz.box> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 23901-done Cc: Jostein =?iso-8859-1?Q?Kj=F8nigsen?= , =?iso-8859-1?Q?=C5smund?= Grammeltvedt X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Bug fixed in master. -- Alan Mackenzie (Nuremberg, Germany). ------------=_1469271361-15432-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 5 Jul 2016 20:03:25 +0000 Received: from localhost ([127.0.0.1]:38635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKWYy-0005AZ-IE for submit@debbugs.gnu.org; Tue, 05 Jul 2016 16:03:25 -0400 Received: from pnakotus.big-oil.org ([176.58.114.221]:55948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKW9o-0004Y8-Sr for submit@debbugs.gnu.org; Tue, 05 Jul 2016 15:37:21 -0400 Received: from localhost (localhost [127.0.0.1]) by pnakotus.big-oil.org (Postfix) with ESMTP id 31EB925EE5 for ; Tue, 5 Jul 2016 19:37:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at pnakotus.big-oil.org Received: from pnakotus.big-oil.org ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q6FgG6NLD2sK for ; Tue, 5 Jul 2016 19:37:18 +0000 (UTC) Received: from [IPv6:2001:16d8:ee16:0:35b9:bb3:8ff6:5ea] (unknown [IPv6:2001:16d8:ee16:0:35b9:bb3:8ff6:5ea]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asmundg) by pnakotus.big-oil.org (Postfix) with ESMTPSA id 48F3525ED9 for ; Tue, 5 Jul 2016 19:37:17 +0000 (UTC) To: submit@debbugs.gnu.org Subject: CC Mode 5.33 (Java/l); Wrong indentation of fallthrough switch/case with strings From: =?UTF-8?Q?=c3=85smund_Grammeltvedt?= Message-ID: <577C0C6B.4000706@big-oil.org> Date: Tue, 5 Jul 2016 21:37:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 05 Jul 2016 16:03:18 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hi! Running indent-region on the following code produces wrong indentation on all but the first statement in the last switch block. I have included two cases that work correctly for comparison: class Foo { public void Bar(String foo) { int a = 0; switch (a) { case 0: case 1: a += 1; a += 2; break; } switch (foo) { case "foo": a += 1; a += 2; break; } switch (foo) { case "foo": case "bar": a += 1; a += 2; break; } } } Emacs : GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) of 2016-04-15 Package: CC Mode 5.33 (Java/l) Buffer Style: java c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties 1-bit) current state: ============== (setq c-basic-offset 4 c-comment-only-line-offset '(0 . 0) c-indent-comment-alist '((anchored-comment column . 0) (end-block space . 1) (cpp-end-block space . 2)) c-indent-comments-syntactically-p nil c-block-comment-prefix "* " c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (other . "//+\\|\\**")) c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc)) c-cleanup-list '(scope-operator) c-hanging-braces-alist '((brace-list-open) (brace-entry-open) (statement-cont) (substatement-open after) (block-close . c-snug-do-while) (extern-lang-open after) (namespace-open after) (module-open after) (composition-open after) (inexpr-class-open after) (inexpr-class-close before) (arglist-cont-nonempty)) c-hanging-colons-alist nil c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist) c-backslash-column 48 c-backslash-max-column 72 c-special-indent-hook nil c-label-minimum-indentation 1 c-offsets-alist '((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . c-lineup-inexpr-block) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call +) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist) (arglist-cont c-lineup-gcc-asm-reg 0) (comment-intro c-lineup-knr-region-comment c-lineup-comment) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (case-label . 0) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-intro . +) (brace-list-close . 0) (brace-list-open . 0) (block-close . 0) (block-open . 0) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (func-decl-cont . c-lineup-java-throws) (inher-cont . c-lineup-java-inher) (access-label . 0) (arglist-close . c-lineup-arglist) (arglist-intro . c-lineup-arglist-intro-after-paren) (statement-cont . +) (statement-case-open . +) (label . +) (substatement-label . +) (substatement-open . +) (knr-argdecl-intro . 5) (statement-block-intro . +) (topmost-intro-cont . +) (inline-open . 0) ) c-buffer-is-cc-mode 'java-mode c-tab-always-indent t c-syntactic-indentation t c-syntactic-indentation-in-macros t c-ignore-auto-fill '(string cpp code) c-auto-align-backslashes t c-backspace-function 'backward-delete-char-untabify c-delete-function 'delete-char c-electric-pound-behavior nil c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu")) c-enable-xemacs-performance-kludge-p nil c-old-style-variable-behavior nil defun-prompt-regexp nil tab-width 4 comment-column 32 parse-sexp-ignore-comments t parse-sexp-lookup-properties t auto-fill-function nil comment-multi-line t comment-start-skip "\\(//+\\|/\\*+\\)\\s *" fill-prefix nil fill-column 70 paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*\\(@[a-zA-Z]+\\>\\|$\\)\\|^\f" adaptive-fill-mode t adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*\\([-–!|#%;>*·•‣⁃◦]+[ ]*\\)*\\)" ) -- Åsmund Grammeltvedt ------------=_1469271361-15432-1--