zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@sunsite.dk
Subject: Re: compinstall and command to add to the .zshrc
Date: Sun, 20 Aug 2006 23:50:11 +0100	[thread overview]
Message-ID: <200608202250.k7KMoBvF005758@pwslaptop.csr.com> (raw)
In-Reply-To: Message from Vincent Lefevre <vincent@vinc17.org>  of "Mon, 21 Aug 2006 00:19:49 +0200." <20060820221949.GC690@prunille.vinc17.org>

Vincent Lefevre wrote:
> After running compinstall, I get:
> 
> Enter file to save in (~ will be expanded), or return to abort:
> file> .zcomp
> If you want this file to be run automatically, you should add
>   . .zcomp
> to your .zshrc.  compinstall will remember the name of this file for
> future use.
> 
> But the zshbuiltins(1) man page says that the shell looks in the
> components of $path to find the directory containing the file.
> So, I don't see how this can work, unless ~ is in $path, and it
> usually isn't. Shouldn't compinstall have said ". ~/.zcomp"?

We discussed this and it's because the user entered a relative path.
The following is supposed to intercept that.  I haven't tried every
combination.

Index: Completion/compinstall
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/compinstall,v
retrieving revision 1.9
diff -u -r1.9 compinstall
--- Completion/compinstall	23 Nov 2005 11:29:21 -0000	1.9
+++ Completion/compinstall	20 Aug 2006 22:47:57 -0000
@@ -109,15 +109,23 @@
   return
 fi
 
-
 local newifile=$ifile
 if [[ $foundold = true ]]; then
-  print "I have found completion definitions in $ifile.
+  if [[ $newifile != [~/]* ]]; then
+    newifile=${ZDOTDIR:-~}/$newifile
+    print "[Existing completion definition file is not absolute path:
+updating to $newifile]"
+  fi
+  print "I have found completion definitions in $newifile.
 If you want me to read these, just hit return.  Otherwise, edit the file
 name to look for definitions somewhere else, or delete the whole line
 in order not to use existing definitions."
   vared -ch -p 'file> ' newifile
-  [[ -z $newifile ]] && foundold=false
+  if [[ -n $newifile && $newifile != [/~]* ]]; then
+    newifile=$PWD/$newifile
+    print "[Not absolute path: updating to $newifile]"
+  fi
+  [[ -z $newifile || ! -f $newfile ]] && foundold=false
 else
   print "I haven't found any existing completion definitions.
 If you have some already defined by compinstall, edit the name of the
@@ -126,6 +134,10 @@
 the line as it is, or empty, I won't search."
   while true;  do
     vared -ch -p 'file> ' newifile || break
+    if [[ -n $newifile && $newifile != [/~]* ]]; then
+      newifile=$PWD/$newifile
+      print "[Not absolute path: updating to $newifile]"
+    fi
     if [[ -n $newifile && $ifile != $newifile ]]; then
       if __ci_test_ifile $newifile; then
         foundold=true
@@ -138,7 +150,7 @@
     fi
   done
 fi
-ifile=$newifile
+ifile=${~newifile}
 
 if [[ $foundold = true ]]; then
   sed -n "/^[ 	]*$startline/,/^[ 	]*$endline/p" $ifile |
@@ -1926,6 +1938,10 @@
    print "Enter file to save in (~ will be expanded), or return to abort:"
    ifile=
    vared -ch -p 'file> ' ifile
+   if [[ $ifile != [/~]* ]]; then
+     ifile=$PWD/$ifile
+     print "[Not absolute path; updating to $ifile]"
+   fi
    ifile=${~ifile}
 fi
 
-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2006-08-20 22:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <vincent@vinc17.org>
2006-08-20 22:19 ` Vincent Lefevre
2006-08-20 22:50   ` Peter Stephenson [this message]
2006-05-03 15:25 Vincent Lefevre

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=200608202250.k7KMoBvF005758@pwslaptop.csr.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@sunsite.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).