From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 17a950c: Fix comment end delimiter fontification in OPascal mode Date: Tue, 11 May 2021 13:20:30 -0400 Message-ID: References: <20210511135237.14950.6701@vcs0.savannah.gnu.org> <20210511135238.D80A321128@vcs0.savannah.gnu.org> <87r1idkz83.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33726"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 11 19:24:21 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgW7I-0008eQ-D7 for ged-emacs-devel@m.gmane-mx.org; Tue, 11 May 2021 19:24:20 +0200 Original-Received: from localhost ([::1]:40726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgW7H-000282-Ba for ged-emacs-devel@m.gmane-mx.org; Tue, 11 May 2021 13:24:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgW3j-00078a-Rt for emacs-devel@gnu.org; Tue, 11 May 2021 13:20:41 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgW3e-0000XN-5g for emacs-devel@gnu.org; Tue, 11 May 2021 13:20:39 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id EE7A8100216; Tue, 11 May 2021 13:20:32 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 10165100068; Tue, 11 May 2021 13:20:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1620753631; bh=dmyusTD/bjzyXMR7oRlKDnLT9ZD6ldhIRvTIUtVMNWQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=H3LyliOh5pahrH5t3w3JOgeHl8FFxZxUwDuT7oZ9Gf/yRjN7YDrSYfU1qVGhOu4BJ TZ+bC7gzTwairMX0vtqfLnwN+eVwBA0WdaMRH2r8Juv31N1gKS/mhnwz9PZLvN/ZNj 2zQha8wAO4VP5Uxri2LsOWri8pqqd2t6BCGz1qiqIjwUIHmJy1ZLkMtmHcryUyGTA0 4GzMPMYWTevQsEY8dA8nCB8IL++y18lPXr4CkbeTpcTqz1HajMbZB6DeBk3RYNn23l qJ/Dmejk2ziIYkoYObKmsXAo/dDiLQfs1lAU86uSE495LNmE5GwOVrsPYiKrY3F7F6 vxQlKjrI/LgOA== Original-Received: from alfajor (76-10-140-76.dsl.teksavvy.com [76.10.140.76]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D5A16120246; Tue, 11 May 2021 13:20:30 -0400 (EDT) In-Reply-To: <87r1idkz83.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 11 May 2021 18:32:44 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca 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-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269170 Archived-At: Lars Ingebrigtsen [2021-05-11 18:32:44] wrote: > Stefan Monnier writes: >> OPascal supports many different kinds of comment syntaxes, but //...} is >> not one of them, AFAIK. > The plethora of comment/start/end variables may be confusing me, but > here's what we get in opascal-mode after that change: But `M-;` won't behave correctly. Also your change didn't fix the case of (* other comment *) I suspect you need to set `font-lock-comment-end-skip`, tho I think the real problem is that `font-lock.el` should use `comment-end-skip` rather than `comment-end` as a fallback for `font-lock-comment-end-skip`. So I pushed the patch below. Stefan diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 82915d8c8b0..4dc42d9cf6a 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1604,18 +1604,15 @@ font-lock-comment-start-skip "If non-nil, Font Lock mode uses this instead of `comment-start-skip'.") (defvar font-lock-comment-end-skip nil - "If non-nil, Font Lock mode uses this instead of `comment-end'.") + "If non-nil, Font Lock mode uses this instead of `comment-end-skip'.") (defun font-lock-fontify-syntactically-region (start end &optional loudly) "Put proper face on each string and comment between START and END. START should be at the beginning of a line." (syntax-propertize end) ; Apply any needed syntax-table properties. (with-syntax-table (or syntax-ppss-table (syntax-table)) - (let ((comment-end-regexp - (or font-lock-comment-end-skip - (regexp-quote - (replace-regexp-in-string "^ *" "" comment-end)))) - ;; Find the `start' state. + (when (and comment-start (not comment-end-skip)) (comment-normalize-vars)) + (let (;; Find the `start' state. (state (if (or syntax-ppss-table (not font-lock--syntax-table-affects-ppss)) (syntax-ppss start) @@ -1648,7 +1645,9 @@ font-lock-fontify-syntactically-region comment-start-skip)) (put-text-property beg (match-end 0) 'face font-lock-comment-delimiter-face))) - (if (looking-back comment-end-regexp (point-at-bol) t) + (if (looking-back (or font-lock-comment-end-skip + comment-end-skip) + (point-at-bol) t) (put-text-property (match-beginning 0) (point) 'face font-lock-comment-delimiter-face)))) (< (point) end)) diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el index 686e72ce6dd..662d2b4b74f 100644 --- a/lisp/progmodes/opascal.el +++ b/lisp/progmodes/opascal.el @@ -1766,7 +1766,6 @@ opascal-mode (setq-local syntax-propertize-function opascal--syntax-propertize) (setq-local comment-start "// ") - (setq-local comment-end "}") (setq-local comment-start-skip "\\(?://\\|(\\*\\|{\\)[ \t]*") (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*)\\|}\\)"))