* Still bugs in read-file-name completion on w32
@ 2006-04-20 14:22 Lennart Borgman
2006-04-21 11:26 ` Mathias Dahl
0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-04-20 14:22 UTC (permalink / raw)
Eval this code and try to complete in a directory with only one file,
but not matching the pattern (ie temp.tmp):
(defcustom nxhtml-image-completion-pattern
"\\.\\(?:png\\|jpg\\|jpeg\\|gif\\)$"
"Pattern for matching image URLs in completion."
:type 'regexp)
(defun nxhtml-image-url-predicate(url)
(setq nxhtml-predicate-error nil)
(if (or (file-directory-p url)
(string-match nxhtml-image-completion-pattern url))
t
(setq nxhtml-predicate-error "Does not match image file name
pattern.")
nil))
(read-file-name "File: " nil "" nil "" 'nxhtml-image-url-predicate)
For me this completes to the file temp.tmp. This is on w32:
GNU Emacs 22.0.50.1 (i386-mingw-nt5.0.2195) of 2006-04-15
I do not know if this bug affects other platforms too, please test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Still bugs in read-file-name completion on w32
2006-04-20 14:22 Still bugs in read-file-name completion on w32 Lennart Borgman
@ 2006-04-21 11:26 ` Mathias Dahl
2006-04-21 13:33 ` Jason Rumney
0 siblings, 1 reply; 5+ messages in thread
From: Mathias Dahl @ 2006-04-21 11:26 UTC (permalink / raw)
Cc: Emacs Devel
> Eval this code and try to complete in a directory with only one file,
> but not matching the pattern (ie temp.tmp):
>
> (defcustom nxhtml-image-completion-pattern
> "\\.\\(?:png\\|jpg\\|jpeg\\|gif\\)$"
> "Pattern for matching image URLs in completion."
> :type 'regexp)
>
> (defun nxhtml-image-url-predicate(url)
> (setq nxhtml-predicate-error nil)
> (if (or (file-directory-p url)
> (string-match nxhtml-image-completion-pattern url))
> t
> (setq nxhtml-predicate-error "Does not match image file name
> pattern.")
> nil))
>
> (read-file-name "File: " nil "" nil "" 'nxhtml-image-url-predicate)
>
> For me this completes to the file temp.tmp. This is on w32:
> GNU Emacs 22.0.50.1 (i386-mingw-nt5.0.2195) of 2006-04-15
>
> I do not know if this bug affects other platforms too, please test.
It does not affect me on Windows. These are the files matcing "test" in c:\:
test av mellanslag.txt test.doc.PPT
test.html test.html~
test.jpg test.txt
test.txt~ test.zip
test1.txt test2.txt
test_stor.mp3
If I use normal find-file I can select one of them. With your code
above I can only select the test.jpg file.
My version:
GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2005-06-26 on NONIQPC
/Mathias
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Still bugs in read-file-name completion on w32
2006-04-21 11:26 ` Mathias Dahl
@ 2006-04-21 13:33 ` Jason Rumney
2006-04-21 17:20 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Jason Rumney @ 2006-04-21 13:33 UTC (permalink / raw)
Cc: Lennart Borgman, Emacs Devel
Mathias Dahl wrote:
> It does not affect me on Windows. These are the files matcing "test" in c:\:
>
> test av mellanslag.txt test.doc.PPT
> test.html test.html~
> test.jpg test.txt
> test.txt~ test.zip
> test1.txt test2.txt
> test_stor.mp3
>
I think you missed an important part of Lennart's mail. In his case only
one file matched "test", and it did not match the regexp he used for
completions.
I think this is by design. Completion is there to help the user choose a
file, not to prevent them from choosing the wrong file. By default we
ignore backup files and known binary suffixes, but if the only match for
what the user has typed is a file that we would normally ignore, then we
happily complete to that, because ultimately the user knows best.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Still bugs in read-file-name completion on w32
2006-04-21 13:33 ` Jason Rumney
@ 2006-04-21 17:20 ` Stefan Monnier
2006-04-25 13:56 ` Mathias Dahl
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2006-04-21 17:20 UTC (permalink / raw)
Cc: Lennart Borgman, Emacs Devel, Mathias Dahl
>> It does not affect me on Windows. These are the files matcing "test" in c:\:
>>
>> test av mellanslag.txt test.doc.PPT
>> test.html test.html~
>> test.jpg test.txt
>> test.txt~ test.zip
>> test1.txt test2.txt
>> test_stor.mp3
>>
> I think you missed an important part of Lennart's mail. In his case only one
> file matched "test", and it did not match the regexp he used
> for completions.
> I think this is by design. Completion is there to help the user choose
> a file, not to prevent them from choosing the wrong file. By default we
> ignore backup files and known binary suffixes, but if the only match for
> what the user has typed is a file that we would normally ignore, then we
> happily complete to that, because ultimately the user knows best.
Are you sure?
I know this is the expected behavior of completion-ignored-extensions, but
I didn't know this is the expected behavior of the `predicate' argument to
read-file-name.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Still bugs in read-file-name completion on w32
2006-04-21 17:20 ` Stefan Monnier
@ 2006-04-25 13:56 ` Mathias Dahl
0 siblings, 0 replies; 5+ messages in thread
From: Mathias Dahl @ 2006-04-25 13:56 UTC (permalink / raw)
Cc: Lennart Borgman, Emacs Devel, Jason Rumney
> > I think this is by design. Completion is there to help the user choose
> > a file, not to prevent them from choosing the wrong file. By default we
> > ignore backup files and known binary suffixes, but if the only match for
> > what the user has typed is a file that we would normally ignore, then we
> > happily complete to that, because ultimately the user knows best.
> Are you sure?
> I know this is the expected behavior of completion-ignored-extensions, but
> I didn't know this is the expected behavior of the `predicate' argument to
> read-file-name.
I agree, and the documentation string is quite clear:
...
If optional sixth arg predicate is non-nil, possible completions and
the resulting file name must satisfy (funcall predicate NAME).
...
*Must* satisfy.
/Mathias
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-04-25 13:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-20 14:22 Still bugs in read-file-name completion on w32 Lennart Borgman
2006-04-21 11:26 ` Mathias Dahl
2006-04-21 13:33 ` Jason Rumney
2006-04-21 17:20 ` Stefan Monnier
2006-04-25 13:56 ` Mathias Dahl
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.