unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60441: [PATCH] Fontification of function declarators with reference return types is incorrect in c++-ts-mode
       [not found] <m14jtc8kg9.fsf.ref@yahoo.es>
@ 2022-12-31  0:51 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-02  0:26   ` Yuan Fu
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-31  0:51 UTC (permalink / raw)
  To: 60441

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


Given the following valid C++ code:

class Foo {
public:
        Bar& getBar();
};

c++-ts-mode does not fontify getBar with the
font-lock-function-name-face face.

I've attached a fix to treat reference declarators in
c-ts-mode--declarator-identifier similarly to pointer_declarators.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-fontification-of-C-functions-with-reference-retu.patch --]
[-- Type: text/x-patch, Size: 1159 bytes --]

From 19182746e53ca66dc94aea4a7cd91f67cc7e0aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sat, 31 Dec 2022 01:45:27 +0100
Subject: [PATCH] Fix fontification of C++ functions with reference return
 types

* lisp/progmodes/c-ts-mode.el (c-ts-fontify-error): Treat
reference_declarator nodes the same as pointer_declarator nodes when
calculating the identifier to fontify.
---
 lisp/progmodes/c-ts-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 82a13e9762..3cb671f4c5 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -425,7 +425,7 @@ c-ts-mode--declarator-identifier
     ;; Recurse.
     ((or "attributed_declarator" "parenthesized_declarator")
      (c-ts-mode--declarator-identifier (treesit-node-child node 0 t)))
-    ("pointer_declarator"
+    ((or "pointer_declarator" "reference_declarator")
      (c-ts-mode--declarator-identifier (treesit-node-child node -1)))
     ((or "function_declarator" "array_declarator" "init_declarator")
      (c-ts-mode--declarator-identifier
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#60441: [PATCH] Fontification of function declarators with reference return types is incorrect in c++-ts-mode
  2022-12-31  0:51 ` bug#60441: [PATCH] Fontification of function declarators with reference return types is incorrect in c++-ts-mode Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-02  0:26   ` Yuan Fu
  0 siblings, 0 replies; 2+ messages in thread
From: Yuan Fu @ 2023-01-02  0:26 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 60441-done


Daniel Martín <mardani29@yahoo.es> writes:

> Given the following valid C++ code:
>
> class Foo {
> public:
>         Bar& getBar();
> };
>
> c++-ts-mode does not fontify getBar with the
> font-lock-function-name-face face.
>
> I've attached a fix to treat reference declarators in
> c-ts-mode--declarator-identifier similarly to pointer_declarators.

Applied, thanks!

Yuan





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-02  0:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m14jtc8kg9.fsf.ref@yahoo.es>
2022-12-31  0:51 ` bug#60441: [PATCH] Fontification of function declarators with reference return types is incorrect in c++-ts-mode Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-02  0:26   ` Yuan Fu

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).