Open Bug 443462 Opened 12 years ago Updated 5 years ago

allow alias parameters to be optional

Categories

(Other Applications :: ChatZilla, enhancement)

enhancement
Not set

Tracking

(Not tracked)

People

(Reporter: glenjamin+bmo, Assigned: rginda)

Details

Attachments

(1 file)

The current alias replacements, while pretty powerful, suffer from the restriction that only $(all) allows any numbered params to be optional.

If i recall, the original reason Gijs stated for not including this in bug 240114 was to do with optional arguments and mandatory ones with a higher number and the various problems that might arise from people trying to use such aliases.

I'd say the benefits from having this syntax would outweigh the potential misuse of such things.

I'm attaching a simple patch that adds the use of a $(n-) replacement, which is simply the optional version of $(n+).

Since writing and testing the patch it's occurred to me that it would probably be useful to make all of the existing numbered replacements have an optional version, perhaps we could do:

$(n?) $(n+?) and $(n-m?)

This may be overdoing it with syntax; whatever is decided it will of course need to be backwardly compatible with existing aliases, and not greedily eat replacements that were required before.

Any thoughts?
I would be more in favour of the ? proposal than the $(n-) one, because I don't think the syntax is very clear. It almost suggests "all the parameters up to n" to me, which is clearly not what it does. Instead, it's the same as $(n+) except it doesn't require parameter n, afaict.
What about a syntax like "$(1|text)"?  That would allow "text" to be the default value for the parameter.  "$(1|)" would let the default be an empty string.  Note special processing would be required if the default value has spaces.  For that, see also Bug 1156026.
You need to log in before you can comment on or make changes to this bug.