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

Re: the function to show a digit argument while it is being typed



On Nov 11,  3:22am, Mikael Magnusson wrote:
}
} I have a similar function, it doesn't work well for negative arguments
} though:
}
} function _digit_argument () {
}   zle -M "$NUMERIC$KEYS[-1]"
}   zle .digit-argument
} }

Hmm, that suggests yet another possible improvement to my function.  I
assumed $NUMERIC was updated too late to use it in PREDISPLAY, but it
is updated in time to be used in place of my __digit_arg global.

    function digit-argument-show {
      if [[ $LASTWIDGET == neg-argument ]]
      then PREDISPLAY="(arg: $((NUMERIC*$KEYS[-1]))) "
      else PREDISPLAY="(arg: $NUMERIC$KEYS[-1]) "
      fi
      zle -R
      zle .digit-argument
      zle read-command
      [[ $REPLY != digit-argument ]] && PREDISPLAY=""
      zle -U $KEYS
    }

With this, you don't need the neg-argument-show function at all, and
assignments to PREDISPLAY can be replaced with zle -M if you like.



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