unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Cadilhac <michael.cadilhac@lrde.org>
Cc: eliz@gnu.org, Luc Teirlinck <teirllm@dms.auburn.edu>,
	rms@gnu.org, emacs-devel@gnu.org
Subject: Re: [michael.cadilhac@lrde.org: PC-do-completion with directories adding stars.]
Date: Mon, 06 Mar 2006 21:18:25 +0100	[thread overview]
Message-ID: <87u0abqqcu.fsf@mahaena.lrde> (raw)
In-Reply-To: <jwv7j77h14k.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 06 Mar 2006 13:38:45 -0500")


[-- Attachment #1.1.1: Type: text/plain, Size: 886 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> 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).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: Patch --]
[-- Type: text/x-patch, Size: 1940 bytes --]

*** 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 <daveg@synaptics.com>
  ;; 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 <daveg@synaptics.com>
  ;; 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))

[-- Attachment #1.1.3: Type: text/plain, Size: 657 bytes --]



  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 #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2006-03-06 20:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-05  0:59 [michael.cadilhac@lrde.org: PC-do-completion with directories adding stars.] Richard Stallman
2006-03-05  4:36 ` Eli Zaretskii
2006-03-05 14:00   ` Michael Cadilhac
2006-03-05 19:59     ` Eli Zaretskii
2006-03-05 20:53       ` Stefan Monnier
2006-03-05 21:05         ` Luc Teirlinck
2006-03-06  3:31           ` Stefan Monnier
2006-03-06  3:31             ` Luc Teirlinck
2006-03-06  7:43               ` Stefan Monnier
2006-03-06 14:09             ` Luc Teirlinck
2006-03-06 18:38               ` Stefan Monnier
2006-03-06 20:18                 ` Michael Cadilhac [this message]
2006-03-06 20:52                   ` Stefan Monnier
2006-03-06 21:01                     ` Michael Cadilhac
2006-03-07  4:49                       ` Eli Zaretskii
2006-03-07 11:26                         ` Juanma Barranquero
2006-03-07 19:35                           ` Eli Zaretskii
2006-03-07 23:21                             ` Juanma Barranquero
2006-03-06  0:49   ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87u0abqqcu.fsf@mahaena.lrde \
    --to=michael.cadilhac@lrde.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    --cc=teirllm@dms.auburn.edu \
    /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.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).