From: Noah Peart <noah.v.peart@gmail.com>
To: 70465@debbugs.gnu.org
Subject: bug#70465: [PATCH] Add font-locking rule for Rust function signatures
Date: Thu, 18 Apr 2024 19:01:57 -0700 [thread overview]
Message-ID: <CAPVBTSdpnpJKEYXckLMCoigPEdsZN+C3zLnYVN35C_3zZ768Dg@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 929 bytes --]
Tags: patch
Adds a rule to font-lock Rust function signatures and missing function
modifier "default" to rust-ts-mode--keywords.
The new rule adds font-locking to signatures as in the following
example:
trait Foo {
fn foo() -> String;
// ^ font-lock-function-name-face
}
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2024-04-18 built on noah-X580VD
Repository revision: 0a57dfcff8d0abcf4427cfbfd886264bb3b8eaab
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.4 LTS
Configured using:
'configure --prefix=/usr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
CXX=gcc-12'
[-- Attachment #1.2: Type: text/html, Size: 1080 bytes --]
[-- Attachment #2: 0001-Add-font-locking-rule-for-Rust-function-signatures.patch --]
[-- Type: text/x-patch, Size: 1634 bytes --]
From 1cce696ed89abe9fc3be5ea77b83c38e55c8a714 Mon Sep 17 00:00:00 2001
From: Noah Peart <noah.v.peart@gmail.com>
Date: Thu, 18 Apr 2024 18:52:06 -0700
Subject: [PATCH] Add font-locking rule for Rust function signatures
* lisp/progmodes/rust-ts-mode.el
(rust-ts-mode--font-lock-settings): Add font-lock rule for Rust
function signatures and missing function modifier keyword 'default'.
---
lisp/progmodes/rust-ts-mode.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 7112ceced57..92978db64af 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -129,7 +129,7 @@ rust-ts-mode--builtin-macros
"Rust built-in macros for tree-sitter font-locking.")
(defvar rust-ts-mode--keywords
- '("as" "async" "await" "break" "const" "continue" "dyn" "else"
+ '("as" "async" "await" "break" "const" "continue" "default" "dyn" "else"
"enum" "extern" "fn" "for" "if" "impl" "in" "let" "loop" "match"
"mod" "move" "pub" "ref" "return" "static" "struct" "trait" "type"
"union" "unsafe" "use" "where" "while" (crate) (self) (super)
@@ -176,6 +176,7 @@ rust-ts-mode--font-lock-settings
:language 'rust
:feature 'definition
'((function_item name: (identifier) @font-lock-function-name-face)
+ (function_signature_item name: (identifier) @font-lock-function-name-face)
(macro_definition "macro_rules!" @font-lock-constant-face)
(macro_definition (identifier) @font-lock-preprocessor-face)
(field_declaration name: (field_identifier) @font-lock-property-name-face)
--
2.34.1
next reply other threads:[~2024-04-19 2:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 2:01 Noah Peart [this message]
2024-04-19 7:24 ` bug#70465: [PATCH] Add font-locking rule for Rust function signatures Yuan Fu
2024-04-19 10:47 ` Eli Zaretskii
2024-04-19 16:47 ` Noah Peart
2024-04-19 17:35 ` Eli Zaretskii
2024-04-19 17:43 ` Noah Peart
2024-04-22 0:03 ` Yuan Fu
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=CAPVBTSdpnpJKEYXckLMCoigPEdsZN+C3zLnYVN35C_3zZ768Dg@mail.gmail.com \
--to=noah.v.peart@gmail.com \
--cc=70465@debbugs.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.