[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] lisp/progmodes/etags.el don't (forward-char) as it's ove

From: Konstantin Kharlamov
Subject: Re: [PATCH 2/3] lisp/progmodes/etags.el don't (forward-char) as it's overriden next line
Date: Mon, 18 Mar 2019 12:57:25 +0300

On Пн, Mar 18, 2019 at 12:43:16, Konstantin Kharlamov <address@hidden> wrote:

On Пн, Mar 18, 2019 at 06:34:00, Eli Zaretskii <address@hidden> wrote:
 Date: Sun, 17 Mar 2019 23:44:28 +0300
 From: Konstantin Kharlamov <address@hidden>
 Cc: address@hidden

 > But that's incorrect: a tag in a tags table always begins at the
> beginning of a line, so it must be a search anchored at the beginning > of the line. And in selective-display mode ^M counts as the beginning
 > of a line.

Great, now that we established that part, to reply your question why we don't care about the beginnging of the line let me quote my other mail:

  > The pattern that this functions searches for determines the tag
uniquely. But here's a catch: no programming language creates distinc entities (ones that end up in the tag), based only on trailing space.
 I.e. "foo()" and " foo() " always refer to the same thing.

I'm not talking about whitespace. I'm talking about a tags table file
that names a symbol 'foobar', say.  If you search for a tag "bar" and
do not anchor the search at the beginning of a line, you will decide
that "bar" is present on the "foobar" line, although it really isn't.

Not exactly. Here's an alternative bad situation: let's say you do anchor the text, and you search for tag 'foo'. And… you still match 'foobar'!

Actually, it's interesting, that such name clashes are possible right now: let's say we have:

        #define FOO
        #define FOO_BAR

If source code is intact, you should get FOO. But if code changed, then emacs tries to find where did it go, and may as well stumble upon FOO_BAR.

So, I suggest an improvement to my patch: how about we

1. anchor the regexp to the end of the line also
2. replace trailing space with "any whitespace" regex '\s-*'


To be clear: I suggest that we keep anchoring to the beginning of a line in place, add anchoring to the end of line, and replace trailing whitespace with "any whitespace" regex.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]