GNU bug report logs - #60397
29.0.60; c++-ts-mode could report better defun names

Previous Next

Package: emacs;

Reported by: Knut Anders Hatlen <kahatlen <at> gmail.com>

Date: Thu, 29 Dec 2022 07:43:02 UTC

Severity: normal

Found in version 29.0.60

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 60397 <at> debbugs.gnu.org (full text, mbox):

From: Knut Anders Hatlen <kahatlen <at> gmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 60397 <at> debbugs.gnu.org
Subject: Re: bug#60397: 29.0.60; c++-ts-mode could report better defun names
Date: Sun, 08 Jan 2023 08:05:30 +0100
Yuan Fu <casouri <at> gmail.com> writes:

> Knut Anders Hatlen <kahatlen <at> gmail.com> writes:
>
>> The defun names reported by c++-ts-mode could still need a couple of
>> improvements:
>>
>> 1) In a buffer with c++-ts-mode and which-function-mode enabled, and
>> this content:
>>
>> struct S {
>>   int f1(int x) {
>>     return x + 1;
>>   }
>>   int g1(int x);
>> };
>>
>> int S::g1(int x) {
>>   return x + 1;
>> }
>>
>> Inside the inline f1 function definition, which-function-mode shows
>> "S.f1". But inside the out-of-line g1 function definition, it shows
>> "n/a" instead of "S.g1". (Not limited to structs. Classes have the same
>> problem.)
>
> Now the second function is displayed as S::g1.

Looks good now. Classes seem to be handled fine too.

>> 2) Namespaces are not handled. Given this content:
>>
>> namespace n {
>> int f1(int x) {
>>   return x + 1;
>> }
>> }
>>
>> namespace {
>> int f2(int x) {
>>   return x + 1;
>> }
>> }
>>
>> Inside the f1 and f2 function bodies, which-function-mode shows "f1" and
>> "f2", respectively. It would be better if it showed "n.f1" for the
>> former, and perhaps something like "(anonymous).f2" for the latter.
>
> Now the first function is shown as n.f1, the second is shown as f2.
> Making it (anonymous).f2 isn’t necessarily better than f2 IMO, and
> requires some non-trivial change to the current code, so I didn’t do it.

Fair enough. Thanks!

-- 
Knut Anders




This bug report was last modified 2 years and 122 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.