emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: PC-do-completion with directories adding stars.]


From: Michael Cadilhac
Subject: Re: address@hidden: PC-do-completion with directories adding stars.]
Date: Mon, 06 Mar 2006 21:18:25 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>>    When I try it, I don't get that.  Instead I just see "[Ambiguous dir 
>> name]"
>>    appended to the minibuffer for 2 seconds.
>
>> Then you must have a subdirectory of ~/ starting with `a'.
>
> No, that wasn't it.  It turns out the difference is that my shell is zsh.
> If I set SHELL to bash I can now reproduce your description.
>
> This happens to illustrate what I said earlier:
>> ... Of course, this part of the code is difficult to get right because it
>> uses an underlying shell to do the globbing ...
>
> I'll see if I can find a good fix for it,

  What about the following for PC-do-completion ?

  This patch fixes a minor issue with files containing spaces in their
  name, too. [1]

  However, I don't see what would be a « good fix » for the general
  completion function (not the PC one).

*** complete.el 2006-03-06 21:07:38.000000000 +0100
--- complete.el 2006-03-06 21:06:33.000000000 +0100
***************
*** 1,7 ****
  ;;; complete.el --- partial completion mechanism plus other goodies
  
  ;; Copyright (C) 1990, 1991, 1992, 1993, 1999, 2000, 2002, 2003, 2004,
! ;;   2005 Free Software Foundation, Inc.
  
  ;; Author: Dave Gillespie <address@hidden>
  ;; Keywords: abbrev convenience
--- 1,7 ----
  ;;; complete.el --- partial completion mechanism plus other goodies
  
  ;; Copyright (C) 1990, 1991, 1992, 1993, 1999, 2000, 2002, 2003, 2004,
! ;;   2005, 2006 Free Software Foundation, Inc.
  
  ;; Author: Dave Gillespie <address@hidden>
  ;; Keywords: abbrev convenience
***************
*** 767,783 ****
    (save-excursion
      (set-buffer (generate-new-buffer " *Glob Output*"))
      (erase-buffer)
!     (shell-command (concat "echo " name) t)
      (goto-char (point-min))
!     (if (looking-at ".*No match")
        nil
        (insert "(\"")
!       (while (search-forward " " nil t)
        (delete-backward-char 1)
        (insert "\" \""))
!       (goto-char (point-max))
!       (delete-backward-char 1)
!       (insert "\")")
        (goto-char (point-min))
        (let ((files (read (current-buffer))) (p nil))
        (kill-buffer (current-buffer))
--- 767,783 ----
    (save-excursion
      (set-buffer (generate-new-buffer " *Glob Output*"))
      (erase-buffer)
!     (shell-command (concat "for f in " name "; do test -e \"$f\" && echo 
\"$f\"; done") t)
      (goto-char (point-min))
!     (if (looking-at "\\($\\|.*No match\\)")
        nil
        (insert "(\"")
!       (setq goal-column 0)
!       (while (= (forward-line 1) 0)
        (delete-backward-char 1)
        (insert "\" \""))
!       (delete-backward-char 2)
!       (insert ")")
        (goto-char (point-min))
        (let ((files (read (current-buffer))) (p nil))
        (kill-buffer (current-buffer))

  Note that  the for loop  has to  check « test  -e » because  of this
  standard sh behavior :

  $ for f in /a*/b*/c*/d*; echo $f; done
  /a*/b*/c*/d*
  $ 


Footnotes: 
[1]  Example :

cd /tmp ; mkdir test; touch test/'this is a test'
C-x C-f /tmp/tes/this <TAB> : Ambigous dir name

with the patch

C-x C-f /tmp/tes/this <TAB> rightly turns into « /tmp/test/this is a test »

-- 
    Michael Cadilhac, a.k.a. Micha [mika] |
                    Epita/LRDE promo 2007 |   )\._.,--....,'``.
123 av. de Fontainebleau | 08.70.65.13.14 |  /.  _.. \   _\  (` ._,.
94270 Le Kremlin Bicetre | 06.23.20.31.30 | '._.-(,_..'--(,_...`-..'

Attachment: pgpEHaJgKi89y.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]