From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
To: Emacs-devel <emacs-devel@gnu.org>
Subject: Re: rust-ts-mode: appropriately fontify doc strings
Date: Fri, 1 Dec 2023 21:38:37 +0000 [thread overview]
Message-ID: <87jzpxr4bn.fsf@poincare.umons.ac.be> (raw)
In-Reply-To: <87il5is524.fsf@poincare.umons.ac.be> (Christophe TROESTLER's message of "Fri, 1 Dec 2023 08:25:08 +0000")
[-- Attachment #1: Type: text/plain, Size: 90 bytes --]
Hi,
A slightly updated patch (to encompass create level doc comments).
Best,
C.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-rust-ts-mode-appropriately-fontify-doc-strings.patch --]
[-- Type: text/x-diff; name="0001-rust-ts-mode-appropriately-fontify-doc-strings.patch", Size: 1707 bytes --]
From a5a6c31060962c976d7476da631a325c251a272d Mon Sep 17 00:00:00 2001
From: Christophe Troestler <Christophe.Troestler@umons.ac.be>
Date: Thu, 30 Nov 2023 00:13:10 +0100
Subject: [PATCH] rust-ts-mode: appropriately fontify doc strings
Content-Type: text/plain; charset="utf-8"
---
lisp/progmodes/rust-ts-mode.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 88344934e49..0e24b09bbbb 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -153,7 +153,7 @@ rust-ts-mode--font-lock-settings
:language 'rust
:feature 'comment
- '(([(block_comment) (line_comment)]) @font-lock-comment-face)
+ '(([(block_comment) (line_comment)]) @rust-ts-mode--comment-docstring)
:language 'rust
:feature 'delimiter
@@ -293,6 +293,17 @@ rust-ts-mode--font-lock-settings
'((ERROR) @font-lock-warning-face))
"Tree-sitter font-lock settings for `rust-ts-mode'.")
+(defun rust-ts-mode--comment-docstring (node override start end &rest _args)
+ "Use the comment or documentation face appropriately for comments."
+ (let* ((beg (treesit-node-start node))
+ (end (treesit-node-end node))
+ (face (save-excursion
+ (goto-char beg)
+ (if (looking-at "//\\(?:/\\|!\\)")
+ 'font-lock-doc-face
+ 'font-lock-comment-face))))
+ (treesit-fontify-with-override beg end face override start end)))
+
(defun rust-ts-mode--fontify-scope (node override start end &optional tail-p)
(let* ((case-fold-search nil)
(face
--
2.42.0
next prev parent reply other threads:[~2023-12-01 21:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 23:21 rust-ts-mode: appropriately fontify doc strings Christophe TROESTLER
2023-12-01 0:50 ` Dmitry Gutov
2023-12-01 8:25 ` Christophe TROESTLER
2023-12-01 21:38 ` Christophe TROESTLER [this message]
2023-12-01 23:58 ` Dmitry Gutov
2023-12-02 0:59 ` Christophe TROESTLER
2023-12-02 3:41 ` Yuan Fu
2023-12-02 7:55 ` Eli Zaretskii
2023-12-02 10:40 ` Christophe TROESTLER
2023-12-02 17:04 ` Dmitry Gutov
2023-12-02 20:57 ` Christophe TROESTLER
2023-12-03 14:12 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jzpxr4bn.fsf@poincare.umons.ac.be \
--to=christophe.troestler@umons.ac.be \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.