unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christophe TROESTLER <Christophe.TROESTLER@umons.ac.be>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: rust-ts-mode: appropriately fontify doc strings
Date: Sat, 2 Dec 2023 00:59:52 +0000	[thread overview]
Message-ID: <878r6dqv07.fsf@poincare.umons.ac.be> (raw)
In-Reply-To: <cf277ceb-5ac5-c6f8-6151-6e6671a37f49@gutov.dev> (Dmitry Gutov's message of "Sat, 2 Dec 2023 01:58:36 +0200")

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

On  2 December 2023 at 00:58 +01, Dmitry Gutov <dmitry@gutov.dev> wrote:
> […] I've pushed it to emacs-29. In the future, please send patches to
> the bug tracker, though (then it's easier to ensure they are not
> lost).

It seems my latest message has not reached the mailing list... (it ia attached).  I'll use the bug tracker from now on — for some reason, I was under the impression that Emacs patches should be sent first to Emacs devel.

Best,
C.



[-- Attachment #2: Type: message/rfc822, Size: 14965 bytes --]

[-- Attachment #2.1.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.1.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


  reply	other threads:[~2023-12-02  0:59 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
2023-12-01 23:58     ` Dmitry Gutov
2023-12-02  0:59       ` Christophe TROESTLER [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878r6dqv07.fsf@poincare.umons.ac.be \
    --to=christophe.troestler@umons.ac.be \
    --cc=dmitry@gutov.dev \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).