zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: "Zsh hackers list" <zsh-workers@sunsite.auc.dk>
Subject: Re: New completion - redefine widgets instead of rebinding keys RE: pws-22
Date: Fri, 18 Jun 1999 16:55:11 +0200	[thread overview]
Message-ID: <9906181455.AA20655@ibmth.df.unipi.it> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Wed, 16 Jun 1999 17:42:42 DFT." <9906161542.AA12356@ibmth.df.unipi.it>

Peter Stephenson wrote:
> "Andrej Borsenkow" wrote:
> > Since I've never seen any reply to this, I repeat it here.
> > 
> > My suggestion was, that instead of rebinding keys (as is done currently) we
> > should simply redefine corresponding widgets.
> 
> This certainly looks like a good idea.

I haven't had a problem with this, so here's the diff.  compdef uses the
`.' form of the completion widgets, though after the patch I sent that's no
longer necessary.  Now binding completion keys before or after compinit and
in any keymap will work transparently.

--- Completion/Core/compinit	Wed Jun  9 09:28:57 1999
+++ /home/user2/pws/bin/comp/compinit	Wed Jun 16 18:02:06 1999
@@ -215,7 +215,11 @@
       fi
 
       # Define the widget.
-      zle -C "$func" "$1" "$func"
+      if [[ $1 = .* ]]; then
+	zle -C "$func" "$1" "$func"
+      else
+	zle -C "$func" ".$1" "$func"
+      fi
       shift
 
       # And bind the keys...
@@ -335,6 +339,14 @@
   fi
 fi
 
+
+# Rebind the standard widgets
+for _i_line in complete-word delete-char-or-list expand-or-complete \
+  expand-or-complete-prefix list-choices menu-complete \
+  menu-expand-or-complete reverse-menu-complete; do
+  zle -C $_i_line .$_i_line _main_complete
+done
+
 _i_done=''
 
 # If we have a dump file, load it.
@@ -368,23 +380,6 @@
       esac
     done
   done
-
-  bindkey |
-    while read -rA _i_line; do
-      case "$_i_line[2]" in
-      (complete-word) ;&
-      (delete-char-or-list) ;&
-      (expand-or-complete) ;&
-      (expand-or-complete-prefix) ;&
-      (list-choices) ;&
-      (menu-complete) ;&
-      (menu-expand-or-complete) ;&
-      (reverse-menu-complete)
-	zle -C _complete_$_i_line[2] $_i_line[2] _main_complete
-	bindkey "${_i_line[1][2,-2]}" _complete_$_i_line[2]
-	;;
-      esac
-    done
 
   unset _i_dir _i_line _i_file _i_tag
 
--- Completion/Core/compdump	Wed Jun  9 09:28:56 1999
+++ /home/user2/pws/bin/comp/compdump	Wed Jun 16 18:03:08 1999
@@ -44,11 +44,13 @@
 # Now dump the key bindings. We dump all bindings for zle widgets
 # whose names start with a underscore.
 # We need both the zle -C's and the bindkey's to recreate.
+# We can ignore any zle -C which rebinds a standard widget (second
+# argument to zle does not begin with a `_').
 
 _d_bks=()
 zle -lL |
   while read -rA _d_line; do
-    if [[ ${_d_line[5]} = _* ]]; then
+    if [[ ${_d_line[3]} = _* && ${_d_line[5]} = _* ]]; then
       print -r - ${_d_line}
       _d_bks=($_d_bks ${_d_line[3]})
     fi
--- Doc/Zsh/compsys.yo.bak	Thu Jun 17 14:01:38 1999
+++ Doc/Zsh/compsys.yo	Fri Jun 18 16:53:11 1999
@@ -59,6 +59,8 @@
 start and finish), you can rerun tt(compinstall) and it will correctly
 locate and modify these lines.  Note, however, that any code you add to
 this section by hand is likely to be lost if you rerun tt(compinstall).
+The new code will take effect next time you start the shell, or run
+tt(.zshrc) by hand.
 
 You can run it as `tt(source )var(<path>)tt(/compinstall)' or
 `tt(. )var(<path>)tt(/compinstall)', where var(<path>) is where the
@@ -72,6 +74,11 @@
 
 You can abort the installation any time you are being prompted for
 information, and your tt(.zshrc) will not be altered at all.
+
+After initialization all the builtin completion widgets such as
+tt(expand-or-complete) will be redefined to use the new completion system.
+Should you need to, you can still bind keys to the old functions by putting
+a `tt(.)' in front, e.g. `tt(.expand-or-complete)'.
 
 subsect(Use of compinit)
 

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  parent reply	other threads:[~1999-06-18 15:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-15  9:15 pws-22 Peter Stephenson
1999-06-15 10:10 ` pws-22 Helmut Jarausch
1999-06-15 15:23 ` New completion - redefine widgets instead of rebinding keys pws-22 Andrej Borsenkow
1999-06-16 15:42   ` Peter Stephenson
1999-06-16 16:14     ` PATCH: pws-22: zle -C after rebinding completion widgets Peter Stephenson
1999-06-18 14:55     ` Peter Stephenson [this message]
1999-06-15 15:40 ` Modules and function install RE: pws-22 Andrej Borsenkow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9906181455.AA20655@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).