Subject: bug#34088: 26.1; OPascal mode some comment delimiters use the wrong face

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 22 Jan 2021 22:23:02 +0100

Tom Ient <[email-masked]> writes:

> When in OPascal mode, the left and right curly brackets (comment
> delimiters) use different faces: the left curly bracket uses the
> 'font-lock-comment-delimiter-face', while the right curly bracket uses
> the 'font-lock-comment-face'. Both curly brackets should use the
> 'font-lock-comment-delimiter-face'. For reference, Pascal mode
> highlights both curly brackets with the correct face,
> 'font-lock-comment-delimiter-face'.

(I'm going through old bug reports that unfortunately got no response at
the time.)

There was unfortunately no test case, but I took the first example of
Objective Pascal found on the internet and put into a buffer and
switched to opascal-mode:

Type
  Average = Object
    NumVal: Integer;
    Values: Array [1..200] of Real;
    Function Mean: Real; { calculates the average value of the array }
  End;

The two braces uses faces that look identical, but they are indeed
different faces.  The following patch fixes the test case, but I don't
really know Objective Pascal at all.  For reference, this is what
pascal.el says about comments:

  (setq-local comment-start "{")
  (setq-local comment-start-skip "(\\*+ *\\|{ *")
  (setq-local comment-end "}")

I've added Simon the the CCs; perhaps he has some insight here.

diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el
index 662d2b4b74..686e72ce6d 100644
--- a/lisp/progmodes/opascal.el
+++ b/lisp/progmodes/opascal.el
@@ -1766,6 +1766,7 @@ 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\\|\\*)\\|}\\)"))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no