[PATCH 1 of 1] bash_completion: complete aliases

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Mon May 16 17:08:13 CDT 2011


Matt, All,

On Friday 13 May 2011 01:56:05 Matt Mackall wrote:
> On Thu, 2011-05-12 at 00:14 +0200, Yann E. MORIN wrote:
> > bash_completion: complete aliases
> 
> The right way to do this is with HGPLAINEXCEPT:
> http://www.selenic.com/hg/rev/9f97de157aad

OK, I've had a look, and it does not look straightforward to me. :-/

> Step 1: make it easy to check for exceptions, eg:
>  if not ui.plain(): -> if not ui.plain("feature"):

You mean, changing the API of ui.plain() from taking no arg, to (optionally)
taking the name of a feature to test for?

What I understand from ui.plain() so far is that it returns either True
or False, or the list of features that do not cause plain mode. In that
latter case, it's up to the caller to check if the particular feature it
is interested in is in the list ui.plain() returns. Right?

And your suggestion is to change that, and have ui.plain() check the feature
on behalf of the caller, and always return either True or False, with:
- False if HGPLAIN is not set or the requested feature is in HGPLAINEXCEPT
- True otherwise.

Is that what you are suggesting?

> Step 2: teach the alias code to check for an exception

I found no 'alias code', but in ui.readconfig():
    if self.plain():
        [...]
        for k, v in cfg.items('alias'):
            del cfg['alias'][k]

If I understand correctly, the above loop should be moved out of the 'if'
block, and into its own:
    if self.plain("alias")
        for k, v in cfg.items('alias'):
            del cfg['alias'][k]

Sorry if I sound stupid here. I'm a bit clueless...

> Step 3: teach completion to use it

OK, that I understood! :-)

Anyway, tentative patches will follow later. Thanks!

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the Mercurial-devel mailing list