Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Word break characters are language dependent
@ 2003-09-18 19:16 Joel Brobecker
  2003-09-21 12:32 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2003-09-18 19:16 UTC (permalink / raw)
  To: gdb-patches

Hello,

I was working on implementing proper completion for Ada in GDB, and
ended up reading this part of the code (completer.c:localtion_completer()):

      else if (strchr (gdb_completer_word_break_characters, *p))
        symbol_start = p + 1;

Unfortunately, the word-break characters for Ada are not exactly the
same as the ones used by default.  As a consequence, the current
completer does not always find the correct starting location of the
symbol name.  So I think we should make them language-dependent by
adding a new field to the language vector.

For instance, we could add a new pointer to a function that would
return the string of word-break characters.

My proposal is the following:

  - Add the following field to struct language_defn:

    char * (*la_word_break_characters) (const char *);

  - Move static char *gdb_completer_word_break_characters and
    get_gdb_completer_word_break_characters() to language.[hc]
    and call them: default_completer_word_break_characters
    and get_default_completer_word_break_characters() respectively.

  - Initialize the new field inside all languages to this
    default function.

  - Update completer.c to use the language-dependent version
    of this string, rather than the current hard-coded one.

Sounds reasonable?

Also, while we are looking at this, would it be worth considering
the same for 
  - gdb_completer_command_word_break_characters: I don't think so.
    Command names are independent of the language.
  - gdb_completer_file_name_break_characters: I don't think so either.
    Independent from the filename.
  - gdb_completer_loc_break_characters: Likewise.
  - gdb_completer_quote_characters: This is less obvious. Maybe some
    future language will want to have it's own different quote character.
    Not obvious, so I would leave it as is too.

Thanks,
-- 
Joel


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

* Re: [RFC] Word break characters are language dependent
  2003-09-18 19:16 [RFC] Word break characters are language dependent Joel Brobecker
@ 2003-09-21 12:32 ` Eli Zaretskii
  2003-09-21 21:43   ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2003-09-21 12:32 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Date: Thu, 18 Sep 2003 12:16:41 -0700
> From: Joel Brobecker <brobecker@gnat.com>
> 
> I was working on implementing proper completion for Ada in GDB, and
> ended up reading this part of the code (completer.c:localtion_completer()):
> 
>       else if (strchr (gdb_completer_word_break_characters, *p))
>         symbol_start = p + 1;
> 
> Unfortunately, the word-break characters for Ada are not exactly the
> same as the ones used by default.  As a consequence, the current
> completer does not always find the correct starting location of the
> symbol name.  So I think we should make them language-dependent by
> adding a new field to the language vector.

Did you actually try to replace the hard-coded string with a different
one that is good for Ada, and see if that solves your problem?

I'm asking because I have a vague memory of things being
not-quite-that-simple in that part of the code, since readline's
interface with customized completers is--how should I put it?--less
than optimal.

So I think before we discuss the design of a possible solution, we
should be sure that it is in fact a solution ;-)

Other than that, I think your general idea is correct and the proposed
direction is reasonable.


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

* Re: [RFC] Word break characters are language dependent
  2003-09-21 12:32 ` Eli Zaretskii
@ 2003-09-21 21:43   ` Joel Brobecker
  2003-09-22  5:14     ` Eli Zaretskii
  2003-09-22  7:24     ` Andrew Cagney
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Brobecker @ 2003-09-21 21:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

> > Unfortunately, the word-break characters for Ada are not exactly the
> > same as the ones used by default.  As a consequence, the current
> > completer does not always find the correct starting location of the
> > symbol name.  So I think we should make them language-dependent by
> > adding a new field to the language vector.
> 
> Did you actually try to replace the hard-coded string with a different
> one that is good for Ada, and see if that solves your problem?

Yes :).

What I actually did while waiting for the opinion of the maintainers
and developpers was to make our Ada version of this string non-static,
and changed gdb_get_completer_word_break_character() return the ada
string if the current_language was ada. I then used that function
in place of the string itself in the one location where I detected
the problem.

> So I think before we discuss the design of a possible solution, we
> should be sure that it is in fact a solution ;-)

Right! :-) That reminds me of a collegue in my previous job that often
came to the chif software architect with grand designs, some of them
almost extravagant. And this architect will always smile while asking
the same question after the presentation: "Are you sure it works?".
And this collegue would smile back and always say the same: "Yes,
because I implemented it" :-).

In this particular case, I didn't actually implement what I am
suggesting. I just did a hack, a prototype if you like, that proves
that it should work well.

> Other than that, I think your general idea is correct and the proposed
> direction is reasonable.

Thanks for your input, it is much appreciated. I'll wait for another
week to see if I can get more feedback, and then will try to work on
a patch.

-- 
Joel


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

* Re: [RFC] Word break characters are language dependent
  2003-09-21 21:43   ` Joel Brobecker
@ 2003-09-22  5:14     ` Eli Zaretskii
  2003-09-23 18:35       ` Joel Brobecker
  2003-09-22  7:24     ` Andrew Cagney
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2003-09-22  5:14 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Date: Sun, 21 Sep 2003 14:43:23 -0700
> From: Joel Brobecker <brobecker@gnat.com>
> > 
> > Did you actually try to replace the hard-coded string with a different
> > one that is good for Ada, and see if that solves your problem?
> 
> Yes :).

Okay, that's good to know.

There are two different ways into the completion code, though: one is
when you type some of the beginning characters and hit TAB, the other
one is when you type Meta-TAB (ESC-TAB on some systems, Alt-TAB on
others).  Did you try both of them?  (IIRC, readline does different
things depending on which of these two keys you type.)


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

* Re: [RFC] Word break characters are language dependent
  2003-09-21 21:43   ` Joel Brobecker
  2003-09-22  5:14     ` Eli Zaretskii
@ 2003-09-22  7:24     ` Andrew Cagney
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Cagney @ 2003-09-22  7:24 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Eli Zaretskii, gdb-patches

> Other than that, I think your general idea is correct and the proposed
>> direction is reasonable.
> 
> 
> Thanks for your input, it is much appreciated. I'll wait for another
> week to see if I can get more feedback, and then will try to work on
> a patch.

You mean: This whole idea of language sensative tab-expansion, while 
sensible, makes my brain hurt :-)




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

* Re: [RFC] Word break characters are language dependent
  2003-09-22  5:14     ` Eli Zaretskii
@ 2003-09-23 18:35       ` Joel Brobecker
  2003-09-24  5:34         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2003-09-23 18:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

> There are two different ways into the completion code, though: one is
> when you type some of the beginning characters and hit TAB, the other
> one is when you type Meta-TAB (ESC-TAB on some systems, Alt-TAB on
> others).  Did you try both of them?  (IIRC, readline does different
> things depending on which of these two keys you type.)

Did you mean "M-*" (which I just learnt about by reading the
documention)? "M-Tab" doesn't seem to work, even on a RH's stock
GDB, and I can't seem to find documentation for it.

However, "M-*" worked beautifully, inserting all possible completions.

-- 
Joel


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

* Re: [RFC] Word break characters are language dependent
  2003-09-23 18:35       ` Joel Brobecker
@ 2003-09-24  5:34         ` Eli Zaretskii
  2003-09-24 18:13           ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2003-09-24  5:34 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Date: Tue, 23 Sep 2003 11:34:58 -0700
> From: Joel Brobecker <brobecker@gnat.com>
> 
> Did you mean "M-*" (which I just learnt about by reading the
> documention)? "M-Tab" doesn't seem to work, even on a RH's stock
> GDB, and I can't seem to find documentation for it.
> 
> However, "M-*" worked beautifully, inserting all possible completions.

Sorry, I meant "M-?".


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

* Re: [RFC] Word break characters are language dependent
  2003-09-24  5:34         ` Eli Zaretskii
@ 2003-09-24 18:13           ` Joel Brobecker
  0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2003-09-24 18:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

> > However, "M-*" worked beautifully, inserting all possible completions.
> 
> Sorry, I meant "M-?".

Ah, sorry, I forgot to say in my previous message that I also tried
"M-?" and that it was working fine. Let me start sending the patches
when I have a minute.

-- 
Joel


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

end of thread, other threads:[~2003-09-24 18:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-18 19:16 [RFC] Word break characters are language dependent Joel Brobecker
2003-09-21 12:32 ` Eli Zaretskii
2003-09-21 21:43   ` Joel Brobecker
2003-09-22  5:14     ` Eli Zaretskii
2003-09-23 18:35       ` Joel Brobecker
2003-09-24  5:34         ` Eli Zaretskii
2003-09-24 18:13           ` Joel Brobecker
2003-09-22  7:24     ` Andrew Cagney

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