Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH v2] scripts: Have make TAGS not include structure members
@ 2026-05-27 16:11 Steven Rostedt
  2026-05-27 16:29 ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2026-05-27 16:11 UTC (permalink / raw)
  To: LKML, Linux trace kernel, linux-kbuild
  Cc: Andrew Morton, Masahiro Yamada, Masatake YAMATO, Peter Zijlstra,
	Geert Uytterhoeven, Michal Marek, Yang Bai, Stephen Boyd

From: Steven Rostedt <rostedt@goodmis.org>

It is really annoying when I use emacs TAGS to search for something
like "dev_name" and have to go through 12 iterations before I find the
function "dev_name". I really do not care about structures that include
"dev_name" as one of its fields, and I'm sure pretty much all other
developers do not care either.

There's a "remove_structs" variable used by the scripts/tags.sh, which
I'm guessing is suppose to remove these structures from the TAGS file,
but it must do a poor job at it, as I'm always hitting structures when
I want the actual declaration.

Luckily, the etags program comes with an option "--no-members", which does
exactly what I want, and I'm sure all other kernel developers want too.

Create a new "no_members" variable and assign it to "--no-members" for the
"TAGS" case and pass that to the etags program to remove structures.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
Changes since v1: https://lore.kernel.org/all/20131115093645.6dc03918@gandalf.local.home/

- Use a no_members variable instead of hard coding the --no-members into
  the etags call, as that can break some "tags" cases. (Michal Marek)

- Rebase to the current decade. Yes, v1 is from 2013. I've been carrying
  this patch in my personal repos as a quilt entry where I would just push
  it when doing a "make TAGS". I also have the conversation still in my
  INBOX to remind me to send a v2. Talk about procrastination! It only
  took me 13 years to send the v2 :-p

  I'm still keeping the same Cc's. I wonder how many of them will be
  broken. :-/

 scripts/tags.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index 243373683f98..018588014eed 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -305,7 +305,7 @@ exuberant()
 emacs()
 {
 	setup_regex emacs asm c
-	all_target_sources | xargs $1 -a "${regex[@]}"
+	all_target_sources | xargs $1 -a $no_members "${regex[@]}"
 
 	setup_regex emacs kconfig
 	all_kconfigs | xargs $1 -a "${regex[@]}"
@@ -334,6 +334,7 @@ if [ "${ARCH}" = "um" ]; then
 fi
 
 remove_structs=
+no_members=
 case "$1" in
 	"cscope")
 		docscope
@@ -353,6 +354,7 @@ case "$1" in
 		rm -f TAGS
 		xtags etags
 		remove_structs=y
+		no_members=--no-members
 		;;
 esac
 
-- 
2.53.0


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

* Re: [PATCH v2] scripts: Have make TAGS not include structure members
  2026-05-27 16:11 [PATCH v2] scripts: Have make TAGS not include structure members Steven Rostedt
@ 2026-05-27 16:29 ` Peter Zijlstra
  2026-05-27 16:31   ` [PATCH v2] scripts: Have make TAGS not include structure members' Peter Zijlstra
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Peter Zijlstra @ 2026-05-27 16:29 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux trace kernel, linux-kbuild, Andrew Morton,
	Masahiro Yamada, Masatake YAMATO, Geert Uytterhoeven,
	Michal Marek, Yang Bai, Stephen Boyd

On Wed, May 27, 2026 at 12:11:44PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
> 
> It is really annoying when I use emacs TAGS to search for something
> like "dev_name" and have to go through 12 iterations before I find the
> function "dev_name". I really do not care about structures that include
> "dev_name" as one of its fields, and I'm sure pretty much all other
> developers do not care either.
> 
> There's a "remove_structs" variable used by the scripts/tags.sh, which
> I'm guessing is suppose to remove these structures from the TAGS file,
> but it must do a poor job at it, as I'm always hitting structures when
> I want the actual declaration.
> 
> Luckily, the etags program comes with an option "--no-members", which does
> exactly what I want, and I'm sure all other kernel developers want too.
> 
> Create a new "no_members" variable and assign it to "--no-members" for the
> "TAGS" case and pass that to the etags program to remove structures.
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> Changes since v1: https://lore.kernel.org/all/20131115093645.6dc03918@gandalf.local.home/
> 
> - Use a no_members variable instead of hard coding the --no-members into
>   the etags call, as that can break some "tags" cases. (Michal Marek)

Yeah, I often use member tags.

The tags file have a 'kind' field, what you want is for emacs to order
on kind and prefer 'f' over 'm'.

The alternative is switching to use emacs-lsp, that way the editor knows
the kind of symbol you want. If you're on a function call, it should
only consider 'f' tags. Whereas if the cursor is on a member deref, it
should only consider 'm'.

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

* Re: [PATCH v2] scripts: Have make TAGS not include structure members'
  2026-05-27 16:29 ` Peter Zijlstra
@ 2026-05-27 16:31   ` Peter Zijlstra
  2026-05-27 18:47   ` [PATCH v2] scripts: Have make TAGS not include structure members Steven Rostedt
  2026-05-27 19:36   ` Masatake YAMATO
  2 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2026-05-27 16:31 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux trace kernel, linux-kbuild, Andrew Morton,
	Masahiro Yamada, Masatake YAMATO, Geert Uytterhoeven,
	Michal Marek, Yang Bai, Stephen Boyd

On Wed, May 27, 2026 at 06:29:14PM +0200, Peter Zijlstra wrote:
> On Wed, May 27, 2026 at 12:11:44PM -0400, Steven Rostedt wrote:
> > From: Steven Rostedt <rostedt@goodmis.org>
> > 
> > It is really annoying when I use emacs TAGS to search for something
> > like "dev_name" and have to go through 12 iterations before I find the
> > function "dev_name". I really do not care about structures that include
> > "dev_name" as one of its fields, and I'm sure pretty much all other
> > developers do not care either.
> > 
> > There's a "remove_structs" variable used by the scripts/tags.sh, which
> > I'm guessing is suppose to remove these structures from the TAGS file,
> > but it must do a poor job at it, as I'm always hitting structures when
> > I want the actual declaration.
> > 
> > Luckily, the etags program comes with an option "--no-members", which does
> > exactly what I want, and I'm sure all other kernel developers want too.
> > 
> > Create a new "no_members" variable and assign it to "--no-members" for the
> > "TAGS" case and pass that to the etags program to remove structures.
> > 
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > ---
> > Changes since v1: https://lore.kernel.org/all/20131115093645.6dc03918@gandalf.local.home/
> > 
> > - Use a no_members variable instead of hard coding the --no-members into
> >   the etags call, as that can break some "tags" cases. (Michal Marek)
> 
> Yeah, I often use member tags.
> 
> The tags file have a 'kind' field, what you want is for emacs to order
> on kind and prefer 'f' over 'm'.
> 
> The alternative is switching to use emacs-lsp, that way the editor knows
> the kind of symbol you want. If you're on a function call, it should
> only consider 'f' tags. Whereas if the cursor is on a member deref, it
> should only consider 'm'.

That said, setting up clangd on the kernel tree is rather more painful
that I'd like it to be :-(

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

* Re: [PATCH v2] scripts: Have make TAGS not include structure members
  2026-05-27 16:29 ` Peter Zijlstra
  2026-05-27 16:31   ` [PATCH v2] scripts: Have make TAGS not include structure members' Peter Zijlstra
@ 2026-05-27 18:47   ` Steven Rostedt
  2026-05-27 19:36   ` Masatake YAMATO
  2 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2026-05-27 18:47 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: LKML, Linux trace kernel, linux-kbuild, Andrew Morton,
	Masahiro Yamada, Masatake YAMATO, Geert Uytterhoeven,
	Michal Marek, Yang Bai

On Wed, 27 May 2026 18:29:14 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> Yeah, I often use member tags.
> 
> The tags file have a 'kind' field, what you want is for emacs to order
> on kind and prefer 'f' over 'm'.
> 
> The alternative is switching to use emacs-lsp, that way the editor knows
> the kind of symbol you want. If you're on a function call, it should
> only consider 'f' tags. Whereas if the cursor is on a member deref, it
> should only consider 'm'.

OK, so in addition to my procrastination of sending out this patch, I
finally changed my .emacs file to have "Meta-." call
xref-find-definitions instead of find-tags.

The xref-find-definitions gives a list of all the tags it finds and you
can search for the function. In the example of "dev_name", I simply
searched for "dev_name(" and it found the function immediately.

As "find-tags" has been deprecated back in 2016 (10 years ago!), and
xref-find-definitions doesn't suffer as much as 'find-tags' does with
respect to member tags. I'll simply drop this patch.

I can also finally archive the conversation I have in my INBOX! ;-)

-- Steve

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

* Re: [PATCH v2] scripts: Have make TAGS not include structure members
  2026-05-27 16:29 ` Peter Zijlstra
  2026-05-27 16:31   ` [PATCH v2] scripts: Have make TAGS not include structure members' Peter Zijlstra
  2026-05-27 18:47   ` [PATCH v2] scripts: Have make TAGS not include structure members Steven Rostedt
@ 2026-05-27 19:36   ` Masatake YAMATO
  2 siblings, 0 replies; 5+ messages in thread
From: Masatake YAMATO @ 2026-05-27 19:36 UTC (permalink / raw)
  To: peterz
  Cc: rostedt, linux-kernel, linux-trace-kernel, linux-kbuild, akpm,
	masahiroy, geert, mmarek, hamo.by, sboyd

From: Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v2] scripts: Have make TAGS not include structure members
Date: Wed, 27 May 2026 18:29:14 +0200

> On Wed, May 27, 2026 at 12:11:44PM -0400, Steven Rostedt wrote:
>> From: Steven Rostedt <rostedt@goodmis.org>
>> 
>> It is really annoying when I use emacs TAGS to search for something
>> like "dev_name" and have to go through 12 iterations before I find the
>> function "dev_name". I really do not care about structures that include
>> "dev_name" as one of its fields, and I'm sure pretty much all other
>> developers do not care either.
>> 
>> There's a "remove_structs" variable used by the scripts/tags.sh, which
>> I'm guessing is suppose to remove these structures from the TAGS file,
>> but it must do a poor job at it, as I'm always hitting structures when
>> I want the actual declaration.
>> 
>> Luckily, the etags program comes with an option "--no-members", which does
>> exactly what I want, and I'm sure all other kernel developers want too.
>> 
>> Create a new "no_members" variable and assign it to "--no-members" for the
>> "TAGS" case and pass that to the etags program to remove structures.
>> 
>> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
>> ---
>> Changes since v1: https://lore.kernel.org/all/20131115093645.6dc03918@gandalf.local.home/
>> 
>> - Use a no_members variable instead of hard coding the --no-members into
>>   the etags call, as that can break some "tags" cases. (Michal Marek)
> 
> Yeah, I often use member tags.
> 
> The tags file have a 'kind' field, what you want is for emacs to order
> on kind and prefer 'f' over 'm'.

citre (https://github.com/universal-ctags/citre) utilizes the kinds field
of tags file when soriting the list of definitions. citre runs on emacs.

https://github.com/universal-ctags/citre/blob/master/citre-lang-c.el#L28 explains
the parts of heuristics used in citre:

;; - When the symbol is after "->" or ".", tags of member kind are sorted above
;;   others.
;; - When the symbol is before "(", tags of function/macro kinds are sorted
;;   above others.
;; - When the cursor is on the header file in a "#include" directive, the
;;   header file itself, and the references to that header file (if tagged) is
;;   found as its definitions.  References that uses paths can't be found.
;;   Also, file names will be used for auto-completion.

I use citre and ctags daily for reading kernel code. Quite comfortable.

Masatake YAMATO

> 
> The alternative is switching to use emacs-lsp, that way the editor knows
> the kind of symbol you want. If you're on a function call, it should
> only consider 'f' tags. Whereas if the cursor is on a member deref, it
> should only consider 'm'.
> 


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

end of thread, other threads:[~2026-05-27 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 16:11 [PATCH v2] scripts: Have make TAGS not include structure members Steven Rostedt
2026-05-27 16:29 ` Peter Zijlstra
2026-05-27 16:31   ` [PATCH v2] scripts: Have make TAGS not include structure members' Peter Zijlstra
2026-05-27 18:47   ` [PATCH v2] scripts: Have make TAGS not include structure members Steven Rostedt
2026-05-27 19:36   ` Masatake YAMATO

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox