Make abbreviation optional
authorFrank Terbeck <ft@grml.org>
Fri, 30 May 2008 12:59:34 +0000 (14:59 +0200)
committerFrank Terbeck <ft@grml.org>
Fri, 30 May 2008 12:59:34 +0000 (14:59 +0200)
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
etc/zsh/zshrc

index 4318d70..1c26a34 100644 (file)
@@ -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 <mika@grml.org>  Sat, 17 May 2008 22:53:04 +0200
+ -- Frank Terbeck <ft@grml.org>  Fri, 30 May 2008 14:56:45 +0200
 
 grml-etc-core (0.3.50) unstable; urgency=low
 
index d50f72c..23554dd 100644 (file)
@@ -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}