Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Adding the original string from completion



On Dec 5, 12:36pm, Oliver Kiddle wrote:
}
} compadd "$expl[@]" -U -Q - "$PREFIX$SUFFIX"
} 
} When called from _prefix, the result is that the suffix is lost.
} 
} The fix is to change the line to:
} 
} compadd "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" -U -Q - "$PREFIX$SUFFIX"
} 
} Only problem is if _prefix's add-space style is set. It sticks an
} additional space at the beginning of ISUFFIX.
[...]
} This amounts to trusting $words[CURRENT] to be unchanged instead of
} $ISUFFIX. If we do this, I'm inclined to factor it out into an new
} _original function though. Anyone got any better ideas?

How about this:

Have functions _prefix and _original cooperate with each other.  Before
changing $ISUFFIX, _prefix stores the original value in a local, perhaps
$_orig_isuf or some such.  Then _original uses ${_orig_isuf:-$ISUFFIX}
when constructing the compadd command.

} There is also the option of only adding original strings at the end from
} _main_complete. Given certain styles and whether menu completion if
} enabled that is.

So then _original would work sort of like _all_matches ?  That might be
a good way to go, but I'm not entirely certain.



Messages sorted by: Reverse Date, Date, Thread, Author