[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 17a950c: Fix comment end delimiter fontification in OPascal m
From: |
Stefan Monnier |
Subject: |
Re: master 17a950c: Fix comment end delimiter fontification in OPascal mode |
Date: |
Tue, 11 May 2021 13:20:30 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Lars Ingebrigtsen [2021-05-11 18:32:44] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> 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\\|\\*)\\|}\\)"))