Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Difficulty with the readline completion interface in GDB
@ 2004-01-18 22:49 Daniel Jacobowitz
  2004-01-19  6:14 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-01-18 22:49 UTC (permalink / raw)
  To: bug-readline; +Cc: gdb

Hi Chet,

I've spent this morning trying to fix a long-standing bug in GDB's tab
completion.  I think it's unsolvable with the current readline interface, so
I'd like your suggestions on how to improve the situation.

The gist of the problem is that different parts of the command line have
different word break characters.  For example, '/' is a word break character
after a command or a symbol, but not after a directory name.  There's no way
to explain this to Readline.  Right now, we do a lot of fudging
rl_completer_word_break_chars, but it's never quite in time.  As a result,
we get this chain of events:

  - rl_completer_word_break_chars contains '/' and '.'
  - The user enters "file ./gdb.base<TAB>"
  - GDB's complete_line is called from rl_complete.  The text parameter
    is "base", because . was treated as a word separator.
  - We return, and readline stats the file to figure out whether to add
    a slash after it.  It stats "base", having lost the "./gdb.".  Stat
    fails.
  - A space is inserted instead of the slash (gdb.base is a directory).

There's a lot of possible solutions.  There could be a hook called before
rl_complete generates the matches list, which could fudge the complete
characters - most direct solution, not very elegant.  A function could be
called to get the list of complete characters, which would then be sensitive
to rl_point - not sure what other issues this could cause.  The filename
completion code could search backwards according to the list of filename
wordbreak characters; this would solve the specific problem but not the
more general one.  Probably there are others.

What do you think?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

* Re: Difficulty with the readline completion interface in GDB
  2004-01-18 22:49 Difficulty with the readline completion interface in GDB Daniel Jacobowitz
@ 2004-01-19  6:14 ` Eli Zaretskii
  2004-01-28 20:09   ` Chet Ramey
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2004-01-19  6:14 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: bug-readline, gdb

> Date: Sun, 18 Jan 2004 17:49:29 -0500
> From: Daniel Jacobowitz <drow@mvista.com>
> 
> I've spent this morning trying to fix a long-standing bug in GDB's tab
> completion.  I think it's unsolvable with the current readline interface

Agreed.  This has come up before on GDB mailing lists, see, for example:

   http://sources.redhat.com/ml/gdb/2001-09/msg00247.html

> There's a lot of possible solutions.  There could be a hook called before
> rl_complete generates the matches list, which could fudge the complete
> characters - most direct solution, not very elegant.  A function could be
> called to get the list of complete characters, which would then be sensitive
> to rl_point - not sure what other issues this could cause.  The filename
> completion code could search backwards according to the list of filename
> wordbreak characters; this would solve the specific problem but not the
> more general one.  Probably there are others.

I think the first solution is the easiest one and will do the job.

The two others need to teach GDB functions dealing with completion too
much context, which they are currently oblivious about.  For example,
the back-search method in the last proposal is not easy since you not
always know where to stop the search (e.g., imagine a GDB command that
has 2 file-name arguments, or the "foo.c:bar" case).  It's not so hard
to scan forward from some place, but much harder to scan backward.

What is inelegant in the first solution you suggested, Daniel?


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

* Re: Difficulty with the readline completion interface in GDB
  2004-01-19  6:14 ` Eli Zaretskii
@ 2004-01-28 20:09   ` Chet Ramey
  2004-01-28 20:17     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Chet Ramey @ 2004-01-28 20:09 UTC (permalink / raw)
  To: eliz; +Cc: drow, bug-readline, gdb, chet

> > There's a lot of possible solutions.  There could be a hook called before
> > rl_complete generates the matches list, which could fudge the complete
> > characters - most direct solution, not very elegant.  A function could be
> > called to get the list of complete characters, which would then be sensitive
> > to rl_point - not sure what other issues this could cause.  The filename
> > completion code could search backwards according to the list of filename
> > wordbreak characters; this would solve the specific problem but not the
> > more general one.  Probably there are others.
> 
> I think the first solution is the easiest one and will do the job.

I added the hook:  char *(*rl_completion_word_break_hook)(void)

The completion code sets the word break characters from this function's
return value, defaulting to rl_completer_word_break_characters if it is
unset or returns NULL.

This will be in bash-3.0/readline-5.0.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
						Live...Laugh...Love
Chet Ramey, ITS, CWRU    chet@po.cwru.edu    http://tiswww.tis.cwru.edu/~chet/


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

* Re: Difficulty with the readline completion interface in GDB
  2004-01-28 20:09   ` Chet Ramey
@ 2004-01-28 20:17     ` Daniel Jacobowitz
  2004-01-29 23:33       ` Elena Zannoni
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2004-01-28 20:17 UTC (permalink / raw)
  To: chet; +Cc: eliz, bug-readline, gdb

On Wed, Jan 28, 2004 at 03:04:29PM -0500, Chet Ramey wrote:
> > > There's a lot of possible solutions.  There could be a hook called before
> > > rl_complete generates the matches list, which could fudge the complete
> > > characters - most direct solution, not very elegant.  A function could be
> > > called to get the list of complete characters, which would then be sensitive
> > > to rl_point - not sure what other issues this could cause.  The filename
> > > completion code could search backwards according to the list of filename
> > > wordbreak characters; this would solve the specific problem but not the
> > > more general one.  Probably there are others.
> > 
> > I think the first solution is the easiest one and will do the job.
> 
> I added the hook:  char *(*rl_completion_word_break_hook)(void)
> 
> The completion code sets the word break characters from this function's
> return value, defaulting to rl_completer_word_break_characters if it is
> unset or returns NULL.
> 
> This will be in bash-3.0/readline-5.0.

Great, thank you!  Would you mind posting the patch for this feature,
so that I can merge it into the version of readline we are currently
using?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

* Re: Difficulty with the readline completion interface in GDB
  2004-01-28 20:17     ` Daniel Jacobowitz
@ 2004-01-29 23:33       ` Elena Zannoni
  0 siblings, 0 replies; 5+ messages in thread
From: Elena Zannoni @ 2004-01-29 23:33 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: chet, eliz, bug-readline, gdb

Daniel Jacobowitz writes:
 > On Wed, Jan 28, 2004 at 03:04:29PM -0500, Chet Ramey wrote:
 > > > > There's a lot of possible solutions.  There could be a hook called before
 > > > > rl_complete generates the matches list, which could fudge the complete
 > > > > characters - most direct solution, not very elegant.  A function could be
 > > > > called to get the list of complete characters, which would then be sensitive
 > > > > to rl_point - not sure what other issues this could cause.  The filename
 > > > > completion code could search backwards according to the list of filename
 > > > > wordbreak characters; this would solve the specific problem but not the
 > > > > more general one.  Probably there are others.
 > > > 
 > > > I think the first solution is the easiest one and will do the job.
 > > 
 > > I added the hook:  char *(*rl_completion_word_break_hook)(void)
 > > 
 > > The completion code sets the word break characters from this function's
 > > return value, defaulting to rl_completer_word_break_characters if it is
 > > unset or returns NULL.
 > > 
 > > This will be in bash-3.0/readline-5.0.
 > 
 > Great, thank you!  Would you mind posting the patch for this feature,
 > so that I can merge it into the version of readline we are currently
 > using?

Can this be made part of the official set of readline-4.3 patches? It
would be easier to keep track of.

thanks
elena


 > 
 > -- 
 > Daniel Jacobowitz
 > MontaVista Software                         Debian GNU/Linux Developer


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

end of thread, other threads:[~2004-01-29 23:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-18 22:49 Difficulty with the readline completion interface in GDB Daniel Jacobowitz
2004-01-19  6:14 ` Eli Zaretskii
2004-01-28 20:09   ` Chet Ramey
2004-01-28 20:17     ` Daniel Jacobowitz
2004-01-29 23:33       ` Elena Zannoni

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