From unknown Sun Jun 15 08:33:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#66911 <66911@debbugs.gnu.org> To: bug#66911 <66911@debbugs.gnu.org> Subject: Status: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Reply-To: bug#66911 <66911@debbugs.gnu.org> Date: Sun, 15 Jun 2025 15:33:31 +0000 retitle 66911 CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to= class-open reassign 66911 cc-mode submitter 66911 Arsen Arsenovi=C4=87 severity 66911 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 03 06:23:53 2023 Received: (at submit) by debbugs.gnu.org; 3 Nov 2023 10:23:53 +0000 Received: from localhost ([127.0.0.1]:56892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyrLB-0002t0-Mg for submit@debbugs.gnu.org; Fri, 03 Nov 2023 06:23:53 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyrL6-0002sa-Lp for submit@debbugs.gnu.org; Fri, 03 Nov 2023 06:23:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyrKQ-0004lb-Ns for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 06:23:02 -0400 Received: from mout-p-102.mailbox.org ([2001:67c:2050:0:465::102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1qyrKL-0003fG-UH for bug-gnu-emacs@gnu.org; Fri, 03 Nov 2023 06:23:02 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4SMGyq6NFHz9sZT for ; Fri, 3 Nov 2023 11:22:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1699006963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vChdkCGpwq7zhAuKX9UuUPw1szTs6UMioL7L6BpNhEE=; b=iaLCntXFlPMHGUUFpu6dDNS5iveul6w6WCBSizMrWzzupGVgtRDUWTtdVinSYMYeKrSSDy /gUmSk3CJlSz6HQ1y0B6mq3EX3Q4wsdohvxZw+eWHEX64QBnysEUCjjDSshJXGiTMB/9Ut d8L8Fu36Tx51mJ5UYQRUTE6S9WaTUrhrrVG7xu3XdVmTVQLvBzB0AfwQyZC+G2vvsNt4Q+ rrTosD0+oJhL/Y8aOGabLjzvoa8AbJcTB3WU8sNA7BCz66jfJV3sNPmNkcWXVZPVno0S+z nibGmi0XJxTcqx1oB98SCcrToh63ueV5ZnkYyVajQbC+SUQpHaOhHAdS8aSXpg== From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: bug-gnu-emacs@gnu.org Subject: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Date: Fri, 03 Nov 2023 10:51:32 +0100 X-Debbugs-Package: cc-mode Message-ID: <87zfzv16io.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2001:67c:2050:0:465::102; envelope-from=arsen@aarsen.me; helo=mout-p-102.mailbox.org X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit 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.3 (/) Package: cc-mode <#secure method=3Dpgpmime mode=3Dsign> Package: cc-mode In the example below: namespace a { _BEGIN template<> struct foo { /* HERE */ }; } // Local Variables: // c-noise-macro-names: ("_BEGIN") // End: Pressing C-c C-s on the stat of the line marked HERE shows ((class-open 15)), which is the '_' of the '_BEGIN'. This appears to be wrong, as the anchor should be the 'class' keyword on the line above, I believe. Anchoring '{' on the class/struct/union that precedes it would also enable implementing the GNU libstdc++ code style (as, AFAICT, it is currently impossible to indent a class with a basic-offset added to the column the 'template' keyword sits on). Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24= .38, cairo version 1.17.8) of 2023-09-24 Package: CC Mode 5.35.2 (C++//l) Buffer Style: gnu c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-st= ring-delim gen-comment-delim syntax-properties category-properties 1-bit) current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq c-basic-offset 2 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++-mode . gtkdoc)) c-cleanup-list '(scope-operator) c-hanging-braces-alist '((substatement-open before after) (arglist-cont-no= nempty)) 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 '(t c-gnu-impose-minimum) c-label-minimum-indentation 1 c-offsets-alist '((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . 0) (template-args-cont c-lineup-template-args c-lineup-template-args-indented-from-margin ) (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) (access-label . -) (case-label . 0) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-close . 0) (block-close . 0) (block-open . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (constraint-cont . +) (topmost-intro . 0) (knr-argdecl . 0) (func-decl-cont . +) (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) (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont ) (brace-list-intro first c-lineup-2nd-brace-entry-in-arglist c-lineup-class-decl-init-+ + ) (brace-list-open . +) (inline-open . 0) (arglist-close . c-lineup-arglist) (arglist-intro . c-lineup-arglist-intro-after-paren) (statement-cont . +) (statement-case-open . +) (label . 0) (substatement-label . 0) (substatement-open . +) (knr-argdecl-intro . 5) (statement-block-intro . +) ) c-buffer-is-cc-mode 'c++-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 8 comment-column 32 parse-sexp-ignore-comments t parse-sexp-lookup-properties t auto-fill-function 'c-do-auto-fill comment-multi-line t comment-start-skip "\\(?://+\\|/\\*+\\)\\s *" fill-prefix nil fill-column 79 paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*$\\|^\f" adaptive-fill-mode t adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*\\([-=E2=80=93!|#%= ;>*=C2=B7=E2=80=A2=E2=80=A3=E2=81=83=E2=97=A6]+[ ]*\\)*\\)" ) --=20 Arsen Arsenovi=C4=87 From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 06 05:47:52 2023 Received: (at 66911) by debbugs.gnu.org; 6 Nov 2023 10:47:52 +0000 Received: from localhost ([127.0.0.1]:38679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzx96-0003e0-0n for submit@debbugs.gnu.org; Mon, 06 Nov 2023 05:47:52 -0500 Received: from mail.muc.de ([193.149.48.3]:35730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzx93-0003dm-8U for 66911@debbugs.gnu.org; Mon, 06 Nov 2023 05:47:50 -0500 Received: (qmail 55815 invoked by uid 3782); 6 Nov 2023 11:47:04 +0100 Received: from acm.muc.de (pd953a5e1.dip0.t-ipconnect.de [217.83.165.225]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 06 Nov 2023 11:47:04 +0100 Received: (qmail 6887 invoked by uid 1000); 6 Nov 2023 10:47:03 -0000 Date: Mon, 6 Nov 2023 10:47:03 +0000 To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Message-ID: References: <87zfzv16io.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87zfzv16io.fsf@aarsen.me> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66911 Cc: acm@muc.de, 66911@debbugs.gnu.org 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.0 (-) Hello, Arsen. Thanks for taking the trouble to report this bug, and thanks even more for such a high quality bug report! On Fri, Nov 03, 2023 at 10:51:32 +0100, Arsen Arsenović via CC-Mode-help wrote: > Package: cc-mode > <#secure method=pgpmime mode=sign> > Package: cc-mode > In the example below: > namespace a { > _BEGIN > template<> > struct foo > { /* HERE */ > }; > } > // Local Variables: > // c-noise-macro-names: ("_BEGIN") > // End: > Pressing C-c C-s on the stat of the line marked HERE shows ((class-open > 15)), which is the '_' of the '_BEGIN'. This appears to be wrong, as > the anchor should be the 'class' keyword on the line above, I believe. > Anchoring '{' on the class/struct/union that precedes it would also > enable implementing the GNU libstdc++ code style (as, AFAICT, it is > currently impossible to indent a class with a basic-offset added to the > column the 'template' keyword sits on). Yes, in function c-looking-at-decl-block, the handling of template constructs and noise macros was somewhat careless. This should be fixed by the patch below. Even so, it's worth noting that noise macros with parentheses (set with the buffer local variable c-noise-macro-with-parens-names) are currently not handled correctly, here. This was a decision taken some years ago, to avoid slowing down CC Mode for a construct which is rarer than the noise macros without parens. I'm thinking of taking another look at this. Would you please apply the patch, byte compile cc-engine.el (or all of CC Mode), load it into your Emacs and try it out on your real C++ code. The patch should apply cleanly to the Emacs master branch. Then please confirm that it is actually fixes the bug, or tell me what's still not working properly. (If you want any help applying the patch or compiling the file, feel free to send me private email.) > Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) > of 2023-09-24 > Package: CC Mode 5.35.2 (C++//l) > Buffer Style: gnu > c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit) [ .... ] diff -r 2760aada61fa cc-engine.el --- a/cc-engine.el Sun Oct 15 10:44:22 2023 +0000 +++ b/cc-engine.el Mon Nov 06 10:26:34 2023 +0000 @@ -12633,31 +12633,27 @@ (let ((open-brace (point)) kwd-start first-specifier-pos) (c-syntactic-skip-backward c-block-prefix-charset limit t) - (when (and c-recognize-<>-arglists - (eq (char-before) ?>)) - ;; Could be at the end of a template arglist. - (let ((c-parse-and-markup-<>-arglists t)) - (while (and - (c-backward-<>-arglist nil limit) - (progn - (c-syntactic-skip-backward c-block-prefix-charset limit t) - (eq (char-before) ?>)))))) - - ;; Skip back over noise clauses. - (while (and - c-opt-cpp-prefix - (eq (char-before) ?\)) - (let ((after-paren (point))) - (if (and (c-go-list-backward) - (progn (c-backward-syntactic-ws) - (c-simple-skip-symbol-backward)) - (or (looking-at c-paren-nontype-key) - (looking-at c-noise-macro-with-parens-name-re))) - (progn - (c-syntactic-skip-backward c-block-prefix-charset limit t) - t) - (goto-char after-paren) - nil)))) + (while + (or + ;; Could be after a template arglist.... + (and c-recognize-<>-arglists + (eq (char-before) ?>) + (let ((c-parse-and-markup-<>-arglists t)) + (c-backward-<>-arglist nil limit))) + ;; .... or after a noise clause with parens. + (and c-opt-cpp-prefix + (let ((after-paren (point))) + (if (eq (char-before) ?\)) + (and + (c-go-list-backward) + (eq (char-after) ?\() + (progn (c-backward-syntactic-ws) + (c-simple-skip-symbol-backward)) + (or (looking-at c-paren-nontype-key) ; e.g. __attribute__ + (looking-at c-noise-macro-with-parens-name-re))) + (goto-char after-paren) + nil)))) + (c-syntactic-skip-backward c-block-prefix-charset limit t)) ;; Note: Can't get bogus hits inside template arglists below since they ;; have gotten paren syntax above. @@ -12667,10 +12663,18 @@ ;; The `c-decl-block-key' search continues from there since ;; we know it can't match earlier. (if goto-start - (when (c-syntactic-re-search-forward c-symbol-start - open-brace t t) - (goto-char (setq first-specifier-pos (match-beginning 0))) - t) + (progn + (while + (and + (c-syntactic-re-search-forward c-symbol-start + open-brace t t) + (goto-char (match-beginning 0)) + (if (or (looking-at c-noise-macro-name-re) + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause) + (setq first-specifier-pos (match-beginning 0)) + nil))) + first-specifier-pos) t) (cond @@ -12739,34 +12743,39 @@ (goto-char first-specifier-pos) (while (< (point) kwd-start) - (if (looking-at c-symbol-key) - ;; Accept any plain symbol token on the ground that - ;; it's a specifier masked through a macro (just - ;; like `c-forward-decl-or-cast-1' skip forward over - ;; such tokens). - ;; - ;; Could be more restrictive wrt invalid keywords, - ;; but that'd only occur in invalid code so there's - ;; no use spending effort on it. - (let ((end (match-end 0)) - (kwd-sym (c-keyword-sym (match-string 0)))) - (unless - (and kwd-sym - ;; Moving over a protection kwd and the following - ;; ":" (in C++ Mode) to the next token could take - ;; us all the way up to `kwd-start', leaving us - ;; no chance to update `first-specifier-pos'. - (not (c-keyword-member kwd-sym 'c-protection-kwds)) - (c-forward-keyword-clause 0)) - (goto-char end) - (c-forward-syntactic-ws))) - + (cond + ((or (looking-at c-noise-macro-name-re) + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause)) + ((looking-at c-symbol-key) + ;; Accept any plain symbol token on the ground that + ;; it's a specifier masked through a macro (just + ;; like `c-forward-decl-or-cast-1' skips forward over + ;; such tokens). + ;; + ;; Could be more restrictive wrt invalid keywords, + ;; but that'd only occur in invalid code so there's + ;; no use spending effort on it. + (let ((end (match-end 0)) + (kwd-sym (c-keyword-sym (match-string 0)))) + (unless + (and kwd-sym + ;; Moving over a protection kwd and the following + ;; ":" (in C++ Mode) to the next token could take + ;; us all the way up to `kwd-start', leaving us + ;; no chance to update `first-specifier-pos'. + (not (c-keyword-member kwd-sym 'c-protection-kwds)) + (c-forward-keyword-clause 0)) + (goto-char end) + (c-forward-syntactic-ws)))) + + ((c-syntactic-re-search-forward c-symbol-start + kwd-start 'move t) ;; Can't parse a declaration preamble and is still ;; before `kwd-start'. That means `first-specifier-pos' ;; was in some earlier construct. Search again. - (if (c-syntactic-re-search-forward c-symbol-start - kwd-start 'move t) - (goto-char (setq first-specifier-pos (match-beginning 0))) + (goto-char (setq first-specifier-pos (match-beginning 0)))) + (t ;; Got no preamble before the block declaration keyword. (setq first-specifier-pos kwd-start)))) > -- > Arsen Arsenović -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 06 07:00:16 2023 Received: (at 66911) by debbugs.gnu.org; 6 Nov 2023 12:00:16 +0000 Received: from localhost ([127.0.0.1]:38820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzyH9-0005om-PE for submit@debbugs.gnu.org; Mon, 06 Nov 2023 07:00:16 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]:41324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzyH7-0005oZ-HR for 66911@debbugs.gnu.org; Mon, 06 Nov 2023 07:00:14 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4SP8z43dbfz9spZ; Mon, 6 Nov 2023 12:59:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1699271968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TqQuN+6uxNs4g4HrvqBOMrjb0xtVI29e9a15pysErwc=; b=bnKFlDFO7cSrCdqXCqJqRP65+iaTjg7+Sajh0J9oLMq0v9vsm/A8iWwJq1FEF227y0+0hD lVDgaXTcGtxg0nslFrdiVlEm73DbhfjJGA+HYakN/9toXICDUscZXPig8oEN6Q2IS/+QCb ravljbGBHLGv7e8L0IILMC8oRAtm/1Dc9r6N2H6VZjRs0e1m1sfHzmL6KKAkwuHjoNjqOB qKYiI7cJ0tW3r//E2vbToJtWjhXUV4TnXUwlaGuq+nEU2uc8GN3O5EPtu6BWUH4YqtJ34q MlnlLTbPGNZDMRJFfEvVyQ+f16GfAMmcN7MecF5G6q7x/c6wu/U0cqmnlOE0gg== References: <87zfzv16io.fsf@aarsen.me> From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Alan Mackenzie Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Date: Mon, 06 Nov 2023 12:38:36 +0100 In-reply-to: Message-ID: <867cmv2iua.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 66911 Cc: 66911@debbugs.gnu.org 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.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Alan, Alan Mackenzie writes: > Hello, Arsen. > > Thanks for taking the trouble to report this bug, and thanks even more > for such a high quality bug report! > > On Fri, Nov 03, 2023 at 10:51:32 +0100, Arsen Arsenovi=C4=87 via CC-Mode-= help wrote: >> Package: cc-mode > >> <#secure method=3Dpgpmime mode=3Dsign> >> Package: cc-mode > >> In the example below: > >> namespace a { >> _BEGIN > >> template<> >> struct foo >> { /* HERE */ >> }; >> } > >> // Local Variables: >> // c-noise-macro-names: ("_BEGIN") >> // End: > >> Pressing C-c C-s on the stat of the line marked HERE shows ((class-open >> 15)), which is the '_' of the '_BEGIN'. This appears to be wrong, as >> the anchor should be the 'class' keyword on the line above, I believe. > >> Anchoring '{' on the class/struct/union that precedes it would also >> enable implementing the GNU libstdc++ code style (as, AFAICT, it is >> currently impossible to indent a class with a basic-offset added to the >> column the 'template' keyword sits on). > > Yes, in function c-looking-at-decl-block, the handling of template > constructs and noise macros was somewhat careless. This should be fixed > by the patch below. > > Even so, it's worth noting that noise macros with parentheses (set with > the buffer local variable c-noise-macro-with-parens-names) are currently > not handled correctly, here. This was a decision taken some years ago, > to avoid slowing down CC Mode for a construct which is rarer than the > noise macros without parens. I'm thinking of taking another look at > this. > > Would you please apply the patch, byte compile cc-engine.el (or all of > CC Mode), load it into your Emacs and try it out on your real C++ code. > The patch should apply cleanly to the Emacs master branch. Then please > confirm that it is actually fixes the bug, or tell me what's still not > working properly. (If you want any help applying the patch or compiling > the file, feel free to send me private email.) That indeed appears to have fixed it. I built emacs 30.0.50 from git (94807b6896191245ff3bef44a0ec21efb918232f) and applied your patch, then compared the analysis and indentation before and after on libstdc++es , and it worked as expected (the noise macro stopped confusing it). Though, the anchor still anchors on the template<> line rather than the struct line in: template struct _Base_bitset { ... making it impossible (AFAICT) to create a style that implements: template struct _Base_bitset { }; struct foo { }; instead, the former gets formatted as: template struct _Base_bitset { }; Is this intended? >> Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3= .24.38, cairo version 1.17.8) >> of 2023-09-24 >> Package: CC Mode 5.35.2 (C++//l) >> Buffer Style: gnu >> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes >> gen-string-delim gen-comment-delim syntax-properties category-properties >> 1-bit) > > [ .... ] > > diff -r 2760aada61fa cc-engine.el > --- a/cc-engine.el Sun Oct 15 10:44:22 2023 +0000 > +++ b/cc-engine.el Mon Nov 06 10:26:34 2023 +0000 > @@ -12633,31 +12633,27 @@ > (let ((open-brace (point)) kwd-start first-specifier-pos) > (c-syntactic-skip-backward c-block-prefix-charset limit t) >=20=20 > - (when (and c-recognize-<>-arglists > - (eq (char-before) ?>)) > - ;; Could be at the end of a template arglist. > - (let ((c-parse-and-markup-<>-arglists t)) > - (while (and > - (c-backward-<>-arglist nil limit) > - (progn > - (c-syntactic-skip-backward c-block-prefix-charset limit t) > - (eq (char-before) ?>)))))) > - > - ;; Skip back over noise clauses. > - (while (and > - c-opt-cpp-prefix > - (eq (char-before) ?\)) > - (let ((after-paren (point))) > - (if (and (c-go-list-backward) > - (progn (c-backward-syntactic-ws) > - (c-simple-skip-symbol-backward)) > - (or (looking-at c-paren-nontype-key) > - (looking-at c-noise-macro-with-parens-name-re))) > - (progn > - (c-syntactic-skip-backward c-block-prefix-charset limit t) > - t) > - (goto-char after-paren) > - nil)))) > + (while > + (or=20 > + ;; Could be after a template arglist.... > + (and c-recognize-<>-arglists > + (eq (char-before) ?>) > + (let ((c-parse-and-markup-<>-arglists t)) > + (c-backward-<>-arglist nil limit))) > + ;; .... or after a noise clause with parens. > + (and c-opt-cpp-prefix > + (let ((after-paren (point))) > + (if (eq (char-before) ?\)) > + (and > + (c-go-list-backward) > + (eq (char-after) ?\() > + (progn (c-backward-syntactic-ws) > + (c-simple-skip-symbol-backward)) > + (or (looking-at c-paren-nontype-key) ; e.g. __attribute__ > + (looking-at c-noise-macro-with-parens-name-re))) > + (goto-char after-paren) > + nil)))) > + (c-syntactic-skip-backward c-block-prefix-charset limit t)) >=20=20 > ;; Note: Can't get bogus hits inside template arglists below since t= hey > ;; have gotten paren syntax above. > @@ -12667,10 +12663,18 @@ > ;; The `c-decl-block-key' search continues from there since > ;; we know it can't match earlier. > (if goto-start > - (when (c-syntactic-re-search-forward c-symbol-start > - open-brace t t) > - (goto-char (setq first-specifier-pos (match-beginning 0))) > - t) > + (progn > + (while > + (and > + (c-syntactic-re-search-forward c-symbol-start > + open-brace t t) > + (goto-char (match-beginning 0)) > + (if (or (looking-at c-noise-macro-name-re) > + (looking-at c-noise-macro-with-parens-name-re)) > + (c-forward-noise-clause) > + (setq first-specifier-pos (match-beginning 0)) > + nil))) > + first-specifier-pos) > t) >=20=20 > (cond > @@ -12739,34 +12743,39 @@ > (goto-char first-specifier-pos) >=20=20 > (while (< (point) kwd-start) > - (if (looking-at c-symbol-key) > - ;; Accept any plain symbol token on the ground that > - ;; it's a specifier masked through a macro (just > - ;; like `c-forward-decl-or-cast-1' skip forward over > - ;; such tokens). > - ;; > - ;; Could be more restrictive wrt invalid keywords, > - ;; but that'd only occur in invalid code so there's > - ;; no use spending effort on it. > - (let ((end (match-end 0)) > - (kwd-sym (c-keyword-sym (match-string 0)))) > - (unless > - (and kwd-sym > - ;; Moving over a protection kwd and the following > - ;; ":" (in C++ Mode) to the next token could take > - ;; us all the way up to `kwd-start', leaving us > - ;; no chance to update `first-specifier-pos'. > - (not (c-keyword-member kwd-sym 'c-protection-kwds)) > - (c-forward-keyword-clause 0)) > - (goto-char end) > - (c-forward-syntactic-ws))) > - > + (cond > + ((or (looking-at c-noise-macro-name-re) > + (looking-at c-noise-macro-with-parens-name-re)) > + (c-forward-noise-clause)) > + ((looking-at c-symbol-key) > + ;; Accept any plain symbol token on the ground that > + ;; it's a specifier masked through a macro (just > + ;; like `c-forward-decl-or-cast-1' skips forward over > + ;; such tokens). > + ;; > + ;; Could be more restrictive wrt invalid keywords, > + ;; but that'd only occur in invalid code so there's > + ;; no use spending effort on it. > + (let ((end (match-end 0)) > + (kwd-sym (c-keyword-sym (match-string 0)))) > + (unless > + (and kwd-sym > + ;; Moving over a protection kwd and the following > + ;; ":" (in C++ Mode) to the next token could take > + ;; us all the way up to `kwd-start', leaving us > + ;; no chance to update `first-specifier-pos'. > + (not (c-keyword-member kwd-sym 'c-protection-kwds)) > + (c-forward-keyword-clause 0)) > + (goto-char end) > + (c-forward-syntactic-ws)))) > + > + ((c-syntactic-re-search-forward c-symbol-start > + kwd-start 'move t) > ;; Can't parse a declaration preamble and is still > ;; before `kwd-start'. That means `first-specifier-pos' > ;; was in some earlier construct. Search again. > - (if (c-syntactic-re-search-forward c-symbol-start > - kwd-start 'move t) > - (goto-char (setq first-specifier-pos (match-beginning 0))) > + (goto-char (setq first-specifier-pos (match-beginning 0)))) > + (t > ;; Got no preamble before the block declaration keyword. > (setq first-specifier-pos kwd-start)))) >=20=20 > >> --=20 >> Arsen Arsenovi=C4=87 =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZUjVHV8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTFYIBAPX3dUxuFPSN8dcVgSYn+CR68Fx7utfMjHhP TGH5tqbjAP9ujXKfIIvO0Dls27eWty+lE95iucL67XrlKM61ns4gBA== =oB88 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 06 08:48:27 2023 Received: (at 66911) by debbugs.gnu.org; 6 Nov 2023 13:48:27 +0000 Received: from localhost ([127.0.0.1]:38905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzzxq-0002eQ-K2 for submit@debbugs.gnu.org; Mon, 06 Nov 2023 08:48:27 -0500 Received: from mail.muc.de ([193.149.48.3]:40960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzzxn-0002dT-Ri for 66911@debbugs.gnu.org; Mon, 06 Nov 2023 08:48:24 -0500 Received: (qmail 59578 invoked by uid 3782); 6 Nov 2023 14:47:39 +0100 Received: from acm.muc.de (pd953a5e1.dip0.t-ipconnect.de [217.83.165.225]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 06 Nov 2023 14:47:39 +0100 Received: (qmail 9058 invoked by uid 1000); 6 Nov 2023 13:47:39 -0000 Date: Mon, 6 Nov 2023 13:47:39 +0000 To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Message-ID: References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <867cmv2iua.fsf@aarsen.me> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66911 Cc: acm@muc.de, 66911@debbugs.gnu.org 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.0 (-) Hello, Arsen. On Mon, Nov 06, 2023 at 12:38:36 +0100, Arsen Arsenović wrote: > Hi Alan, > Alan Mackenzie writes: > > On Fri, Nov 03, 2023 at 10:51:32 +0100, Arsen Arsenović via CC-Mode-help wrote: > >> Package: cc-mode [ .... ] > > Would you please apply the patch, byte compile cc-engine.el (or all of > > CC Mode), load it into your Emacs and try it out on your real C++ code. > > The patch should apply cleanly to the Emacs master branch. Then please > > confirm that it is actually fixes the bug, or tell me what's still not > > working properly. (If you want any help applying the patch or compiling > > the file, feel free to send me private email.) > That indeed appears to have fixed it. I built emacs 30.0.50 from git > (94807b6896191245ff3bef44a0ec21efb918232f) and applied your patch, then > compared the analysis and indentation before and after on libstdc++es > , and it worked as expected (the noise macro stopped confusing > it). Thanks! Time to commit the patch, then. > Though, the anchor still anchors on the template<> line rather than the > struct line in: > template > struct _Base_bitset > { > ... making it impossible (AFAICT) to create a style that implements: > template > struct _Base_bitset > { > }; > struct foo > { > }; > instead, the former gets formatted as: > template > struct _Base_bitset > { > }; > Is this intended? Apologies. I missed this second point in your original bug report. This should be fixable, but will be more work to fix than the other point. I think something like the following would do it: we could add a second anchor point to topmost-intro-cont forms, that second point pointing at struct. In languages without templates/generics, or in constructs lacking template components, both anchor points would be the same. So you could write an alignment function which would use that second anchor point for class-open lines and the like. Or, just possibly, we might be able to make that second point the default for class-open. This should keep backward compatibility. I'll have to think about this. And of course, the manual and test programs will need amending, too. ;-) > >> Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) > >> of 2023-09-24 > >> Package: CC Mode 5.35.2 (C++//l) > >> Buffer Style: gnu > >> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes > >> gen-string-delim gen-comment-delim syntax-properties category-properties > >> 1-bit) [ .... ] > -- > Arsen Arsenović -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 06 10:13:06 2023 Received: (at 66911) by debbugs.gnu.org; 6 Nov 2023 15:13:06 +0000 Received: from localhost ([127.0.0.1]:40382 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r01Hm-0007jo-7n for submit@debbugs.gnu.org; Mon, 06 Nov 2023 10:13:06 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]:49206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r01Hk-0007jJ-29 for 66911@debbugs.gnu.org; Mon, 06 Nov 2023 10:13:05 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4SPFFZ3ZLpz9sRT; Mon, 6 Nov 2023 16:12:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1699283538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cn8RY8fqRmeiJHSwW2LlBbFbxioXJXki/ADfR/ho2BU=; b=yGelSZKZy7VBl9PCB7XLDaDuVrfdyfz7XrR6RO8/2Luq+hiHRaDOoXiqJ0vZEJsWmuzhXn iASkJje/lge+DUGPjkJ+pHqhsZymiTsUpU36TIGCaebhbPTXJ/SaXo3g8RwQ0m6UICxNA/ l2msiGVbzshgpR1Iz2EMipS+JXI6/pCBea7VajwDzEVfj5KAXYzZZZ6n1Cfq+xRXpHBayK AdsUipSuxvQDvGPAoG62Hk4DM1VeGp9Sfg5Ny+7FlCz9LxHi9XsdcHWjCRhgCvZYoJ749Q fsJ2tnH9Z6EVEoLaiMOw7AqC+FBD2oravz9StDc9uIOmsY/yQA9rpMZ5YGCTfg== References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Alan Mackenzie Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Date: Mon, 06 Nov 2023 16:07:05 +0100 In-reply-to: Message-ID: <86y1faykz3.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 66911 Cc: 66911@debbugs.gnu.org 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.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alan Mackenzie writes: >> Though, the anchor still anchors on the template<> line rather than the >> struct line in: > >> template >> struct _Base_bitset >> { > >> ... making it impossible (AFAICT) to create a style that implements: > >> template >> struct _Base_bitset >> { >> }; > >> struct foo >> { >> }; > >> instead, the former gets formatted as: > >> template >> struct _Base_bitset >> { >> }; > >> Is this intended? > > Apologies. I missed this second point in your original bug report. Admittedly, I had considered making it two bug reports because the issues seemed separate to me, but I wasn't sure if one caused the other or vice-versa. So, I don't blame you :-) > This should be fixable, but will be more work to fix than the other > point. > > I think something like the following would do it: we could add a second > anchor point to topmost-intro-cont forms, that second point pointing at > struct. In languages without templates/generics, or in constructs > lacking template components, both anchor points would be the same. > > So you could write an alignment function which would use that second > anchor point for class-open lines and the like. Or, just possibly, we > might be able to make that second point the default for class-open. This > should keep backward compatibility. I'll have to think about this. > > And of course, the manual and test programs will need amending, too. ;-) That sounds lovely - thanks in advance, if you do, indeed, decide to do it. For now, I can get this patch implemented with some manual indenting. Thanks for the quick fix, have a lovely day :-) =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZUkCUF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTRzgBALjG0I7uLk/NUZMxSLSKH1zWZtPCS+MxOyvR IWZbFly+AQDDVTWnb/gLR2EHOf8fwfwL4WT6gZi84Lh7pKKjzBhmDQ== =Yuw7 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 16 14:21:34 2023 Received: (at 66911) by debbugs.gnu.org; 16 Nov 2023 19:21:34 +0000 Received: from localhost ([127.0.0.1]:44635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3hvh-0003vh-Lu for submit@debbugs.gnu.org; Thu, 16 Nov 2023 14:21:34 -0500 Received: from mail.muc.de ([193.149.48.3]:58932) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3hvd-0003vM-UC for 66911@debbugs.gnu.org; Thu, 16 Nov 2023 14:21:32 -0500 Received: (qmail 12042 invoked by uid 3782); 16 Nov 2023 20:21:23 +0100 Received: from acm.muc.de (p4fe15ef7.dip0.t-ipconnect.de [79.225.94.247]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 16 Nov 2023 20:21:22 +0100 Received: (qmail 9279 invoked by uid 1000); 16 Nov 2023 19:21:21 -0000 Date: Thu, 16 Nov 2023 19:21:21 +0000 To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Message-ID: References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86y1faykz3.fsf@aarsen.me> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66911 Cc: acm@muc.de, 66911@debbugs.gnu.org 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.0 (-) Hello again, Arsen. On Mon, Nov 06, 2023 at 16:07:05 +0100, Arsen Arsenović wrote: > Alan Mackenzie writes: > >> Though, the anchor still anchors on the template<> line rather than the > >> struct line in: > >> template > >> struct _Base_bitset > >> { > >> ... making it impossible (AFAICT) to create a style that implements: > >> template > >> struct _Base_bitset > >> { > >> }; > >> struct foo > >> { > >> }; > >> instead, the former gets formatted as: > >> template > >> struct _Base_bitset > >> { > >> }; > >> Is this intended? > > Apologies. I missed this second point in your original bug report. > Admittedly, I had considered making it two bug reports because the > issues seemed separate to me, but I wasn't sure if one caused the other > or vice-versa. So, I don't blame you :-) > > This should be fixable, but will be more work to fix than the other > > point. > > I think something like the following would do it: we could add a second > > anchor point to topmost-intro-cont forms, that second point pointing at > > struct. In languages without templates/generics, or in constructs > > lacking template components, both anchor points would be the same. That was a mistake - the second anchor point is needed on class-open lines, not topmost-intro-cont ones. I've coded up this patch, which I include below. Actually, only the last two smallish hunks of the patch are new, the rest is what you've seen before, so it will be necessary to start from a clean copy of cc-engine.el again. The syntactical context of the HERE line (the opening brace of that class) is now something like: ((class-open 76 107)) , where 76 is the position of the template keyword and 107 that of the class keyword. When there's no template, both of these anchor points are the same. Actually, that's not quite accurate: the 107 is the point after the indentation of the line that class is on; it just seemed better that way. > > So you could write an alignment function which would use that second > > anchor point for class-open lines and the like. Or, just possibly, we > > might be able to make that second point the default for class-open. This > > should keep backward compatibility. I'll have to think about this. So, again, please let me know how you get on with this patch. Is the extra anchor point sufficient to write an alignment function to get the indentation you want? > > And of course, the manual and test programs will need amending, too. ;-) They still need amending. On running the test suite, there were 81 files where the new class-open syntactic symbol was different from the recorded old symbol. So I've got 81 files to regenerate. Fortunately, I can do this with a script, even if it will take me a couple of hours to write the script. > That sounds lovely - thanks in advance, if you do, indeed, decide to do > it. For now, I can get this patch implemented with some manual > indenting. > Thanks for the quick fix, have a lovely day :-) Thank you indeed! Have fun with the patch. diff -r 2760aada61fa cc-engine.el --- a/cc-engine.el Sun Oct 15 10:44:22 2023 +0000 +++ b/cc-engine.el Thu Nov 16 18:58:33 2023 +0000 @@ -12633,31 +12633,27 @@ (let ((open-brace (point)) kwd-start first-specifier-pos) (c-syntactic-skip-backward c-block-prefix-charset limit t) - (when (and c-recognize-<>-arglists - (eq (char-before) ?>)) - ;; Could be at the end of a template arglist. - (let ((c-parse-and-markup-<>-arglists t)) - (while (and - (c-backward-<>-arglist nil limit) - (progn - (c-syntactic-skip-backward c-block-prefix-charset limit t) - (eq (char-before) ?>)))))) - - ;; Skip back over noise clauses. - (while (and - c-opt-cpp-prefix - (eq (char-before) ?\)) - (let ((after-paren (point))) - (if (and (c-go-list-backward) - (progn (c-backward-syntactic-ws) - (c-simple-skip-symbol-backward)) - (or (looking-at c-paren-nontype-key) - (looking-at c-noise-macro-with-parens-name-re))) - (progn - (c-syntactic-skip-backward c-block-prefix-charset limit t) - t) - (goto-char after-paren) - nil)))) + (while + (or + ;; Could be after a template arglist.... + (and c-recognize-<>-arglists + (eq (char-before) ?>) + (let ((c-parse-and-markup-<>-arglists t)) + (c-backward-<>-arglist nil limit))) + ;; .... or after a noise clause with parens. + (and c-opt-cpp-prefix + (let ((after-paren (point))) + (if (eq (char-before) ?\)) + (and + (c-go-list-backward) + (eq (char-after) ?\() + (progn (c-backward-syntactic-ws) + (c-simple-skip-symbol-backward)) + (or (looking-at c-paren-nontype-key) ; e.g. __attribute__ + (looking-at c-noise-macro-with-parens-name-re))) + (goto-char after-paren) + nil)))) + (c-syntactic-skip-backward c-block-prefix-charset limit t)) ;; Note: Can't get bogus hits inside template arglists below since they ;; have gotten paren syntax above. @@ -12667,10 +12663,18 @@ ;; The `c-decl-block-key' search continues from there since ;; we know it can't match earlier. (if goto-start - (when (c-syntactic-re-search-forward c-symbol-start - open-brace t t) - (goto-char (setq first-specifier-pos (match-beginning 0))) - t) + (progn + (while + (and + (c-syntactic-re-search-forward c-symbol-start + open-brace t t) + (goto-char (match-beginning 0)) + (if (or (looking-at c-noise-macro-name-re) + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause) + (setq first-specifier-pos (match-beginning 0)) + nil))) + first-specifier-pos) t) (cond @@ -12739,34 +12743,39 @@ (goto-char first-specifier-pos) (while (< (point) kwd-start) - (if (looking-at c-symbol-key) - ;; Accept any plain symbol token on the ground that - ;; it's a specifier masked through a macro (just - ;; like `c-forward-decl-or-cast-1' skip forward over - ;; such tokens). - ;; - ;; Could be more restrictive wrt invalid keywords, - ;; but that'd only occur in invalid code so there's - ;; no use spending effort on it. - (let ((end (match-end 0)) - (kwd-sym (c-keyword-sym (match-string 0)))) - (unless - (and kwd-sym - ;; Moving over a protection kwd and the following - ;; ":" (in C++ Mode) to the next token could take - ;; us all the way up to `kwd-start', leaving us - ;; no chance to update `first-specifier-pos'. - (not (c-keyword-member kwd-sym 'c-protection-kwds)) - (c-forward-keyword-clause 0)) - (goto-char end) - (c-forward-syntactic-ws))) - + (cond + ((or (looking-at c-noise-macro-name-re) + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause)) + ((looking-at c-symbol-key) + ;; Accept any plain symbol token on the ground that + ;; it's a specifier masked through a macro (just + ;; like `c-forward-decl-or-cast-1' skips forward over + ;; such tokens). + ;; + ;; Could be more restrictive wrt invalid keywords, + ;; but that'd only occur in invalid code so there's + ;; no use spending effort on it. + (let ((end (match-end 0)) + (kwd-sym (c-keyword-sym (match-string 0)))) + (unless + (and kwd-sym + ;; Moving over a protection kwd and the following + ;; ":" (in C++ Mode) to the next token could take + ;; us all the way up to `kwd-start', leaving us + ;; no chance to update `first-specifier-pos'. + (not (c-keyword-member kwd-sym 'c-protection-kwds)) + (c-forward-keyword-clause 0)) + (goto-char end) + (c-forward-syntactic-ws)))) + + ((c-syntactic-re-search-forward c-symbol-start + kwd-start 'move t) ;; Can't parse a declaration preamble and is still ;; before `kwd-start'. That means `first-specifier-pos' ;; was in some earlier construct. Search again. - (if (c-syntactic-re-search-forward c-symbol-start - kwd-start 'move t) - (goto-char (setq first-specifier-pos (match-beginning 0))) + (goto-char (setq first-specifier-pos (match-beginning 0)))) + (t ;; Got no preamble before the block declaration keyword. (setq first-specifier-pos kwd-start)))) @@ -14727,7 +14736,10 @@ 'lambda-intro-cont))) (goto-char (cdr placeholder)) (back-to-indentation) - (c-add-stmt-syntax tmpsymbol nil t + (c-add-stmt-syntax tmpsymbol + (and (eq tmpsymbol 'class-open) + (list (point))) + t (c-most-enclosing-brace state-cache (point)) paren-state) (unless (eq (point) (cdr placeholder)) @@ -14770,9 +14782,10 @@ (goto-char indent-point) (skip-chars-forward " \t") (and (eq (char-after) ?{) - (c-looking-at-decl-block t) + (setq tmp-pos (c-looking-at-decl-block t)) (setq placeholder (point)))) - (c-add-syntax 'class-open placeholder)) + (c-add-syntax 'class-open placeholder + (c-point 'boi tmp-pos))) ;; CASE 5A.3: brace list open ((save-excursion > -- > Arsen Arsenović -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 16 15:44:00 2023 Received: (at 66911) by debbugs.gnu.org; 16 Nov 2023 20:44:00 +0000 Received: from localhost ([127.0.0.1]:44726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3jDT-00067d-Uz for submit@debbugs.gnu.org; Thu, 16 Nov 2023 15:44:00 -0500 Received: from mout-p-202.mailbox.org ([80.241.56.172]:45056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3jDR-00067N-Mr for 66911@debbugs.gnu.org; Thu, 16 Nov 2023 15:43:58 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4SWX7V1W8bz9spg; Thu, 16 Nov 2023 21:43:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1700167430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9Dio3YC0OQmApuYopakp8ibOy0+jUV+OcIo/KezTJCo=; b=punJEmzCASbE3+cwAoNCjlsyfpH3k7/psJg+9AGqtT/JBUXakWFbR6HPIXLSWti8Mnm8oQ xTCMh8lEABRn/i2vvdYj7LA1c+lReH11ipJ7rpRGFLBN1w+MfuXOVF0LZALzoJRjmRcNmd o1P46QzCwAog6CUix8LF1gUgNMteDgx17TGefevLv2oZuzBlfp7EZBsZwWNg/D4ouFk8z2 RQRQVEjW15VZMr9+8t2UwBwPK4alAUqEZp+Rv6S+iHAlHV0FQnwP0Vcznb9WPa7LLhTTC0 Nqx8VxNUoXG0afYIYCQy0xNNubqvy+OsPGUTay313nBCy4ZAErfOBPUbKjtqnQ== References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Alan Mackenzie Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Date: Thu, 16 Nov 2023 21:29:29 +0100 In-reply-to: Message-ID: <86h6llbf97.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Rspamd-Queue-Id: 4SWX7V1W8bz9spg X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 66911 Cc: 66911@debbugs.gnu.org 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.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Alan, Thanks for working on this. Alan Mackenzie writes: > Hello again, Arsen. > > On Mon, Nov 06, 2023 at 16:07:05 +0100, Arsen Arsenovi=C4=87 wrote: > >> Alan Mackenzie writes: > >> >> Though, the anchor still anchors on the template<> line rather than t= he >> >> struct line in: > >> >> template >> >> struct _Base_bitset >> >> { > >> >> ... making it impossible (AFAICT) to create a style that implements: > >> >> template >> >> struct _Base_bitset >> >> { >> >> }; > >> >> struct foo >> >> { >> >> }; > >> >> instead, the former gets formatted as: > >> >> template >> >> struct _Base_bitset >> >> { >> >> }; > >> >> Is this intended? > >> > Apologies. I missed this second point in your original bug report. > >> Admittedly, I had considered making it two bug reports because the >> issues seemed separate to me, but I wasn't sure if one caused the other >> or vice-versa. So, I don't blame you :-) > >> > This should be fixable, but will be more work to fix than the other >> > point. > >> > I think something like the following would do it: we could add a second >> > anchor point to topmost-intro-cont forms, that second point pointing at >> > struct. In languages without templates/generics, or in constructs >> > lacking template components, both anchor points would be the same. > > That was a mistake - the second anchor point is needed on class-open > lines, not topmost-intro-cont ones. > > I've coded up this patch, which I include below. Actually, only the last > two smallish hunks of the patch are new, the rest is what you've seen > before, so it will be necessary to start from a clean copy of > cc-engine.el again. > > The syntactical context of the HERE line (the opening brace of that > class) is now something like: > > ((class-open 76 107)) > > , where 76 is the position of the template keyword and 107 that of the > class keyword. When there's no template, both of these anchor points are > the same. Actually, that's not quite accurate: the 107 is the point > after the indentation of the line that class is on; it just seemed better > that way. This behavior seems reasonable to me at a glance and at a test. I like the idea :-) >> > So you could write an alignment function which would use that second >> > anchor point for class-open lines and the like. Or, just possibly, we >> > might be able to make that second point the default for class-open. T= his >> > should keep backward compatibility. I'll have to think about this. > > So, again, please let me know how you get on with this patch. Is the > extra anchor point sufficient to write an alignment function to get the > indentation you want? The following did work nicely (after I made c-langelem-2nd-col, by copying and altering c-langelem-col as is obvious). I'm not sure if it is idiomatic or the cleanest solution, though (plus, my Elisp-fu is poor). =2D-8<---------------cut here---------------start------------->8--- (defun glibcxx-style/line-up-struct (sym-form) "Lines up a class-open with its prior struct line" (if (not (eq 'class-open (c-langelem-sym sym-form))) nil (let ((col (c-langelem-2nd-col c-syntactic-element t))) (if col (vector col) nil)))) =2D-8<---------------cut here---------------end--------------->8--- ... however, I noticed that class-close still anchors on the template that precedes it, and seems to not have a 2nd-pos to play with, so the above line-up fn, when set on class-open, produces: =2D-8<---------------cut here---------------start------------->8--- template struct f { }; =2D-8<---------------cut here---------------end--------------->8--- ... so, we're getting quite close! (It could be that I'm missing something, of course..) Thanks again, have a lovely night (-: >> > And of course, the manual and test programs will need amending, too. = ;-) > > They still need amending. On running the test suite, there were 81 files > where the new class-open syntactic symbol was different from the recorded > old symbol. So I've got 81 files to regenerate. Fortunately, I can do > this with a script, even if it will take me a couple of hours to write > the script. > >> That sounds lovely - thanks in advance, if you do, indeed, decide to do >> it. For now, I can get this patch implemented with some manual >> indenting. > >> Thanks for the quick fix, have a lovely day :-) > > Thank you indeed! Have fun with the patch. > > > > diff -r 2760aada61fa cc-engine.el > --- a/cc-engine.el Sun Oct 15 10:44:22 2023 +0000 > +++ b/cc-engine.el Thu Nov 16 18:58:33 2023 +0000 > @@ -12633,31 +12633,27 @@ > (let ((open-brace (point)) kwd-start first-specifier-pos) > (c-syntactic-skip-backward c-block-prefix-charset limit t) >=20=20 > - (when (and c-recognize-<>-arglists > - (eq (char-before) ?>)) > - ;; Could be at the end of a template arglist. > - (let ((c-parse-and-markup-<>-arglists t)) > - (while (and > - (c-backward-<>-arglist nil limit) > - (progn > - (c-syntactic-skip-backward c-block-prefix-charset limit t) > - (eq (char-before) ?>)))))) > - > - ;; Skip back over noise clauses. > - (while (and > - c-opt-cpp-prefix > - (eq (char-before) ?\)) > - (let ((after-paren (point))) > - (if (and (c-go-list-backward) > - (progn (c-backward-syntactic-ws) > - (c-simple-skip-symbol-backward)) > - (or (looking-at c-paren-nontype-key) > - (looking-at c-noise-macro-with-parens-name-re))) > - (progn > - (c-syntactic-skip-backward c-block-prefix-charset limit t) > - t) > - (goto-char after-paren) > - nil)))) > + (while > + (or > + ;; Could be after a template arglist.... > + (and c-recognize-<>-arglists > + (eq (char-before) ?>) > + (let ((c-parse-and-markup-<>-arglists t)) > + (c-backward-<>-arglist nil limit))) > + ;; .... or after a noise clause with parens. > + (and c-opt-cpp-prefix > + (let ((after-paren (point))) > + (if (eq (char-before) ?\)) > + (and > + (c-go-list-backward) > + (eq (char-after) ?\() > + (progn (c-backward-syntactic-ws) > + (c-simple-skip-symbol-backward)) > + (or (looking-at c-paren-nontype-key) ; e.g. __attribute__ > + (looking-at c-noise-macro-with-parens-name-re))) > + (goto-char after-paren) > + nil)))) > + (c-syntactic-skip-backward c-block-prefix-charset limit t)) >=20=20 > ;; Note: Can't get bogus hits inside template arglists below since t= hey > ;; have gotten paren syntax above. > @@ -12667,10 +12663,18 @@ > ;; The `c-decl-block-key' search continues from there since > ;; we know it can't match earlier. > (if goto-start > - (when (c-syntactic-re-search-forward c-symbol-start > - open-brace t t) > - (goto-char (setq first-specifier-pos (match-beginning 0))) > - t) > + (progn > + (while > + (and > + (c-syntactic-re-search-forward c-symbol-start > + open-brace t t) > + (goto-char (match-beginning 0)) > + (if (or (looking-at c-noise-macro-name-re) > + (looking-at c-noise-macro-with-parens-name-re)) > + (c-forward-noise-clause) > + (setq first-specifier-pos (match-beginning 0)) > + nil))) > + first-specifier-pos) > t) >=20=20 > (cond > @@ -12739,34 +12743,39 @@ > (goto-char first-specifier-pos) >=20=20 > (while (< (point) kwd-start) > - (if (looking-at c-symbol-key) > - ;; Accept any plain symbol token on the ground that > - ;; it's a specifier masked through a macro (just > - ;; like `c-forward-decl-or-cast-1' skip forward over > - ;; such tokens). > - ;; > - ;; Could be more restrictive wrt invalid keywords, > - ;; but that'd only occur in invalid code so there's > - ;; no use spending effort on it. > - (let ((end (match-end 0)) > - (kwd-sym (c-keyword-sym (match-string 0)))) > - (unless > - (and kwd-sym > - ;; Moving over a protection kwd and the following > - ;; ":" (in C++ Mode) to the next token could take > - ;; us all the way up to `kwd-start', leaving us > - ;; no chance to update `first-specifier-pos'. > - (not (c-keyword-member kwd-sym 'c-protection-kwds)) > - (c-forward-keyword-clause 0)) > - (goto-char end) > - (c-forward-syntactic-ws))) > - > + (cond > + ((or (looking-at c-noise-macro-name-re) > + (looking-at c-noise-macro-with-parens-name-re)) > + (c-forward-noise-clause)) > + ((looking-at c-symbol-key) > + ;; Accept any plain symbol token on the ground that > + ;; it's a specifier masked through a macro (just > + ;; like `c-forward-decl-or-cast-1' skips forward over > + ;; such tokens). > + ;; > + ;; Could be more restrictive wrt invalid keywords, > + ;; but that'd only occur in invalid code so there's > + ;; no use spending effort on it. > + (let ((end (match-end 0)) > + (kwd-sym (c-keyword-sym (match-string 0)))) > + (unless > + (and kwd-sym > + ;; Moving over a protection kwd and the following > + ;; ":" (in C++ Mode) to the next token could take > + ;; us all the way up to `kwd-start', leaving us > + ;; no chance to update `first-specifier-pos'. > + (not (c-keyword-member kwd-sym 'c-protection-kwds)) > + (c-forward-keyword-clause 0)) > + (goto-char end) > + (c-forward-syntactic-ws)))) > + > + ((c-syntactic-re-search-forward c-symbol-start > + kwd-start 'move t) > ;; Can't parse a declaration preamble and is still > ;; before `kwd-start'. That means `first-specifier-pos' > ;; was in some earlier construct. Search again. > - (if (c-syntactic-re-search-forward c-symbol-start > - kwd-start 'move t) > - (goto-char (setq first-specifier-pos (match-beginning 0))) > + (goto-char (setq first-specifier-pos (match-beginning 0)))) > + (t > ;; Got no preamble before the block declaration keyword. > (setq first-specifier-pos kwd-start)))) >=20=20 > @@ -14727,7 +14736,10 @@ > 'lambda-intro-cont))) > (goto-char (cdr placeholder)) > (back-to-indentation) > - (c-add-stmt-syntax tmpsymbol nil t > + (c-add-stmt-syntax tmpsymbol > + (and (eq tmpsymbol 'class-open) > + (list (point))) > + t > (c-most-enclosing-brace state-cache (point)) > paren-state) > (unless (eq (point) (cdr placeholder)) > @@ -14770,9 +14782,10 @@ > (goto-char indent-point) > (skip-chars-forward " \t") > (and (eq (char-after) ?{) > - (c-looking-at-decl-block t) > + (setq tmp-pos (c-looking-at-decl-block t)) > (setq placeholder (point)))) > - (c-add-syntax 'class-open placeholder)) > + (c-add-syntax 'class-open placeholder > + (c-point 'boi tmp-pos))) >=20=20 > ;; CASE 5A.3: brace list open > ((save-excursion > > >> --=20 >> Arsen Arsenovi=C4=87 =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZVZ/BF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTJxQBAPzrrQB5AAHqVgEaebRFHLphqpJF5xjHbKud je8/POk8AP9TXjRgnnlvjtkbqYS2InQFmWCUVPHb9Pb83T9f8qh8Cw== =noMl -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 17 07:09:42 2023 Received: (at 66911) by debbugs.gnu.org; 17 Nov 2023 12:09:42 +0000 Received: from localhost ([127.0.0.1]:45456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3xfJ-0004Lx-6Q for submit@debbugs.gnu.org; Fri, 17 Nov 2023 07:09:42 -0500 Received: from mail.muc.de ([193.149.48.3]:31948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3xfF-0004Lf-Sx for 66911@debbugs.gnu.org; Fri, 17 Nov 2023 07:09:40 -0500 Received: (qmail 78793 invoked by uid 3782); 17 Nov 2023 13:09:29 +0100 Received: from acm.muc.de (p4fe15a41.dip0.t-ipconnect.de [79.225.90.65]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 17 Nov 2023 13:09:29 +0100 Received: (qmail 7826 invoked by uid 1000); 17 Nov 2023 12:09:28 -0000 Date: Fri, 17 Nov 2023 12:09:28 +0000 To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Message-ID: References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> <86h6llbf97.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86h6llbf97.fsf@aarsen.me> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66911 Cc: acm@muc.de, 66911@debbugs.gnu.org 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.0 (-) Hello, Arsen. On Thu, Nov 16, 2023 at 21:29:29 +0100, Arsen Arsenović wrote: > Hi Alan, > Thanks for working on this. > Alan Mackenzie writes: [ .... ] > > That was a mistake - the second anchor point is needed on class-open > > lines, not topmost-intro-cont ones. > > I've coded up this patch, which I include below. Actually, only the last > > two smallish hunks of the patch are new, the rest is what you've seen > > before, so it will be necessary to start from a clean copy of > > cc-engine.el again. > > The syntactical context of the HERE line (the opening brace of that > > class) is now something like: > > ((class-open 76 107)) > > , where 76 is the position of the template keyword and 107 that of the > > class keyword. When there's no template, both of these anchor points are > > the same. Actually, that's not quite accurate: the 107 is the point > > after the indentation of the line that class is on; it just seemed better > > that way. > This behavior seems reasonable to me at a glance and at a test. I like > the idea :-) [ .... ] > > So, again, please let me know how you get on with this patch. Is the > > extra anchor point sufficient to write an alignment function to get the > > indentation you want? > The following did work nicely (after I made c-langelem-2nd-col, by > copying and altering c-langelem-col as is obvious). I'm not sure if it > is idiomatic or the cleanest solution, though (plus, my Elisp-fu is > poor). > --8<---------------cut here---------------start------------->8--- > (defun glibcxx-style/line-up-struct (sym-form) > "Lines up a class-open with its prior struct line" > (if (not (eq 'class-open (c-langelem-sym sym-form))) > nil > (let ((col (c-langelem-2nd-col c-syntactic-element t))) > (if col > (vector col) > nil)))) > --8<---------------cut here---------------end--------------->8--- > ... however, I noticed that class-close still anchors on the template > that precedes it, and seems to not have a 2nd-pos to play with, so the > above line-up fn, when set on class-open, produces: > --8<---------------cut here---------------start------------->8--- > template > struct f > { > }; > --8<---------------cut here---------------end--------------->8--- Yes. I should have noticed this myself. :-( > ... so, we're getting quite close! So, please try out the new patch (below) which supplies the second anchor point to class-close too. The patch applies cleanly to the Emacs master branch. Again, please start off with a clean cc-engine.el before applying the new patch, not the version with the previous patch applied. [ .... ] diff -r 2760aada61fa cc-engine.el --- a/cc-engine.el Sun Oct 15 10:44:22 2023 +0000 +++ b/cc-engine.el Fri Nov 17 11:49:55 2023 +0000 @@ -12633,31 +12633,27 @@ (let ((open-brace (point)) kwd-start first-specifier-pos) (c-syntactic-skip-backward c-block-prefix-charset limit t) - (when (and c-recognize-<>-arglists - (eq (char-before) ?>)) - ;; Could be at the end of a template arglist. - (let ((c-parse-and-markup-<>-arglists t)) - (while (and - (c-backward-<>-arglist nil limit) - (progn - (c-syntactic-skip-backward c-block-prefix-charset limit t) - (eq (char-before) ?>)))))) - - ;; Skip back over noise clauses. - (while (and - c-opt-cpp-prefix - (eq (char-before) ?\)) - (let ((after-paren (point))) - (if (and (c-go-list-backward) - (progn (c-backward-syntactic-ws) - (c-simple-skip-symbol-backward)) - (or (looking-at c-paren-nontype-key) - (looking-at c-noise-macro-with-parens-name-re))) - (progn - (c-syntactic-skip-backward c-block-prefix-charset limit t) - t) - (goto-char after-paren) - nil)))) + (while + (or + ;; Could be after a template arglist.... + (and c-recognize-<>-arglists + (eq (char-before) ?>) + (let ((c-parse-and-markup-<>-arglists t)) + (c-backward-<>-arglist nil limit))) + ;; .... or after a noise clause with parens. + (and c-opt-cpp-prefix + (let ((after-paren (point))) + (if (eq (char-before) ?\)) + (and + (c-go-list-backward) + (eq (char-after) ?\() + (progn (c-backward-syntactic-ws) + (c-simple-skip-symbol-backward)) + (or (looking-at c-paren-nontype-key) ; e.g. __attribute__ + (looking-at c-noise-macro-with-parens-name-re))) + (goto-char after-paren) + nil)))) + (c-syntactic-skip-backward c-block-prefix-charset limit t)) ;; Note: Can't get bogus hits inside template arglists below since they ;; have gotten paren syntax above. @@ -12667,10 +12663,18 @@ ;; The `c-decl-block-key' search continues from there since ;; we know it can't match earlier. (if goto-start - (when (c-syntactic-re-search-forward c-symbol-start - open-brace t t) - (goto-char (setq first-specifier-pos (match-beginning 0))) - t) + (progn + (while + (and + (c-syntactic-re-search-forward c-symbol-start + open-brace t t) + (goto-char (match-beginning 0)) + (if (or (looking-at c-noise-macro-name-re) + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause) + (setq first-specifier-pos (match-beginning 0)) + nil))) + first-specifier-pos) t) (cond @@ -12739,34 +12743,39 @@ (goto-char first-specifier-pos) (while (< (point) kwd-start) - (if (looking-at c-symbol-key) - ;; Accept any plain symbol token on the ground that - ;; it's a specifier masked through a macro (just - ;; like `c-forward-decl-or-cast-1' skip forward over - ;; such tokens). - ;; - ;; Could be more restrictive wrt invalid keywords, - ;; but that'd only occur in invalid code so there's - ;; no use spending effort on it. - (let ((end (match-end 0)) - (kwd-sym (c-keyword-sym (match-string 0)))) - (unless - (and kwd-sym - ;; Moving over a protection kwd and the following - ;; ":" (in C++ Mode) to the next token could take - ;; us all the way up to `kwd-start', leaving us - ;; no chance to update `first-specifier-pos'. - (not (c-keyword-member kwd-sym 'c-protection-kwds)) - (c-forward-keyword-clause 0)) - (goto-char end) - (c-forward-syntactic-ws))) - + (cond + ((or (looking-at c-noise-macro-name-re) + (looking-at c-noise-macro-with-parens-name-re)) + (c-forward-noise-clause)) + ((looking-at c-symbol-key) + ;; Accept any plain symbol token on the ground that + ;; it's a specifier masked through a macro (just + ;; like `c-forward-decl-or-cast-1' skips forward over + ;; such tokens). + ;; + ;; Could be more restrictive wrt invalid keywords, + ;; but that'd only occur in invalid code so there's + ;; no use spending effort on it. + (let ((end (match-end 0)) + (kwd-sym (c-keyword-sym (match-string 0)))) + (unless + (and kwd-sym + ;; Moving over a protection kwd and the following + ;; ":" (in C++ Mode) to the next token could take + ;; us all the way up to `kwd-start', leaving us + ;; no chance to update `first-specifier-pos'. + (not (c-keyword-member kwd-sym 'c-protection-kwds)) + (c-forward-keyword-clause 0)) + (goto-char end) + (c-forward-syntactic-ws)))) + + ((c-syntactic-re-search-forward c-symbol-start + kwd-start 'move t) ;; Can't parse a declaration preamble and is still ;; before `kwd-start'. That means `first-specifier-pos' ;; was in some earlier construct. Search again. - (if (c-syntactic-re-search-forward c-symbol-start - kwd-start 'move t) - (goto-char (setq first-specifier-pos (match-beginning 0))) + (goto-char (setq first-specifier-pos (match-beginning 0)))) + (t ;; Got no preamble before the block declaration keyword. (setq first-specifier-pos kwd-start)))) @@ -14181,7 +14190,8 @@ (defun c-add-class-syntax (symbol containing-decl-open containing-decl-start - containing-decl-kwd) + containing-decl-kwd + &rest args) ;; The inclass and class-close syntactic symbols are added in ;; several places and some work is needed to fix everything. ;; Therefore it's collected here. @@ -14196,7 +14206,7 @@ ;; Ought to use `c-add-stmt-syntax' instead of backing up to boi ;; here, but we have to do like this for compatibility. (back-to-indentation) - (c-add-syntax symbol (point)) + (apply #'c-add-syntax symbol (point) args) (if (and (c-keyword-member containing-decl-kwd 'c-inexpr-class-kwds) (/= containing-decl-start (c-point 'boi containing-decl-start))) @@ -14230,9 +14240,10 @@ ;; CASE B.1: class-open ((save-excursion (and (eq (char-after) ?{) - (c-looking-at-decl-block t) + (setq placeholder (c-looking-at-decl-block t)) (setq beg-of-same-or-containing-stmt (point)))) - (c-add-syntax 'class-open beg-of-same-or-containing-stmt)) + (c-add-syntax 'class-open beg-of-same-or-containing-stmt + (c-point 'boi placeholder))) ;; CASE B.2: brace-list-open ((or (consp special-brace-list) @@ -14727,7 +14738,10 @@ 'lambda-intro-cont))) (goto-char (cdr placeholder)) (back-to-indentation) - (c-add-stmt-syntax tmpsymbol nil t + (c-add-stmt-syntax tmpsymbol + (and (eq tmpsymbol 'class-open) + (list (point))) + t (c-most-enclosing-brace state-cache (point)) paren-state) (unless (eq (point) (cdr placeholder)) @@ -14770,9 +14784,10 @@ (goto-char indent-point) (skip-chars-forward " \t") (and (eq (char-after) ?{) - (c-looking-at-decl-block t) + (setq tmp-pos (c-looking-at-decl-block t)) (setq placeholder (point)))) - (c-add-syntax 'class-open placeholder)) + (c-add-syntax 'class-open placeholder + (c-point 'boi tmp-pos))) ;; CASE 5A.3: brace list open ((save-excursion @@ -15170,10 +15185,14 @@ ((and containing-sexp (eq char-after-ip ?}) (eq containing-decl-open containing-sexp)) + (save-excursion + (goto-char containing-decl-open) + (setq tmp-pos (c-looking-at-decl-block t))) (c-add-class-syntax 'class-close containing-decl-open containing-decl-start - containing-decl-kwd)) + containing-decl-kwd + (c-point 'boi tmp-pos))) ;; CASE 5H: we could be looking at subsequent knr-argdecls ((and c-recognize-knr-p > -- > Arsen Arsenović -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 17 14:35:32 2023 Received: (at 66911) by debbugs.gnu.org; 17 Nov 2023 19:35:32 +0000 Received: from localhost ([127.0.0.1]:47168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r44cm-0002Yi-36 for submit@debbugs.gnu.org; Fri, 17 Nov 2023 14:35:32 -0500 Received: from mout-p-202.mailbox.org ([80.241.56.172]:56258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r44ci-0002YT-HB for 66911@debbugs.gnu.org; Fri, 17 Nov 2023 14:35:30 -0500 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4SX6Z031tTz9spY; Fri, 17 Nov 2023 20:35:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1700249720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6ej1pRQ6BTDUDMMVMH4h2SvpM2FcpN+O/9oc6D417fA=; b=kTOAP0wdMKH3GSynvh9m/h9CD/ghkYdAdPZdiH/9Jn+Szl+pNHRdxTTep7cdBykz3icgMK yxNDeFK+BJYcmkc0a7TUzsJ55njiie0KD0eQ37Q2Njve+w7YSpxMK5g/7RLklmidfWJTtd yGeZXWNkd14JImPGcFRQUlEHZohr7l30/o8Zh3DyphRYa5lkNGUeOR+LpPQOnqb+8fqcDY k7LafdVzOp3x/VfyovptOlwHV+uq6bMlolAc0UzrUQMwnOHuPWNSL6o8jNQOX6zJo6EBiY aWgALFrgbU71ecGQYv6/G+byfZxWnT0Vsvk2Iiqmx0qbeuMRZopDhLUZPwdKPg== References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> <86h6llbf97.fsf@aarsen.me> From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Alan Mackenzie Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Date: Fri, 17 Nov 2023 20:16:31 +0100 In-reply-to: Message-ID: <86fs1441hl.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 66911 Cc: 66911@debbugs.gnu.org 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.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Alan, Thanks (again!) for working on this. Alan Mackenzie writes: > Hello, Arsen. > > On Thu, Nov 16, 2023 at 21:29:29 +0100, Arsen Arsenovi=C4=87 wrote: >> Hi Alan, > >> Thanks for working on this. > >> Alan Mackenzie writes: > > [ .... ] > >> > That was a mistake - the second anchor point is needed on class-open >> > lines, not topmost-intro-cont ones. > >> > I've coded up this patch, which I include below. Actually, only the l= ast >> > two smallish hunks of the patch are new, the rest is what you've seen >> > before, so it will be necessary to start from a clean copy of >> > cc-engine.el again. > >> > The syntactical context of the HERE line (the opening brace of that >> > class) is now something like: > >> > ((class-open 76 107)) > >> > , where 76 is the position of the template keyword and 107 that of the >> > class keyword. When there's no template, both of these anchor points = are >> > the same. Actually, that's not quite accurate: the 107 is the point >> > after the indentation of the line that class is on; it just seemed bet= ter >> > that way. > >> This behavior seems reasonable to me at a glance and at a test. I like >> the idea :-) > > [ .... ] > >> > So, again, please let me know how you get on with this patch. Is the >> > extra anchor point sufficient to write an alignment function to get the >> > indentation you want? > >> The following did work nicely (after I made c-langelem-2nd-col, by >> copying and altering c-langelem-col as is obvious). I'm not sure if it >> is idiomatic or the cleanest solution, though (plus, my Elisp-fu is >> poor). > >> --8<---------------cut here---------------start------------->8--- >> (defun glibcxx-style/line-up-struct (sym-form) >> "Lines up a class-open with its prior struct line" >> (if (not (eq 'class-open (c-langelem-sym sym-form))) >> nil >> (let ((col (c-langelem-2nd-col c-syntactic-element t))) >> (if col >> (vector col) >> nil)))) >> --8<---------------cut here---------------end--------------->8--- > >> ... however, I noticed that class-close still anchors on the template >> that precedes it, and seems to not have a 2nd-pos to play with, so the >> above line-up fn, when set on class-open, produces: > >> --8<---------------cut here---------------start------------->8--- >> template >> struct f >> { >> }; >> --8<---------------cut here---------------end--------------->8--- > > Yes. I should have noticed this myself. :-( > >> ... so, we're getting quite close! > > So, please try out the new patch (below) which supplies the second anchor > point to class-close too. The patch applies cleanly to the Emacs master > branch. Again, please start off with a clean cc-engine.el before > applying the new patch, not the version with the previous patch applied. Excellent! The following did it: =2D-8<---------------cut here---------------start------------->8--- (defun glibcxx-style/line-up-struct (sym-form) "Lines up a class-open/close with its prior struct line" (if (not (seq-contains-p '(class-open class-close) (c-langelem-sym sym-form))) nil (let ((col (c-langelem-2nd-col c-syntactic-element t))) (if col (vector col) nil)))) =2D-8<---------------cut here---------------end--------------->8--- Again, unsure if it is the most elegant solution, or even if it's a good one. But it did work! I've copied c-langelem-2nd-col again to do the above. Is that helper intentionally omitted? Is there perhaps a more idiomatic solution? In any case, I'll be sure to use this as soon as it lands in the Emacs VCS. Thanks again, have a lovely night! =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZVfAdl8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTxq4BAPYAvMrMoDWkKTZmHvjgQg1SWLSpkaEMgONF oQ32gCpaAQC4uOiM6PSkl9E2nKR75vkNY/da5NFgJkCBzTkwod7ZAw== =SlIH -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 17 15:18:01 2023 Received: (at 66911) by debbugs.gnu.org; 17 Nov 2023 20:18:01 +0000 Received: from localhost ([127.0.0.1]:47189 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r45Hs-0003pc-SX for submit@debbugs.gnu.org; Fri, 17 Nov 2023 15:18:01 -0500 Received: from mail.muc.de ([193.149.48.3]:43279) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r45Hp-0003pI-P4 for 66911@debbugs.gnu.org; Fri, 17 Nov 2023 15:18:00 -0500 Received: (qmail 39985 invoked by uid 3782); 17 Nov 2023 21:17:50 +0100 Received: from acm.muc.de (p4fe15a41.dip0.t-ipconnect.de [79.225.90.65]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 17 Nov 2023 21:17:50 +0100 Received: (qmail 11248 invoked by uid 1000); 17 Nov 2023 20:17:47 -0000 Date: Fri, 17 Nov 2023 20:17:47 +0000 To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Message-ID: References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> <86h6llbf97.fsf@aarsen.me> <86fs1441hl.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86fs1441hl.fsf@aarsen.me> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66911 Cc: acm@muc.de, 66911@debbugs.gnu.org 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.0 (-) Hello, Arsen. On Fri, Nov 17, 2023 at 20:16:31 +0100, Arsen Arsenović wrote: > Hi Alan, > Thanks (again!) for working on this. Appreciated! > Alan Mackenzie writes: > > On Thu, Nov 16, 2023 at 21:29:29 +0100, Arsen Arsenović wrote: > >> The following did work nicely (after I made c-langelem-2nd-col, by > >> copying and altering c-langelem-col as is obvious). I'm not sure if it > >> is idiomatic or the cleanest solution, though (plus, my Elisp-fu is > >> poor). I think c-langelem-2nd-col is as good as anything else. It's better to have it as a function than open coding it everywhere it's used. > >> --8<---------------cut here---------------start------------->8--- > >> (defun glibcxx-style/line-up-struct (sym-form) > >> "Lines up a class-open with its prior struct line" > >> (if (not (eq 'class-open (c-langelem-sym sym-form))) > >> nil > >> (let ((col (c-langelem-2nd-col c-syntactic-element t))) > >> (if col > >> (vector col) > >> nil)))) > >> --8<---------------cut here---------------end--------------->8--- > >> ... however, I noticed that class-close still anchors on the template > >> that precedes it, and seems to not have a 2nd-pos to play with, so the > >> above line-up fn, when set on class-open, produces: > >> --8<---------------cut here---------------start------------->8--- > >> template > >> struct f > >> { > >> }; > >> --8<---------------cut here---------------end--------------->8--- > > Yes. I should have noticed this myself. :-( > >> ... so, we're getting quite close! > > So, please try out the new patch (below) which supplies the second anchor > > point to class-close too. The patch applies cleanly to the Emacs master > > branch. Again, please start off with a clean cc-engine.el before > > applying the new patch, not the version with the previous patch applied. > Excellent! The following did it: > --8<---------------cut here---------------start------------->8--- > (defun glibcxx-style/line-up-struct (sym-form) > "Lines up a class-open/close with its prior struct line" > (if (not (seq-contains-p '(class-open class-close) > (c-langelem-sym sym-form))) > nil > (let ((col (c-langelem-2nd-col c-syntactic-element t))) > (if col > (vector col) > nil)))) > --8<---------------cut here---------------end--------------->8--- > Again, unsure if it is the most elegant solution, or even if it's a good > one. But it did work! Working is rather more important than elegance. ;-) > I've copied c-langelem-2nd-col again to do the above. Is that helper > intentionally omitted? Is there perhaps a more idiomatic solution? I don't think so. > In any case, I'll be sure to use this as soon as it lands in the Emacs > VCS. This might take a few days - I've still got to amend the (stand alone CC Mode) test suite and the documentation. And I've got quite a lot on in Real Life in the next few days. > Thanks again, have a lovely night! Thanks. You too! > -- > Arsen Arsenović -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 24 05:15:00 2023 Received: (at 66911-done) by debbugs.gnu.org; 24 Nov 2023 10:15:00 +0000 Received: from localhost ([127.0.0.1]:35654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6TDA-0004tZ-6Q for submit@debbugs.gnu.org; Fri, 24 Nov 2023 05:15:00 -0500 Received: from mail.muc.de ([193.149.48.3]:29085) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6TD7-0004tK-C4 for 66911-done@debbugs.gnu.org; Fri, 24 Nov 2023 05:14:58 -0500 Received: (qmail 28045 invoked by uid 3782); 24 Nov 2023 11:14:46 +0100 Received: from acm.muc.de (pd953a757.dip0.t-ipconnect.de [217.83.167.87]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 24 Nov 2023 11:14:45 +0100 Received: (qmail 3905 invoked by uid 1000); 24 Nov 2023 10:14:45 -0000 Date: Fri, 24 Nov 2023 10:14:45 +0000 To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Message-ID: References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> <86h6llbf97.fsf@aarsen.me> <86fs1441hl.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 66911-done Cc: acm@muc.de, 66911-done@debbugs.gnu.org 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.0 (-) Hello, Arsen. On Fri, Nov 17, 2023 at 20:17:47 +0000, Alan Mackenzie wrote: > On Fri, Nov 17, 2023 at 20:16:31 +0100, Arsen Arsenović wrote: > > Hi Alan, [ .... ] > > > So, please try out the new patch (below) which supplies the second anchor > > > point to class-close too. The patch applies cleanly to the Emacs master > > > branch. Again, please start off with a clean cc-engine.el before > > > applying the new patch, not the version with the previous patch applied. [ .... ] > > In any case, I'll be sure to use this as soon as it lands in the Emacs > > VCS. > This might take a few days - I've still got to amend the (stand alone CC > Mode) test suite and the documentation. And I've got quite a lot on in > Real Life in the next few days. I've now amended the test suite and cc-mode.texi. I've committed the enhancement to all the usual places, including the Emacs master branch, so I'm closing the bug with this post. > > -- > > Arsen Arsenović -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 24 13:12:02 2023 Received: (at 66911-done) by debbugs.gnu.org; 24 Nov 2023 18:12:02 +0000 Received: from localhost ([127.0.0.1]:37224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6ael-0006PI-Hh for submit@debbugs.gnu.org; Fri, 24 Nov 2023 13:12:02 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]:48136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6aeg-0006P2-VK for 66911-done@debbugs.gnu.org; Fri, 24 Nov 2023 13:11:58 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4ScNNG2pzyz9sxP; Fri, 24 Nov 2023 19:11:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1700849502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R8P4EId/4TrxqllwnHTBDgGcfjpskibhJg0CH6YekmE=; b=Psn/NTubALORBaOeixwF4OxwS+vuKxNWXi9cMREK7XRSvR4J3mE4CtsdCX7lJ3zuVU0lg2 ghlbVHoixUAPE0yvdJupD5ajt+1XFi+r3tF3usFfy/IBDX8Gydk/andH7aGaY5b0oXmLav QXmcLDghQqjOpODnWEfduvIO8FyiwcXGq6rNDkcE+s+a4QQBF5atOq0PUXuNlVUNA9OHPG OmFoBgefSz2f236u5b8GksZL0qxloKDfZxaz7X0fHwC5fzBySMnt2eg4xOmwWzG0OPurGY Gfqq8SD4DeADRSmhBsl7WBXQjtnNHkPJcBb0pF8bFyNcqS4fm6nrG4U8OxZJZw== References: <87zfzv16io.fsf@aarsen.me> <867cmv2iua.fsf@aarsen.me> <86y1faykz3.fsf@aarsen.me> <86h6llbf97.fsf@aarsen.me> <86fs1441hl.fsf@aarsen.me> From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Alan Mackenzie Subject: Re: bug#66911: CC Mode 5.35.2 (C++//l); Noise macro being taken as anchor to class-open Date: Fri, 24 Nov 2023 19:09:44 +0100 In-reply-to: Message-ID: <86bkbjc97o.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Rspamd-Queue-Id: 4ScNNG2pzyz9sxP X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 66911-done Cc: 66911-done@debbugs.gnu.org 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.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Alan, Alan Mackenzie writes: > Hello, Arsen. > > On Fri, Nov 17, 2023 at 20:17:47 +0000, Alan Mackenzie wrote: >> On Fri, Nov 17, 2023 at 20:16:31 +0100, Arsen Arsenovi=C4=87 wrote: >> > Hi Alan, > > [ .... ] > >> > > So, please try out the new patch (below) which supplies the second a= nchor >> > > point to class-close too. The patch applies cleanly to the Emacs ma= ster >> > > branch. Again, please start off with a clean cc-engine.el before >> > > applying the new patch, not the version with the previous patch appl= ied. > > [ .... ] > >> > In any case, I'll be sure to use this as soon as it lands in the Emacs >> > VCS. > >> This might take a few days - I've still got to amend the (stand alone CC >> Mode) test suite and the documentation. And I've got quite a lot on in >> Real Life in the next few days. > > I've now amended the test suite and cc-mode.texi. I've committed the > enhancement to all the usual places, including the Emacs master branch, > so I'm closing the bug with this post. Thank you very much! I shall update Emacs today, then. Would you be interested in adding the GNU-derived libstdc++ style into CC-mode proper? After I give it a further test-drive and possibly more bug squashing. Have a lovely night! >> > --=20 >> > Arsen Arsenovi=C4=87 =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZWDnW18UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTUnAA/AybTQKAQ6W1MifoQxBNX/DhUOzlA4RvCxFv xEQRs250AQDs8Ag+So13RXRN+69vzyAFP0X996ZMyNEjcSjPWDmjCg== =Batk -----END PGP SIGNATURE----- --=-=-=-- From unknown Sun Jun 15 08:33:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 23 Dec 2023 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator