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

Re: Defining function based on alias



Peter Stephenson wrote on Sun, Jan 08, 2017 at 19:19:22 +0000:
> +++ b/Src/input.c
> @@ -670,3 +670,22 @@ ingetptr(void)
>  {
>      return inbufptr;
>  }
> +
> +/**/
> +char *input_hasalias(void)

May we please have docstrings for new code?  E.g.,

/*
 * If the input at the top of the stack(?) is an alias, return the name of
 * that alias, otherwise return NULL.
 */

Gave this a quick spin with various aliases and global aliases; behaves
as I'd expect.

My main concern is that .zshrc files that contain such a bug will not be
sourced all the way through.  Add a README entry?

Thanks,

Daniel

> +{
> +    int flags = inbufflags;
> +    struct instacks *instackptr = instacktop;
> +
> +    for (;;)
> +    {
> +	if (!(flags & INP_CONT))
> +	    break;
> +	instackptr--;
> +	if (instackptr->alias)
> +	    return instackptr->alias->node.nam;
> +	flags = instackptr->flags;
> +    }
> +
> +    return NULL;
> +}



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