From 47c440aa2a141b1af60c2df192ff257b902dd177 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 7 Apr 2014 09:58:30 +0100 Subject: 32527: zcalc-auto-insert key binding for use in zcalc --- Functions/Misc/zcalc | 3 +++ Functions/Zle/zcalc-auto-insert | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 Functions/Zle/zcalc-auto-insert (limited to 'Functions') diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index b79644687..63f67adb0 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -96,6 +96,9 @@ emulate -L zsh setopt extendedglob +# For testing in ZLE functions. +local ZCALC_ACTIVE=1 + # TODO: make local variables that shouldn't be visible in expressions # begin with _. local line ans base defbase forms match mbegin mend psvar optlist opt arg diff --git a/Functions/Zle/zcalc-auto-insert b/Functions/Zle/zcalc-auto-insert new file mode 100644 index 000000000..c9a5c8867 --- /dev/null +++ b/Functions/Zle/zcalc-auto-insert @@ -0,0 +1,8 @@ +# Bind to a binary operator keystroke for use with zcalc + +if [[ -n $ZCALC_ACTIVE ]]; then + if [[ $CURSOR -eq 0 || $LBUFFER[-1] = "(" ]]; then + LBUFFER+=${ZCALC_AUTO_INSERT_PREFIX:-"ans "} + fi +fi +zle .self-insert -- cgit 1.4.1 From 08d4a6136e5c289d1be6d6290568866c2d59ef53 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 7 Apr 2014 09:59:35 +0100 Subject: addition to 32527: also update .distfiles --- Functions/Zle/.distfiles | 1 + 1 file changed, 1 insertion(+) (limited to 'Functions') diff --git a/Functions/Zle/.distfiles b/Functions/Zle/.distfiles index 5b301b62b..b43476032 100644 --- a/Functions/Zle/.distfiles +++ b/Functions/Zle/.distfiles @@ -44,5 +44,6 @@ up-case-word-match up-line-or-beginning-search url-quote-magic which-command +zcalc-auto-insert zed-set-file-name ' -- cgit 1.4.1