From 0e6200b2a9f73f42fbd89a014a33a18f2b857752 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Fri, 30 May 2008 14:59:34 +0200 Subject: [PATCH] Make abbreviation optional The ',.' global abbreviation replacement feature is meant. It is still on by default, but can be disabled by default by setting $NOABBREVIATION to something greater than zero in .zshenv; or temporarily by hitting '^xA', which switches it off (another '^xA' will reenable it - that way, we can still get it back on, if disabled by $NOABBREVIATION). Note: Turning off abbreviation effectively disables the feature. The binding to ',.' still remains, though. Therefore, entering a comma (,) will still take a few moments (because zsh is waiting for a possible ',.'). If you cannot be bothered to wait that long, quickly hit CTRL-V before hitting the comma key. I briefly looked for a better binding for the feature; but most (all?) of the easy-to-remember ones (like ALT-a, ALT-, or ALT-.) where already taken. Others didn't produce a useful character sequence on my keyboard (like CTRL-, or CTRL.); and I don't want '^xA' for it, because that takes four(!) key presses. If someone has a better solution, please say so! --- debian/changelog | 3 ++- etc/zsh/zshrc | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4318d70..1c26a34 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ grml-etc-core (0.3.51) unstable; urgency=low [ Frank Terbeck ] * zshrc: Add persistent dirstack support for shells older than 4.2.0 + * zshrc: Make ',.' abbreviation optional [Closes: issue445] [ Michael Prokop ] * zshrc: @@ -10,7 +11,7 @@ grml-etc-core (0.3.51) unstable; urgency=low - Support .deb in show-archive() [via harnir] * zshenv: set $PATH on Solaris/SunOS. - -- Michael Prokop Sat, 17 May 2008 22:53:04 +0200 + -- Frank Terbeck Fri, 30 May 2008 14:56:45 +0200 grml-etc-core (0.3.50) unstable; urgency=low diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index d50f72c..23554dd 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -502,6 +502,24 @@ bindkey '^Xi' insert-unicode-char # bindkey . rationalise-dot # bindkey '\eq' push-line-or-edit + +## toggle the ,. abbreviation feature on/off +# NOABBREVIATION: default abbreviation-state +# 0 - enabled (default) +# 1 - disabled +NOABBREVIATION=${NOABBREVIATION:-0} + +grml_toggle_abbrev() { + if (( ${NOABBREVIATION} > 0 )) ; then + NOABBREVIATION=0 + else + NOABBREVIATION=1 + fi +} + +zle -N grml_toggle_abbrev +bindkey '^xA' grml_toggle_abbrev + # }}} # a generic accept-line wrapper {{{ @@ -729,6 +747,12 @@ abk=( globalias() { local MATCH + + if (( NOABBREVIATION > 0 )) ; then + LBUFFER="${LBUFFER},." + return 0 + fi + matched_chars='[.-|_a-zA-Z0-9]#' LBUFFER=${LBUFFER%%(#m)[.-|_a-zA-Z0-9]#} LBUFFER+=${abk[$MATCH]:-$MATCH} -- 2.1.4