Received: (at 43558) by debbugs.gnu.org; 19 Nov 2020 21:31:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 19 16:31:59 2020 Received: from localhost ([127.0.0.1]:41182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kfrX4-0000IC-2q for submit <at> debbugs.gnu.org; Thu, 19 Nov 2020 16:31:58 -0500 Received: from colin.muc.de ([193.149.48.1]:26351 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kfrX1-0000By-KD for 43558 <at> debbugs.gnu.org; Thu, 19 Nov 2020 16:31:56 -0500 Received: (qmail 33276 invoked by uid 3782); 19 Nov 2020 21:31:50 -0000 Received: from acm.muc.de (p4fe153fb.dip0.t-ipconnect.de [79.225.83.251]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 19 Nov 2020 22:31:49 +0100 Received: (qmail 28724 invoked by uid 1000); 19 Nov 2020 21:31:49 -0000 Resent-Date: Thu, 19 Nov 2020 21:31:49 +0000 Resent-Message-ID: <20201119213149.GA28101@ACM> Resent-To: 43558 <at> debbugs.gnu.org Date: Thu, 19 Nov 2020 21:18:22 +0000 From: Alan Mackenzie <acm@HIDDEN> To: Stefan Monnier <monnier@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20201119211822.GE6259@ACM> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> <20200924102022.GA4714@ACM> <jwv7dsjp1i7.fsf-monnier+emacs@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <jwv7dsjp1i7.fsf-monnier+emacs@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) Resent-From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN>, acm@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Stefan. On Thu, Sep 24, 2020 at 12:56:42 -0400, Stefan Monnier wrote: > > As already said, this is a(n ugly) workaround. syntax.c should handle > > comments in all their generality. With a bit of consideration, the > > method to do this is clear: > In my world, it's quite normal for a specific language's lexical rules > not to line up 100% with syntax tables (whether for strings, comments, > younameit). I don't see anything very special here. > A `syntax-propertize` rule for "\*/" should be very easy to implement > and fairly cheap since the regexp is simple and will almost never match. > So, yeah, you can add yet-another-hack on top of the other syntax.c > hacks if you want, but there's a good chance it will only ever be used > by CC-mode. It will take a lot more code changes in syntax.c than > a quick tweak to your Elisp code to search for "\*/". > I do think it would be good to handle this without `syntax-table` > text-property hacks, but I think that should come with an overhaul of > syntax.c based on a major-mode provided DFA (or something like that) so > it can accommodate all the various oddball cases without even the need > to introduce the notion of escaping comment markers. OK, here's the patch. As a matter of interest, it's been heavily tested by the .../test/src/syntax-tests.el unit tests, further enhancements to which are part of the patch. Just as a reminder, the motivation is to be able to have syntax.c correctly parse C/C++ line comments which look like: foo(); // comment \\ second line of comment. by introducing a new syntax flag "e" as a modifier on the syntax entry for \n: (modify-syntax-entry ?\n "> be") > Stefan diff --git a/src/syntax.c b/src/syntax.c index df07809aaa..c701729ba1 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -108,6 +108,11 @@ SYNTAX_FLAGS_COMMENT_NESTED (int flags) { return (flags >> 22) & 1; } +static bool +SYNTAX_FLAGS_COMMENT_ESCAPES (int flags) +{ + return (flags >> 24) & 1; +} /* FLAGS should be the flags of the main char of the comment marker, e.g. the second for comstart and the first for comend. */ @@ -673,6 +678,26 @@ prev_char_comend_first (ptrdiff_t pos, ptrdiff_t pos_byte) return val; } +static bool +comment_ender_quoted (ptrdiff_t from, ptrdiff_t from_byte, int syntax) +{ + int c; + int next_syntax; + if (comment_end_can_be_escaped && char_quoted (from, from_byte)) + return true; + if (SYNTAX_FLAGS_COMMENT_ESCAPES (syntax)) + { + dec_both (&from, &from_byte); + UPDATE_SYNTAX_TABLE_BACKWARD (from); + c = FETCH_CHAR_AS_MULTIBYTE (from_byte); + next_syntax = SYNTAX_WITH_FLAGS (c); + UPDATE_SYNTAX_TABLE_FORWARD (from + 1); + if (next_syntax == Sescape || next_syntax == Scharquote) + return true; + } + return false; +} + /* Check whether charpos FROM is at the end of a comment. FROM_BYTE is the bytepos corresponding to FROM. Do not move back before STOP. @@ -755,6 +780,20 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, && SYNTAX_FLAGS_COMEND_SECOND (prev_syntax)); comstart = (com2start || code == Scomment); + /* Check for any current delimiter being escaped. */ + if (from > stop + && (((com2end || code == Sendcomment) + && comment_ender_quoted (from, from_byte, syntax)) + || (code == Scomment + && comment_end_can_be_escaped + && char_quoted (from, from_byte)))) + { + dec_both (&from, &from_byte); + UPDATE_SYNTAX_TABLE_BACKWARD (from); + com2end = comstart = com2start = 0; + syntax = Smax; + } + /* Nasty cases with overlapping 2-char comment markers: - snmp-mode: -- c -- foo -- c -- --- c -- @@ -1191,6 +1230,10 @@ the value of a `syntax-table' text property. */) case 'c': val |= 1 << 23; break; + + case 'e': + val |= 1 << 24; + break; } if (val < ASIZE (Vsyntax_code_object) && NILP (match)) @@ -1279,7 +1322,8 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, (Lisp_Object syntax) { int code, syntax_code; - bool start1, start2, end1, end2, prefix, comstyleb, comstylec, comnested; + bool start1, start2, end1, end2, prefix, comstyleb, comstylec, comnested, + comescapes; char str[2]; Lisp_Object first, match_lisp, value = syntax; @@ -1320,6 +1364,7 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, comstyleb = SYNTAX_FLAGS_COMMENT_STYLEB (syntax_code); comstylec = SYNTAX_FLAGS_COMMENT_STYLEC (syntax_code); comnested = SYNTAX_FLAGS_COMMENT_NESTED (syntax_code); + comescapes = SYNTAX_FLAGS_COMMENT_ESCAPES (syntax_code); if (Smax <= code) { @@ -1353,6 +1398,8 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, insert ("c", 1); if (comnested) insert ("n", 1); + if (comescapes) + insert ("e", 1); insert_string ("\twhich means: "); @@ -1416,6 +1463,8 @@ DEFUN ("internal-describe-syntax-value", Finternal_describe_syntax_value, insert_string (" (comment style c)"); if (comnested) insert_string (" (nestable)"); + if (comescapes) + insert_string (" (can be escaped)"); if (prefix) { @@ -2336,7 +2385,7 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ? (nesting > 0 && --nesting == 0) : nesting < 0) - && !(comment_end_can_be_escaped && char_quoted (from, from_byte))) + && !comment_ender_quoted (from, from_byte, syntax)) /* We have encountered a comment end of the same style as the comment sequence which began this comment section. */ @@ -2354,12 +2403,12 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, /* We have encountered a nested comment of the same style as the comment sequence which began this comment section. */ nesting++; - if (comment_end_can_be_escaped - && (code == Sescape || code == Scharquote)) + if (SYNTAX_FLAGS_COMEND_FIRST (syntax) + && comment_ender_quoted (from, from_byte, syntax)) { inc_both (&from, &from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); - if (from == stop) continue; /* Failure */ + continue; } inc_both (&from, &from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); @@ -2493,8 +2542,8 @@ between them, return t; otherwise return nil. */) /* We're at the start of a comment. */ found = forw_comment (from, from_byte, stop, comnested, comstyle, 0, &out_charpos, &out_bytepos, &dummy, &dummy2); - from = out_charpos; from_byte = out_bytepos; - if (!found) + from = out_charpos; from_byte = out_bytepos; + if (!found) { SET_PT_BOTH (from, from_byte); return Qnil; @@ -2526,21 +2575,27 @@ between them, return t; otherwise return nil. */) if (code == Sendcomment) comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0); if (from > stop && SYNTAX_FLAGS_COMEND_SECOND (syntax) - && prev_char_comend_first (from, from_byte) - && !char_quoted (from - 1, dec_bytepos (from_byte))) + && prev_char_comend_first (from, from_byte)) { int other_syntax; - /* We must record the comment style encountered so that + /* We must record the comment style encountered so that later, we can match only the proper comment begin sequence of the same style. */ dec_both (&from, &from_byte); - code = Sendcomment; - /* Calling char_quoted, above, set up global syntax position - at the new value of FROM. */ c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); other_syntax = SYNTAX_WITH_FLAGS (c1); - comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); - comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); + if (!comment_ender_quoted (from, from_byte, other_syntax)) + { + code = Sendcomment; + comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); + comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); + syntax = other_syntax; + } + else + { + inc_both (&from, &from_byte); + UPDATE_SYNTAX_TABLE_FORWARD (from); + } } if (code == Scomment_fence) @@ -2579,7 +2634,8 @@ between them, return t; otherwise return nil. */) } else if (code == Sendcomment) { - found = (!quoted || !comment_end_can_be_escaped) + found = + !comment_ender_quoted (from, from_byte, syntax) && back_comment (from, from_byte, stop, comnested, comstyle, &out_charpos, &out_bytepos); if (!found) @@ -2864,6 +2920,7 @@ scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag) other_syntax = SYNTAX_WITH_FLAGS (c2); comstyle = SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax); comnested |= SYNTAX_FLAGS_COMMENT_NESTED (other_syntax); + syntax = other_syntax; } /* Quoting turns anything except a comment-ender @@ -2946,7 +3003,10 @@ scan_lists (EMACS_INT from0, EMACS_INT count, EMACS_INT depth, bool sexpflag) case Sendcomment: if (!parse_sexp_ignore_comments) break; - found = back_comment (from, from_byte, stop, comnested, comstyle, + found = + (from == stop + || !comment_ender_quoted (from, from_byte, syntax)) + && back_comment (from, from_byte, stop, comnested, comstyle, &out_charpos, &out_bytepos); /* FIXME: if !found, it really wasn't a comment-end. For single-char Sendcomment, we can't do much about it apart diff --git a/test/src/syntax-resources/syntax-comments.txt b/test/src/syntax-resources/syntax-comments.txt index a292d816b9..f3357ea244 100644 --- a/test/src/syntax-resources/syntax-comments.txt +++ b/test/src/syntax-resources/syntax-comments.txt @@ -34,7 +34,7 @@ 54{ //74 \ }54 55{/* */}55 -56{ /*76 \*/ }56 +56{ /*76 \*/80 }56 57*/77 58}58 60{ /*78 \\*/79}60 @@ -87,6 +87,21 @@ 110 111#| ; |#111 +/* Comments and purported comments containing string delimiters. */ +120/* "string" */120 +121/* "" */121 +122/* " */122 +130/* +" " */130 +" "*/123 +124/* " ' */124 +126/* +" ' */126 +127/* " " " " " */127 +128/* " ' " ' " ' */128 +129/* ' " ' " ' */129 +" ' */125 + Local Variables: mode: fundamental eval: (set-syntax-table (make-syntax-table)) diff --git a/test/src/syntax-tests.el b/test/src/syntax-tests.el index edee01ec58..399986c31d 100644 --- a/test/src/syntax-tests.el +++ b/test/src/syntax-tests.el @@ -307,6 +307,7 @@ syntax-pps-comments ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun {-in () (setq parse-sexp-ignore-comments t) + (setq comment-use-syntax-ppss nil) (setq comment-end-can-be-escaped nil) (modify-syntax-entry ?{ "<") (modify-syntax-entry ?} ">")) @@ -336,6 +337,7 @@ {-out ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun \;-in () (setq parse-sexp-ignore-comments t) + (setq comment-use-syntax-ppss nil) (setq comment-end-can-be-escaped nil) (modify-syntax-entry ?\n ">") (modify-syntax-entry ?\; "<") @@ -375,6 +377,7 @@ \;-out ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun \#|-in () (setq parse-sexp-ignore-comments t) + (setq comment-use-syntax-ppss nil) (modify-syntax-entry ?# ". 14") (modify-syntax-entry ?| ". 23n") (modify-syntax-entry ?\; "< b") @@ -418,15 +421,18 @@ \#|-out ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun /*-in () (setq parse-sexp-ignore-comments t) + (setq comment-use-syntax-ppss nil) (setq comment-end-can-be-escaped t) (modify-syntax-entry ?/ ". 124b") (modify-syntax-entry ?* ". 23") - (modify-syntax-entry ?\n "> b")) + (modify-syntax-entry ?\n "> b") + (modify-syntax-entry ?\' "\"")) (defun /*-out () (setq comment-end-can-be-escaped nil) (modify-syntax-entry ?/ ".") (modify-syntax-entry ?* ".") - (modify-syntax-entry ?\n " ")) + (modify-syntax-entry ?\n " ") + (modify-syntax-entry ?\' ".")) (eval-and-compile (setq syntax-comments-section "c")) @@ -489,4 +495,142 @@ /*-out (syntax-pps-comments /* 56 76 77 58) (syntax-pps-comments /* 60 78 79) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Emacs 28 "C" style comments - `comment-end-can-be-escaped' is nil, the +;; "e" flag is used for line comments. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun //-in () + (setq parse-sexp-ignore-comments t) + (setq comment-use-syntax-ppss nil) + (modify-syntax-entry ?/ ". 124be") + (modify-syntax-entry ?* ". 23") + (modify-syntax-entry ?\n "> be") + (modify-syntax-entry ?\' "\"")) +(defun //-out () + (modify-syntax-entry ?/ ".") + (modify-syntax-entry ?* ".") + (modify-syntax-entry ?\n " ") + (modify-syntax-entry ?\' ".")) +(eval-and-compile + (setq syntax-comments-section "c++")) + +(syntax-comments // forward t 1) +(syntax-comments // backward t 1) +(syntax-comments // forward t 2) +(syntax-comments // backward t 2) +(syntax-comments // forward t 3) +(syntax-comments // backward t 3) + +(syntax-comments // forward t 4) +(syntax-comments // backward t 4) +(syntax-comments // forward t 5 6) +(syntax-comments // backward nil 5 0) +(syntax-comments // forward nil 6 0) +(syntax-comments // backward t 6 5) + +(syntax-comments // forward t 7) +(syntax-comments // backward t 7) +(syntax-comments // forward nil 8 0) +(syntax-comments // backward nil 8 0) +(syntax-comments // forward t 9) +(syntax-comments // backward t 9) + +(syntax-comments // forward nil 10 0) +(syntax-comments // backward nil 10 0) +(syntax-comments // forward t 11) +(syntax-comments // backward t 11) + +(syntax-comments // forward t 13) +(syntax-comments // backward t 13) +(syntax-comments // forward t 15) +(syntax-comments // backward t 15) + +;; Emacs 28 "C" style comments inside brace lists. +(syntax-br-comments // forward t 50) +(syntax-br-comments // backward t 50) +(syntax-br-comments // forward t 51) +(syntax-br-comments // backward t 51) +(syntax-br-comments // forward t 52) +(syntax-br-comments // backward t 52) + +(syntax-br-comments // forward t 53) +(syntax-br-comments // backward t 53) +(syntax-br-comments // forward t 54 58) +(syntax-br-comments // backward t 54) +(syntax-br-comments // forward t 55) +(syntax-br-comments // backward t 55) + +(syntax-br-comments // forward t 56 56) +(syntax-br-comments // backward t 58 54) +(syntax-br-comments // backward nil 59) +(syntax-br-comments // forward t 60) +(syntax-br-comments // backward t 60) + +;; Emacs 28 "C" style comments parsed by `parse-partial-sexp'. +(syntax-pps-comments // 50 70 71) +(syntax-pps-comments // 52 72 73) +(syntax-pps-comments // 54 74 55 58) +(syntax-pps-comments // 56 76 80) +(syntax-pps-comments // 60 78 79) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Comments containing string delimiters. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(eval-and-compile + (setq syntax-comments-section "c-\"")) + +(syntax-comments /* forward t 120) +(syntax-comments /* backward t 120) +(syntax-comments /* forward t 121) +(syntax-comments /* backward t 121) +(syntax-comments /* forward t 122) +(syntax-comments /* backward t 122) + +(syntax-comments /* backward nil 123 0) +(syntax-comments /* forward t 124) +(syntax-comments /* backward t 124) +(syntax-comments /* backward nil 125 0) +(syntax-comments /* forward t 126) +(syntax-comments /* backward t 126) + +(syntax-comments /* forward t 127) +(syntax-comments /* backward t 127) +(syntax-comments /* forward t 128) +(syntax-comments /* backward t 128) +(syntax-comments /* forward t 129) +(syntax-comments /* backward t 129) + +(syntax-comments /* forward t 130) +(syntax-comments /* backward t 130) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; The same again, with Emacs 28 style C comments. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(eval-and-compile + (setq syntax-comments-section "c++-\"")) + +(syntax-comments // forward t 120) +(syntax-comments // backward t 120) +(syntax-comments // forward t 121) +(syntax-comments // backward t 121) +(syntax-comments // forward t 122) +(syntax-comments // backward t 122) + +(syntax-comments // backward nil 123 0) +(syntax-comments // forward t 124) +(syntax-comments // backward t 124) +(syntax-comments // backward nil 125 0) +(syntax-comments // forward t 126) +(syntax-comments // backward t 126) + +(syntax-comments // forward t 127) +(syntax-comments // backward t 127) +(syntax-comments // forward t 128) +(syntax-comments // backward t 128) +(syntax-comments // forward t 129) +(syntax-comments // backward t 129) + +(syntax-comments // forward t 130) +(syntax-comments // backward t 130) + ;;; syntax-tests.el ends here -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Debbugs Internal Request <help-debbugs@HIDDEN>
to internal_control <at> debbugs.gnu.org
.
Full text available.Alan Mackenzie <acm@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Debbugs Internal Request <help-debbugs@HIDDEN>
to internal_control <at> debbugs.gnu.org
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 22:43:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 18:43:19 2020 Received: from localhost ([127.0.0.1]:41979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLZxP-0007zm-5F for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 18:43:19 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1kLZxJ-0007zV-HV for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 18:43:17 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id BF71A10022C; Thu, 24 Sep 2020 18:43:07 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CF3F510001F; Thu, 24 Sep 2020 18:43:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600987385; bh=3wV5sFDgj3Czxfyv5P1FY4gFnJ5zDFJNt/56La2tabA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=b8u19j7cZ0PQo9sXbFgeSJO7dkP4Kii0y54gsrJxkn/7ubjBdDTB/t/7rY1Gy+q/q YisKPn1F0oLoTpfeSir8TT/FVtZ5OO/12eoxI3yaw34r6PVhnSwYE6WDnvSRSeWmKA ZyD+5LLW8BA+HnV3fG/Z1755j1LDciW7Ehz+cLXsAvKIlFrHVR/AgBaphL5HPY6wnH 2LjmLrdNw7mi9QDkiF+9Rz39Lwc0lBZ+5OZHhnt2mAi0q5rIPmOgy+e7LM9qt9xp87 ufg26fGy6EwEiyjgKnV/BSdK47pbyGQFTcDKfeoABqV1+Iatl0UZxgJgYfL1ikZi1w lVSD8dy0eSEww== Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 938F11203B2; Thu, 24 Sep 2020 18:43:05 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <jwv3636n7b9.fsf-monnier+emacs@HIDDEN> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> <20200924102022.GA4714@ACM> <jwv7dsjp1i7.fsf-monnier+emacs@HIDDEN> <20200924185031.GB4714@ACM> Date: Thu, 24 Sep 2020 18:43:04 -0400 In-Reply-To: <20200924185031.GB4714@ACM> (Alan Mackenzie's message of "Thu, 24 Sep 2020 18:50:31 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.051 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?windows-1252?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) >> > As already said, this is a(n ugly) workaround. syntax.c should handle >> > comments in all their generality. With a bit of consideration, the >> > method to do this is clear: >> In my world, it's quite normal for a specific language's lexical rules >> not to line up 100% with syntax tables (whether for strings, comments, >> younameit). I don't see anything very special here. > Normally when there's a mismatch, it's because a character is > syntactically ambiguous. There's nothing syntax.c can do about this. Oh, no, there are many more situations than just "a character is syntactically ambiguous" (or alternatively you could argue that all cases are "a character is syntactically ambiguous", including your cases of escaped newline and escaped */). >> A `syntax-propertize` rule for "\*/" should be very easy to implement >> and fairly cheap since the regexp is simple and will almost never match. > Well, the rule would actually be for escaped newlines, It doesn't have to be if you set `comment-end-can-be-escaped` to non-nil, in which case you only need to tweak the \*/ case, AFAICT. > but this would be quite expensive (compared with a syntax.c solution) > since every comment near a change region would need scanning at > each change. I don't know what you mean by scanning, but yes you'd need to search for all "\\\\\n" or "\\\\\\*/" (depending on how you set `comment-end-can-be-escaped) and mark the second char accordingly. Seems pretty cheap in either case. > I've hacked up a working, but as yet unsatisfactory, change to syntax.c. > It is surely better, where possible, to fix bugs at their point of > causation rather than by workarounds elsewhere. I don't think it's a bug in `syntax.c`. `syntax.c` is not defined to support the syntax of C, it's only defined to handle a particular set of comment and string styles, which correspond to a common subset of what is in use in most languages, but IME most languages need some extra tweaks handled via the `syntax-table` text property. It's only a question of time until we add a `syntax-propertize-function` for Elisp mode to properly handle some corner cases, for example. >> I do think it would be good to handle this without `syntax-table` >> text-property hacks, but I think that should come with an overhaul of >> syntax.c based on a major-mode provided DFA (or something like that) so >> it can accommodate all the various oddball cases without even the need >> to introduce the notion of escaping comment markers. > That sounds almost more like a rewrite than an overhaul. Tomato tomahto. > We would need to make sure that this wouldn't run more slowly than the > current syntax.c/Lisp combination. I don't think that would be required, as long as it runs fast enough. In any case, the resulting performance is probably not the main worry (I suspect it will/would be easy to make it fast enough). Stefan
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 20:28:07 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 16:28:07 2020 Received: from localhost ([127.0.0.1]:41899 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLXqY-0002hn-MO for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 16:28:06 -0400 Received: from veto.sei.cmu.edu ([147.72.252.17]:56112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mwd@HIDDEN>) id 1kLXqT-0002hE-BE for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 16:28:04 -0400 Received: from korb.sei.cmu.edu (korb.sei.cmu.edu [10.64.21.30]) by veto.sei.cmu.edu (8.14.7/8.14.7) with ESMTP id 08OKRpRQ004974; Thu, 24 Sep 2020 16:27:51 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 veto.sei.cmu.edu 08OKRpRQ004974 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cert.org; s=yc2bmwvrj62m; t=1600979272; bh=vlj8poS9fa2fSE/vU43Rz9kFRxlSgMC2A8WUTyv4tls=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=CGpsxJQ/AftZ/FGc+D4Dhzsfa6jIsLxsAFm3XdJuoU4xdlfqqUFbZWG880nRRF4Eq +Jc6vLdjv4AsiF9+kV7ctwV5farNqRhHaPdLz39Ao0uUMyrxK2gO4bD8Z37Y2CgiT/ FWSpxDCzykOWnJ4cynh243vpqVZDwVH2JPofxggs= Received: from lx-birch.ad.sei.cmu.edu (lx-birch.ad.sei.cmu.edu [10.64.53.120]) by korb.sei.cmu.edu (8.14.7/8.14.7) with ESMTP id 08OKRnrk022482; Thu, 24 Sep 2020 16:27:49 -0400 Received: from lx-birch.ad.sei.cmu.edu (localhost [127.0.0.1]) by lx-birch.ad.sei.cmu.edu (8.14.7/8.14.7) with ESMTP id 08OKRmkP026517; Thu, 24 Sep 2020 16:27:48 -0400 Received: (from mwd@localhost) by lx-birch.ad.sei.cmu.edu (8.14.7/8.14.7) id 08OKRmSW026514; Thu, 24 Sep 2020 16:27:48 -0400 X-Authentication-Warning: lx-birch.ad.sei.cmu.edu: mwd set sender to mwd@HIDDEN using -f From: Michael Welsh Duggan <mwd@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <87v9g3yplr.fsf@HIDDEN> <20200924195742.GC4714@ACM> Date: Thu, 24 Sep 2020 16:27:48 -0400 In-Reply-To: <20200924195742.GC4714@ACM> (Alan Mackenzie's message of "Thu, 24 Sep 2020 15:57:42 -0400") Message-ID: <y2tdefr1qqc43f.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 43558 Cc: Michael Welsh Duggan <mwd@HIDDEN>, Mattias =?utf-8?Q?Engdeg=C3=A5rd?= <mattiase@HIDDEN>, "43558 <at> debbugs.gnu.org" <43558 <at> debbugs.gnu.org>, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Alan Mackenzie <acm@HIDDEN> writes: > Hello, Michael. > > On Thu, Sep 24, 2020 at 14:52:16 -0400, Michael Welsh Duggan wrote: >> Alan Mackenzie <acm@HIDDEN> writes: > >> > On Wed, Sep 23, 2020 at 11:01:59 +0200, Mattias Engdeg=C3=A5rd wrote: >> >> Sorry if I misunderstood, but since when do backslashes escape */ in = C? > >> > Since forever, but only in the CC Mode test suite. :-( > >> > I just tried it out with gcc, and it seems that \*/ does indeed end a >> > block comment. But an escaped newline doesn't end a line comment, >> > instead continuing it to the next line. So I got confused. Thanks for >> > pointing out the mistake. > >> > It seems that as well as the existing variable >> > comment-end-can-be-escaped, we need a new one, say >> > line-comment-end-can-be-escaped, too. In C and C++ modes, these would >> > be nil and t respectively. > >> But where does it say that backslashes escape */ in C++? > > Nowhere. :-( > > There has been a test in the CC Mode test suite for many years which > assumed this (but was disabled for existing (X)Emacs versions, waiting > for a new Emacs version to be "fixed"). > >> The C++ 14 standard (and it hasn't changed through C++ 20) says: > >> 2.7 Comments [lex.comment] >=20=20=20=20=20 >> The characters /* start a comment, which terminates with the >> characters */. These comments do not nest. The characters // start >> a comment, which terminates immediately before the next new-line >> character. > > For all the difference it makes, Emacs assumes the comment ends _after_ > the NL. > >> If there is a form-feed or a vertical-tab character in such a >> comment, only white-space characters shall appear between it and >> the new-line that terminates the comment; no diagnostic is >> required. > > I didn't know that. Emacs/CC Mode doesn't code up this subtlety. It > probably isn't worth bothering about. > >> [ Note: The comment characters //, /*, and */ have no special >> meaning within a // comment and are treated just like other >> characters. Similarly, the comment characters // and /* have no >> special meaning within a /* comment. =E2=80=94 end note ] > > Additionally, an escaped newline continues a comment onto the next line. > This happens, notionally, at a very early stage of compilation where a > backslash followed by NL anywhere get replaced by a space. I think that > even two backslashes followed by NL would get replaced by backslash, > space. Almost. A backslash followed by a newline is elided completely, joining the lines. (Not replaced by a space. Otherwise, I concur. --=20 Michael Welsh Duggan (mwd@HIDDEN)
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 19:57:51 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 15:57:51 2020 Received: from localhost ([127.0.0.1]:41811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLXNG-0001wH-RJ for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 15:57:51 -0400 Received: from colin.muc.de ([193.149.48.1]:41804 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kLXNF-0001w3-8K for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 15:57:49 -0400 Received: (qmail 78094 invoked by uid 3782); 24 Sep 2020 19:57:42 -0000 Received: from acm.muc.de (p4fe15b66.dip0.t-ipconnect.de [79.225.91.102]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 24 Sep 2020 21:57:42 +0200 Received: (qmail 31210 invoked by uid 1000); 24 Sep 2020 19:57:42 -0000 Date: Thu, 24 Sep 2020 19:57:42 +0000 To: Michael Welsh Duggan <mwd@HIDDEN> Subject: Re: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200924195742.GC4714@ACM> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <87v9g3yplr.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87v9g3yplr.fsf@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN>, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Michael. On Thu, Sep 24, 2020 at 14:52:16 -0400, Michael Welsh Duggan wrote: > Alan Mackenzie <acm@HIDDEN> writes: > > On Wed, Sep 23, 2020 at 11:01:59 +0200, Mattias Engdegård wrote: > >> Sorry if I misunderstood, but since when do backslashes escape */ in C? > > Since forever, but only in the CC Mode test suite. :-( > > I just tried it out with gcc, and it seems that \*/ does indeed end a > > block comment. But an escaped newline doesn't end a line comment, > > instead continuing it to the next line. So I got confused. Thanks for > > pointing out the mistake. > > It seems that as well as the existing variable > > comment-end-can-be-escaped, we need a new one, say > > line-comment-end-can-be-escaped, too. In C and C++ modes, these would > > be nil and t respectively. > But where does it say that backslashes escape */ in C++? Nowhere. :-( There has been a test in the CC Mode test suite for many years which assumed this (but was disabled for existing (X)Emacs versions, waiting for a new Emacs version to be "fixed"). > The C++ 14 standard (and it hasn't changed through C++ 20) says: > 2.7 Comments [lex.comment] > The characters /* start a comment, which terminates with the > characters */. These comments do not nest. The characters // start > a comment, which terminates immediately before the next new-line > character. For all the difference it makes, Emacs assumes the comment ends _after_ the NL. > If there is a form-feed or a vertical-tab character in such a > comment, only white-space characters shall appear between it and > the new-line that terminates the comment; no diagnostic is > required. I didn't know that. Emacs/CC Mode doesn't code up this subtlety. It probably isn't worth bothering about. > [ Note: The comment characters //, /*, and */ have no special > meaning within a // comment and are treated just like other > characters. Similarly, the comment characters // and /* have no > special meaning within a /* comment. — end note ] Additionally, an escaped newline continues a comment onto the next line. This happens, notionally, at a very early stage of compilation where a backslash followed by NL anywhere get replaced by a space. I think that even two backslashes followed by NL would get replaced by backslash, space. > -- > Michael Welsh Duggan > (md5i@HIDDEN) -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 18:52:29 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 14:52:29 2020 Received: from localhost ([127.0.0.1]:41746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLWM1-0004cP-I9 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 14:52:29 -0400 Received: from md5i.com ([75.151.244.229]:40480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mwd@HIDDEN>) id 1kLWLz-0004cH-Og for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 14:52:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=md5i.com; s=dkim; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TgXUxapiN/8MkQPCduD01bJMXu8bXBFxLWRxxDpbGqo=; b=vE5my4PR2EPM/gdZKvw9iP2aOV 5R84+ZqYr9TXeB4Dd121gKN+7fEGR/n9Q+O3O2caKTyBC0esMOcQta37oCKhpqiwRsXp11TByO/AI oLPteE8luufnlijjI3xMmf+rX; Received: from md5i by md5i.com with local (Exim 4.94) (envelope-from <mwd@HIDDEN>) id 1kLWLo-005242-Gm; Thu, 24 Sep 2020 14:52:16 -0400 From: Michael Welsh Duggan <mwd@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> Date: Thu, 24 Sep 2020 14:52:16 -0400 In-Reply-To: <20200923144824.GD6178@ACM> (Alan Mackenzie's message of "Wed, 23 Sep 2020 14:48:24 +0000") Message-ID: <87v9g3yplr.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN>, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Alan Mackenzie <acm@HIDDEN> writes: > Hello, Mattias. > > On Wed, Sep 23, 2020 at 11:01:59 +0200, Mattias Engdeg=E5rd wrote: >> Sorry if I misunderstood, but since when do backslashes escape */ in C? > > Since forever, but only in the CC Mode test suite. :-( > > I just tried it out with gcc, and it seems that \*/ does indeed end a > block comment. But an escaped newline doesn't end a line comment, > instead continuing it to the next line. So I got confused. Thanks for > pointing out the mistake. > > It seems that as well as the existing variable > comment-end-can-be-escaped, we need a new one, say > line-comment-end-can-be-escaped, too. In C and C++ modes, these would > be nil and t respectively. But where does it say that backslashes escape */ in C++? The C++ 14 standard (and it hasn't changed through C++ 20) says: 2.7 Comments [lex.comment] =20=20=20=20 The characters /* start a comment, which terminates with the characters */. These comments do not nest. The characters // start a comment, which terminates immediately before the next new-line character. If there is a form-feed or a vertical-tab character in such a comment, only white-space characters shall appear between it and the new-line that terminates the comment; no diagnostic is required. [ Note: The comment characters //, /*, and */ have no special meaning within a // comment and are treated just like other characters. Similarly, the comment characters // and /* have no special meaning within a /* comment. =97 end note ] --=20 Michael Welsh Duggan (md5i@HIDDEN)
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 18:50:41 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 14:50:41 2020 Received: from localhost ([127.0.0.1]:41742 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLWKH-0004Zn-4x for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 14:50:41 -0400 Received: from colin.muc.de ([193.149.48.1]:38311 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kLWKF-0004ZX-Dx for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 14:50:40 -0400 Received: (qmail 34526 invoked by uid 3782); 24 Sep 2020 18:50:32 -0000 Received: from acm.muc.de (p4fe15b66.dip0.t-ipconnect.de [79.225.91.102]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 24 Sep 2020 20:50:31 +0200 Received: (qmail 30966 invoked by uid 1000); 24 Sep 2020 18:50:31 -0000 Date: Thu, 24 Sep 2020 18:50:31 +0000 To: Stefan Monnier <monnier@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200924185031.GB4714@ACM> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> <20200924102022.GA4714@ACM> <jwv7dsjp1i7.fsf-monnier+emacs@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <jwv7dsjp1i7.fsf-monnier+emacs@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Stefan. On Thu, Sep 24, 2020 at 12:56:42 -0400, Stefan Monnier wrote: > > As already said, this is a(n ugly) workaround. syntax.c should handle > > comments in all their generality. With a bit of consideration, the > > method to do this is clear: > In my world, it's quite normal for a specific language's lexical rules > not to line up 100% with syntax tables (whether for strings, comments, > younameit). I don't see anything very special here. Normally when there's a mismatch, it's because a character is syntactically ambiguous. There's nothing syntax.c can do about this. In the current situation, this isn't the case: syntax.c is unable to handle a comment scenario where there is no ambiguity. > A `syntax-propertize` rule for "\*/" should be very easy to implement > and fairly cheap since the regexp is simple and will almost never match. Well, the rule would actually be for escaped newlines, but this would be quite expensive (compared with a syntax.c solution) since every comment near a change region would need scanning at each change. > So, yeah, you can add yet-another-hack on top of the other syntax.c > hacks if you want, but there's a good chance it will only ever be used > by CC-mode. It will take a lot more code changes in syntax.c than > a quick tweak to your Elisp code to search for "\*/". I've hacked up a working, but as yet unsatisfactory, change to syntax.c. It is surely better, where possible, to fix bugs at their point of causation rather than by workarounds elsewhere. As you note, CC Mode modes will be the only known users at the moment. Just as an aside, the project where I was working ~four years ago banned a proprietory editor after a mammoth search for a bug caused by an unintentional escaped NL on a line comment. The banned editor didn't fontify the continuation line in comment face. I was able to demonstrate to the project manager that Emacs fontified that comment correctly. > I do think it would be good to handle this without `syntax-table` > text-property hacks, but I think that should come with an overhaul of > syntax.c based on a major-mode provided DFA (or something like that) so > it can accommodate all the various oddball cases without even the need > to introduce the notion of escaping comment markers. That sounds almost more like a rewrite than an overhaul. You mean, I think, that the syntax of language expressions would be defined using something a bit like (but more powerful than) regular expressions. And with that, the need for syntactic analysis in Lisp would be much reduced. We would need to make sure that this wouldn't run more slowly than the current syntax.c/Lisp combination. > Stefan -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 16:56:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 12:56:52 2020 Received: from localhost ([127.0.0.1]:41512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLUY8-0001gW-Jz for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 12:56:52 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:38736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1kLUY7-0001gG-CC for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 12:56:51 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B412F100251; Thu, 24 Sep 2020 12:56:45 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 30521100096; Thu, 24 Sep 2020 12:56:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600966604; bh=j989CJi0m0jSmlwtHzu4LISP2j1UjOPGBjYk84K8TJc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=myycgk2pY7AQBHbh+cPXnxW8Hlczj3LSUNRC8p7bPJFQd/nGzUeWm+HHtbFTRipSw ikSs7+H7zoOtu3ZHLFyOl+ZV6lv4jRJiHsTI0VJifmbY/I5TKr0gH1RVIG0s3NSMMU otqOYn4aziXA1jWcb0wDAGpiskcNnle2ZxijagN+CN6N6gfbgYjUa4C1RivA7FqaRx p0DCMykCFsmToA9ulBydomc+DJtgaNYmB8JP6Q0J+4rOtv4+xaNwywFSy/kcMNws/j jGqdJB4M2BnHcHbaTkxlGl4l9mby1tH05/ZWlgal2S+5zlw+4YNIK93SKh6OwNEhvt KIjYM7/meWpQQ== Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D3BEE12021C; Thu, 24 Sep 2020 12:56:43 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <jwv7dsjp1i7.fsf-monnier+emacs@HIDDEN> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> <20200924102022.GA4714@ACM> Date: Thu, 24 Sep 2020 12:56:42 -0400 In-Reply-To: <20200924102022.GA4714@ACM> (Alan Mackenzie's message of "Thu, 24 Sep 2020 10:20:22 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.049 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?windows-1252?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > As already said, this is a(n ugly) workaround. syntax.c should handle > comments in all their generality. With a bit of consideration, the > method to do this is clear: In my world, it's quite normal for a specific language's lexical rules not to line up 100% with syntax tables (whether for strings, comments, younameit). I don't see anything very special here. A `syntax-propertize` rule for "\*/" should be very easy to implement and fairly cheap since the regexp is simple and will almost never match. So, yeah, you can add yet-another-hack on top of the other syntax.c hacks if you want, but there's a good chance it will only ever be used by CC-mode. It will take a lot more code changes in syntax.c than a quick tweak to your Elisp code to search for "\*/". I do think it would be good to handle this without `syntax-table` text-property hacks, but I think that should come with an overhaul of syntax.c based on a major-mode provided DFA (or something like that) so it can accommodate all the various oddball cases without even the need to introduce the notion of escaping comment markers. Stefan
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 24 Sep 2020 10:20:34 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 06:20:34 2020 Received: from localhost ([127.0.0.1]:38679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLOMc-0001hS-4k for submit <at> debbugs.gnu.org; Thu, 24 Sep 2020 06:20:34 -0400 Received: from colin.muc.de ([193.149.48.1]:38429 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kLOMY-0001h9-CM for 43558 <at> debbugs.gnu.org; Thu, 24 Sep 2020 06:20:33 -0400 Received: (qmail 43336 invoked by uid 3782); 24 Sep 2020 10:20:23 -0000 Received: from acm.muc.de (p4fe15b66.dip0.t-ipconnect.de [79.225.91.102]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Thu, 24 Sep 2020 12:20:22 +0200 Received: (qmail 4728 invoked by uid 1000); 24 Sep 2020 10:20:22 -0000 Date: Thu, 24 Sep 2020 10:20:22 +0000 To: Stefan Monnier <monnier@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200924102022.GA4714@ACM> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Stefan. On Wed, Sep 23, 2020 at 14:44:54 -0400, Stefan Monnier wrote: > > It seems that as well as the existing variable > > comment-end-can-be-escaped, we need a new one, say > > line-comment-end-can-be-escaped, too. > syntax.c doesn't like to think of it as "line-comment" but rather as > comment stay a, b, c, or nested and non-nested. > > In C and C++ modes, these would be nil and t respectively. > I sm-c-mode, I'd handle those corner cases in > `syntax-propertize-function` (tho I think I don't bother with this one > currently). > So, I guess in CC-mode, you could handle those by placing `syntax-table` > properties from ... wherever you place them ;-) As already said, this is a(n ugly) workaround. syntax.c should handle comments in all their generality. With a bit of consideration, the method to do this is clear: Introduce a new syntax flag `e' which takes effect in comment delimiters. It means "escape characters are active in this type of comment". In a two character delimiter it would, like `b', only take effect on the inner of the two characters. So the syntaxes of the C++ comment characters would be amended to look like / ". 124be" * ". 23" (unchanged) \n "> be" This would be an easy change to make, and (unlike using syntax-table text properties) would cost negligible run time. What do you think? > Stefan -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 23 Sep 2020 20:02:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 23 16:02:26 2020 Received: from localhost ([127.0.0.1]:37971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLAyA-0000hL-9F for submit <at> debbugs.gnu.org; Wed, 23 Sep 2020 16:02:26 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:38626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1kLAy8-0000h6-H1 for 43558 <at> debbugs.gnu.org; Wed, 23 Sep 2020 16:02:24 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 46B7F80921; Wed, 23 Sep 2020 16:02:19 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 061E6814CD; Wed, 23 Sep 2020 16:02:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600891338; bh=Jiadvwcb/PlVaJd0xAtYj8p8u2VxgZJLBnWyBMTNyqI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=SsBmIqJA/WjJ4+ePaOH/JD4lCTIJfYxp1eJlqJZuDV3goH9jtnO2Oa96rS+Kd9fX0 ixgLHji/NnfKLc1dUU6lr4oQ3M06LL8RCxvyGvQ9ovuRqCiZeC+VxdO1Iv1JpB5jh1 v/Q/vo2UZ9KLjFnQtdarIE0Mxji7r1EcKovSFU5K20vI8DZcK00OG2t0AsB3o3MCum E6kE+gun5ThjXZILrZnDC7zL6FJt4OICYc5XK/fsklfiQgF85cT6pBaExSwP0TbkMe hsbRuL56x0u0PknNSIBS7TXDnW+XhHPiaHdUiBoElYImXFSJVGwscS5WUQeiAsun0i 48qrK7XyRscmQ== Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B76E21205CC; Wed, 23 Sep 2020 16:02:17 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <jwvh7ros1ne.fsf-monnier+emacs@HIDDEN> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> <20200923194441.GE6178@ACM> Date: Wed, 23 Sep 2020 16:02:16 -0400 In-Reply-To: <20200923194441.GE6178@ACM> (Alan Mackenzie's message of "Wed, 23 Sep 2020 19:44:41 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.075 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?windows-1252?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > But on the other hand, it feels like a workaround for the lack of a Yes, that's the definition of `syntax-propertize-function` ;-) Stefan
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 23 Sep 2020 19:44:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 23 15:44:52 2020 Received: from localhost ([127.0.0.1]:37924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kLAhA-0008W7-2g for submit <at> debbugs.gnu.org; Wed, 23 Sep 2020 15:44:52 -0400 Received: from colin.muc.de ([193.149.48.1]:36382 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kLAh6-0008Vi-UH for 43558 <at> debbugs.gnu.org; Wed, 23 Sep 2020 15:44:50 -0400 Received: (qmail 97817 invoked by uid 3782); 23 Sep 2020 19:44:42 -0000 Received: from acm.muc.de (p4fe156c4.dip0.t-ipconnect.de [79.225.86.196]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Wed, 23 Sep 2020 21:44:41 +0200 Received: (qmail 31789 invoked by uid 1000); 23 Sep 2020 19:44:41 -0000 Date: Wed, 23 Sep 2020 19:44:41 +0000 To: Stefan Monnier <monnier@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200923194441.GE6178@ACM> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Stefan. On Wed, Sep 23, 2020 at 14:44:54 -0400, Stefan Monnier wrote: > > It seems that as well as the existing variable > > comment-end-can-be-escaped, we need a new one, say > > line-comment-end-can-be-escaped, too. > syntax.c doesn't like to think of it as "line-comment" but rather as > comment stay [ ?? style ?? ] a, b, c, or nested and non-nested. Hmm. It could be quite troublesome to decide on an interface for major modes specifying "comment style b can have its ender escaped, but comment styles a and c cannot". > > In C and C++ modes, these would > > be nil and t respectively. > I sm-c-mode, I'd handle those corner cases in > `syntax-propertize-function` (tho I think I don't bother with this one > currently). > So, I guess in CC-mode, you could handle those by placing `syntax-table` > properties from ... wherever you place them ;-) Thanks, that's an idea - either putting a neutral s-t prop on the \ of \*/, or something on the \n of \\n in a line comment. I think the first of these is a better idea than the second. But on the other hand, it feels like a workaround for the lack of a full-featured comment-end-can-be-escaped. > Stefan -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 23 Sep 2020 18:45:04 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 23 14:45:04 2020 Received: from localhost ([127.0.0.1]:37841 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kL9lI-0006Ur-3R for submit <at> debbugs.gnu.org; Wed, 23 Sep 2020 14:45:04 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1kL9lG-0006U3-VF for 43558 <at> debbugs.gnu.org; Wed, 23 Sep 2020 14:45:03 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4A33A440703; Wed, 23 Sep 2020 14:44:57 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CE53044064F; Wed, 23 Sep 2020 14:44:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600886695; bh=DuysRVMXl329iMy/ZAsjZjxyvpKdn7Dr5mMpO6KcrsA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=edxlcPOXxDkHS/oGfhsIAeZbpvCv2Pip88WPV2TCfgdusslBQao5Vo9d8fiQp0iwg JRQKODcMlYoqAjID+1LerD0VlFefQS/FETwjiDqpLSAulMzFd1khf8opiXkMdFsk13 TCFazxsWAcdc5j1qzy/ZJnTK8UF97p9Qrh0G8EC4ozFtcKthL/xzcdDp1Sq7Wfd+Qh tqW8U9ZCJ/4m0STx72f2OaXjVf5SIlfswwhkYCRH+euhuRy6G7wqyxjARaVAUIIO+9 9Vr0qQKWHy5DU+Q82htUStivJJgmY64ReNhxMWWel6+hum022iuFZS6WUm9hjvnEOr M/TGCueG6ZxLg== Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9A08A12029C; Wed, 23 Sep 2020 14:44:55 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <jwva6xgtjzd.fsf-monnier+emacs@HIDDEN> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> <20200923144824.GD6178@ACM> Date: Wed, 23 Sep 2020 14:44:54 -0400 In-Reply-To: <20200923144824.GD6178@ACM> (Alan Mackenzie's message of "Wed, 23 Sep 2020 14:48:24 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.056 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Mattias =?windows-1252?Q?Engdeg=E5rd?= <mattiase@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > It seems that as well as the existing variable > comment-end-can-be-escaped, we need a new one, say > line-comment-end-can-be-escaped, too. syntax.c doesn't like to think of it as "line-comment" but rather as comment stay a, b, c, or nested and non-nested. > In C and C++ modes, these would > be nil and t respectively. I sm-c-mode, I'd handle those corner cases in `syntax-propertize-function` (tho I think I don't bother with this one currently). So, I guess in CC-mode, you could handle those by placing `syntax-table` properties from ... wherever you place them ;-) Stefan
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 23 Sep 2020 14:48:34 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 23 10:48:34 2020 Received: from localhost ([127.0.0.1]:37450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kL64Q-0006fI-5n for submit <at> debbugs.gnu.org; Wed, 23 Sep 2020 10:48:34 -0400 Received: from colin.muc.de ([193.149.48.1]:23276 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kL64O-0006ew-3N for 43558 <at> debbugs.gnu.org; Wed, 23 Sep 2020 10:48:32 -0400 Received: (qmail 27684 invoked by uid 3782); 23 Sep 2020 14:48:24 -0000 Received: from acm.muc.de (p4fe156c4.dip0.t-ipconnect.de [79.225.86.196]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Wed, 23 Sep 2020 16:48:24 +0200 Received: (qmail 21448 invoked by uid 1000); 23 Sep 2020 14:48:24 -0000 Date: Wed, 23 Sep 2020 14:48:24 +0000 To: Mattias =?iso-8859-1?Q?Engdeg=E5rd?= <mattiase@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200923144824.GD6178@ACM> References: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Mattias. On Wed, Sep 23, 2020 at 11:01:59 +0200, Mattias Engdegård wrote: > Sorry if I misunderstood, but since when do backslashes escape */ in C? Since forever, but only in the CC Mode test suite. :-( I just tried it out with gcc, and it seems that \*/ does indeed end a block comment. But an escaped newline doesn't end a line comment, instead continuing it to the next line. So I got confused. Thanks for pointing out the mistake. It seems that as well as the existing variable comment-end-can-be-escaped, we need a new one, say line-comment-end-can-be-escaped, too. In C and C++ modes, these would be nil and t respectively. -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558) by debbugs.gnu.org; 23 Sep 2020 09:02:12 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 23 05:02:12 2020 Received: from localhost ([127.0.0.1]:34513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kL0fE-000080-2w for submit <at> debbugs.gnu.org; Wed, 23 Sep 2020 05:02:12 -0400 Received: from mail1434c50.megamailservers.eu ([91.136.14.34]:36638 helo=mail263c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mattiase@HIDDEN>) id 1kL0fB-00007g-JE for 43558 <at> debbugs.gnu.org; Wed, 23 Sep 2020 05:02:10 -0400 X-Authenticated-User: mattiase@HIDDEN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1600851723; bh=oYZ5DRGcCGCRQJGfDcbcqVDeaUSMZZHyRZqJK4rif+8=; h=From:Subject:Date:Cc:To:From; b=Exiqiz3eQPBlVw2M9SJbYGGAQosU6S4F85DV11q5SiSORc1vmWMw68Gkf0uTUwCEL 2jr2ryQXM9IZj0cEJ6+FUMQpJtIIUDV8isVDQXTQce7FWL8ReQm0pIwSx9kvxL+hko OFg/90S4M+Uiy7sLd5XkUbUrmL5R90oqxUmjwcmk= Feedback-ID: mattiase@HIDDEN Received: from stanniol.lan (c-304ee655.032-75-73746f71.bbcust.telenor.se [85.230.78.48]) (authenticated bits=0) by mail263c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08N91xoZ025746; Wed, 23 Sep 2020 09:02:01 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= <mattiase@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-Id: <DEA1EEC4-B259-48C2-B00B-30CB8799A0DB@HIDDEN> Date: Wed, 23 Sep 2020 11:01:59 +0200 To: Alan Mackenzie <acm@HIDDEN> X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F28.5F6B0F0B.0025, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=e6d4tph/ c=1 sm=1 tr=0 a=63Z2wlQ1NB3xHpgKFKE71g==:117 a=63Z2wlQ1NB3xHpgKFKE71g==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=J16QL3N0_wU3TY4Eh3EA:9 a=CjuIK1q_8ugA:10 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Sorry if I misunderstood, but since when do backslashes escape */ in C? Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 43558 Cc: 43558 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) Sorry if I misunderstood, but since when do backslashes escape */ in C?
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at 43558-done) by debbugs.gnu.org; 23 Sep 2020 08:57:57 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 23 04:57:57 2020 Received: from localhost ([127.0.0.1]:34506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kL0b7-0008Od-HN for submit <at> debbugs.gnu.org; Wed, 23 Sep 2020 04:57:57 -0400 Received: from colin.muc.de ([193.149.48.1]:64147 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kL0b3-0008OG-W2 for 43558-done <at> debbugs.gnu.org; Wed, 23 Sep 2020 04:57:56 -0400 Received: (qmail 35150 invoked by uid 3782); 23 Sep 2020 08:57:47 -0000 Received: from acm.muc.de (p4fe156c4.dip0.t-ipconnect.de [79.225.86.196]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Wed, 23 Sep 2020 10:57:46 +0200 Received: (qmail 6193 invoked by uid 1000); 23 Sep 2020 08:57:46 -0000 Date: Wed, 23 Sep 2020 08:57:46 +0000 To: 43558-done <at> debbugs.gnu.org Subject: Re: bug#43558: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200923085746.GA6178@ACM> References: <20200922093550.GA26819@ACM> <handler.43558.B.160076736116422.ack <at> debbugs.gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <handler.43558.B.160076736116422.ack <at> debbugs.gnu.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 43558-done X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Bug fixed in master. -- Alan Mackenzie (Nuremberg, Germany).
Alan Mackenzie <acm@HIDDEN>
:Alan Mackenzie <acm@HIDDEN>
:Received: (at submit) by debbugs.gnu.org; 22 Sep 2020 19:41:18 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 22 15:41:18 2020 Received: from localhost ([127.0.0.1]:33455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kKoAA-0008BX-Ge for submit <at> debbugs.gnu.org; Tue, 22 Sep 2020 15:41:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:51226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kKoA9-0008BQ-1a for submit <at> debbugs.gnu.org; Tue, 22 Sep 2020 15:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1kKoA8-0004kK-QW for bug-gnu-emacs@HIDDEN; Tue, 22 Sep 2020 15:41:16 -0400 Received: from colin.muc.de ([193.149.48.1]:40298 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1kKoA6-00033V-QT for bug-gnu-emacs@HIDDEN; Tue, 22 Sep 2020 15:41:16 -0400 Received: (qmail 77892 invoked by uid 3782); 22 Sep 2020 19:41:12 -0000 Received: from acm.muc.de (p4fe15d08.dip0.t-ipconnect.de [79.225.93.8]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Tue, 22 Sep 2020 21:41:11 +0200 Received: (qmail 1174 invoked by uid 1000); 22 Sep 2020 19:41:10 -0000 Date: Tue, 22 Sep 2020 19:41:10 +0000 To: Stefan Monnier <monnier@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200922194110.GD26819@ACM> References: <20200922093550.GA26819@ACM> <jwvd02dzyyo.fsf-monnier+emacs@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <jwvd02dzyyo.fsf-monnier+emacs@HIDDEN> X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@HIDDEN; helo=mail.muc.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 15:41:12 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.6 (--) Hello, Stefan. On Tue, Sep 22, 2020 at 10:09:43 -0400, Stefan Monnier wrote: > Hi Alan, > > Hello, Emacs and Stefan. > > In the following C comment: > > 1 /* > > 2 \*/ > > 3 /**/ > > , with point at BOL 1, do M-: (forward-comment 1). This leaves point > > wrongly at EOL 2. > That seems to be correct w.r.t the highlighting I see, OTOH. > IOW the bug seems to affect both forward-comment and parse-partial-sexp, right? Yes. > > It should end up at EOL 3, since the apparent comment > > ender on L2 is actually escaped. > > The following patch fixes this. > Does it fix it for `parse-partial-sexp` as well? It does, yes. The patch is in forw_comment, which is called by Fforward_comment, scan_lists, and scan_sexps_forward. > > Are there any objections to me installing it? > None from me, no. Thanks! > Stefan -- Alan Mackenzie (Nuremberg, Germany).
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 22 Sep 2020 14:09:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 22 10:09:52 2020 Received: from localhost ([127.0.0.1]:60984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kKizQ-0005hV-0N for submit <at> debbugs.gnu.org; Tue, 22 Sep 2020 10:09:52 -0400 Received: from lists.gnu.org ([209.51.188.17]:33316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1kKizO-0005hO-6K for submit <at> debbugs.gnu.org; Tue, 22 Sep 2020 10:09:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <monnier@HIDDEN>) id 1kKizN-0002eY-Om for bug-gnu-emacs@HIDDEN; Tue, 22 Sep 2020 10:09:50 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:43574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <monnier@HIDDEN>) id 1kKizK-0004rl-Pt for bug-gnu-emacs@HIDDEN; Tue, 22 Sep 2020 10:09:49 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BF3974406B2; Tue, 22 Sep 2020 10:09:45 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5A6BE4406AC; Tue, 22 Sep 2020 10:09:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1600783784; bh=2NMXrahPkvlH6JgIF46aFS7mzqiAxn8gXET7b9ZLmMA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=DEqonfae/QdoANIP5XChfP6HzQ6xNQh11FMgTyleRURt92YNtKzEZTQEjgY0WW5ll ZEknb0gFK+Fp+YGPyFX7pvjtm/H9YCsMAjLBJlr4psFZEJhEx/G130Gf8Rs8fhLJPt winR9tvi1Jl4mr42+3Gc4sJdGxCpweUYQY7XSSupMvskDv4G5DyAsAk0AhGrpSsDd1 x81eZ7kj1jgmiu2zNRKYz2dv5tCLlSVy0Elgo7V7qFMmGjNvwG416n4+OXqo1dB/uM F9yWmcKTWepWObE9DxBnbGiuu1cu4Yr/YqdQk59FjnBegQIf63dixRti9hRjGIRgTU /pPFQzxoyY2bA== Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 345B2120746; Tue, 22 Sep 2020 10:09:44 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Alan Mackenzie <acm@HIDDEN> Subject: Re: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <jwvd02dzyyo.fsf-monnier+emacs@HIDDEN> References: <20200922093550.GA26819@ACM> Date: Tue, 22 Sep 2020 10:09:43 -0400 In-Reply-To: <20200922093550.GA26819@ACM> (Alan Mackenzie's message of "Tue, 22 Sep 2020 09:35:50 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.056 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@HIDDEN; helo=mailscanner.iro.umontreal.ca X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 10:01:06 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) Hi Alan, > Hello, Emacs and Stefan. > > In the following C comment: > > 1 /* > 2 \*/ > 3 /**/ > > , with point at BOL 1, do M-: (forward-comment 1). This leaves point > wrongly at EOL 2. That seems to be correct w.r.t the highlighting I see, OTOH. IOW the bug seems to affect both forward-comment and parse-partial-sexp, right? > It should end up at EOL 3, since the apparent comment > ender on L2 is actually escaped. > > The following patch fixes this. Does it fix it for `parse-partial-sexp` as well? > Are there any objections to me installing it? None from me, no. Stefan
bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 22 Sep 2020 09:36:01 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 22 05:36:01 2020 Received: from localhost ([127.0.0.1]:57244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1kKeiO-0004Gn-Gz for submit <at> debbugs.gnu.org; Tue, 22 Sep 2020 05:36:01 -0400 Received: from lists.gnu.org ([209.51.188.17]:47604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <acm@HIDDEN>) id 1kKeiM-0004Gf-PY for submit <at> debbugs.gnu.org; Tue, 22 Sep 2020 05:35:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1kKeiM-0001uB-Hw for bug-gnu-emacs@HIDDEN; Tue, 22 Sep 2020 05:35:58 -0400 Received: from colin.muc.de ([193.149.48.1]:13791 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1kKeiK-0007VT-EP for bug-gnu-emacs@HIDDEN; Tue, 22 Sep 2020 05:35:58 -0400 Received: (qmail 32167 invoked by uid 3782); 22 Sep 2020 09:35:51 -0000 Received: from acm.muc.de (p4fe15d08.dip0.t-ipconnect.de [79.225.93.8]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Tue, 22 Sep 2020 11:35:50 +0200 Received: (qmail 26885 invoked by uid 1000); 22 Sep 2020 09:35:50 -0000 Date: Tue, 22 Sep 2020 09:35:50 +0000 To: bug-gnu-emacs@HIDDEN, Stefan Monnier <monnier@HIDDEN> Subject: [PATCH]: Fix (forward-comment 1) when end delimiter is escaped. Message-ID: <20200922093550.GA26819@ACM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie <acm@HIDDEN> X-Primary-Address: acm@HIDDEN Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@HIDDEN; helo=mail.muc.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 05:35:53 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.6 (--) Hello, Emacs and Stefan. In the following C comment: 1 /* 2 \*/ 3 /**/ , with point at BOL 1, do M-: (forward-comment 1). This leaves point wrongly at EOL 2. It should end up at EOL 3, since the apparent comment ender on L2 is actually escaped. The following patch fixes this. Are there any objections to me installing it? diff --git a/src/syntax.c b/src/syntax.c index e6af8a377b..066972e6d8 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -2354,6 +2354,13 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, /* We have encountered a nested comment of the same style as the comment sequence which began this comment section. */ nesting++; + if (comment_end_can_be_escaped + && (code == Sescape || code == Scharquote)) + { + inc_both (&from, &from_byte); + UPDATE_SYNTAX_TABLE_FORWARD (from); + if (from == stop) continue; /* Failure */ + } inc_both (&from, &from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); -- Alan Mackenzie (Nuremberg, Germany).
Alan Mackenzie <acm@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#43558
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.