Subject: bug#79258: closed (Re: bug#79258: [PATCH] Face-ify all comment delimiters in 'lua-ts-mode')

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 30 Aug 2025 08:33:02 +0000

Your bug report

#79258: [PATCH] Face-ify all comment delimiters in 'lua-ts-mode'

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
79258: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79258
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#79258: [PATCH] Face-ify all comment delimiters in 'lua-ts-mode'
From: Eli Zaretskii <[email-masked]>
To: john muhl <[email-masked]>
Cc: [email-masked]
Date: Sat, 30 Aug 2025 11:32:36 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: john muhl <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 23 Aug 2025 11:32:48 -0500
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> From: john muhl <[email-masked]>
> >> Date: Sat, 16 Aug 2025 15:43:56 -0500
> >> 
> >> Add font-lock-comment-delimiter face to all the initial dashes in single
> >> line comments. Some popular documentation styles recommend triple dashes
> >> and it looks better to have all the dashes in the same face.
> >
> > Thanks, but shouldn't the code which moves point be in save-excursion
> > in this case?  If not, why not?
> 
> I thought the font-lock machinery took care of it. If I followed
> the code correctly then we eventually end up in
> font-lock-default-fontify-syntactically which uses save-excursion.
> 
> Checking the position of point at the beginning of
> lua-ts--comment-font-lock shows that it has already been moved (to
> the end of the line/comment) before there is any chance to call
> save-excursion from here so the position it would restore isn’t
> where the user has the point at anyway.

Thanks, now installed on the master branch, and closing the bug.

Subject: [PATCH] Face-ify all comment delimiters in 'lua-ts-mode'
From: john muhl <[email-masked]>
To: [email-masked]
Date: Sat, 16 Aug 2025 15:43:56 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Add font-lock-comment-delimiter face to all the initial dashes in single
line comments. Some popular documentation styles recommend triple dashes
and it looks better to have all the dashes in the same face.

>From 06671f6cb239f1807b934eb189e771b9737856aa Mon Sep 17 00:00:00 2001
From: john muhl <[email-masked]>
Date: Wed, 14 May 2025 08:53:42 -0500
Subject: [PATCH] Face-ify all comment delimiters in 'lua-ts-mode'

* lisp/progmodes/lua-ts-mode.el (lua-ts--comment-font-lock):
Apply 'font-lock-comment-delimiter-face' to the entire span of
initial dashes.  In particular, this improves the appearance of
LuaCATS and EmmyLua style annotations which use "---".
* test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua:
Add tests.
---
 lisp/progmodes/lua-ts-mode.el                           | 7 +++++--
 test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index 07a8f0aef55..c51c7e7aef8 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -168,10 +168,13 @@ lua-ts--comment-font-lock
   (let* ((node-start (treesit-node-start node))
          (node-end (treesit-node-end node))
          (node-text (treesit-node-text node t))
-         (delimiter-end (+ 2 node-start)))
+         (delimiter-end (progn
+                          (goto-char node-start)
+                          (while (looking-at-p "-") (forward-char))
+                          (point))))
     (when (and (>= node-start start)
                (<= delimiter-end end)
-               (string-match "\\`--" node-text))
+               (string-match "\\`---*" node-text))
       (treesit-fontify-with-override node-start
                                      delimiter-end
                                      'font-lock-comment-delimiter-face
diff --git a/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua b/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
index 93d589e3825..5a36bcad10b 100644
--- a/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
+++ b/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
@@ -11,6 +11,11 @@ Multi-line comment
 -- <- font-lock-comment-face
 local line_comment = "comment" -- comment
 --                                ^ font-lock-comment-face
+---@alias MyNumber integer
+-- <- font-lock-comment-delimiter-face
+------Calculate new number
+-- ^ font-lock-comment-delimiter-face
+function calc() end
 
 -- Definition
 local function f1() end
-- 
2.50.1