[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/dired.c,v
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/src/dired.c,v |
Date: |
Tue, 13 May 2008 05:16:46 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 08/05/13 05:16:44
Index: dired.c
===================================================================
RCS file: /sources/emacs/emacs/src/dired.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -b -r1.148 -r1.149
--- dired.c 13 May 2008 04:39:32 -0000 1.148
+++ dired.c 13 May 2008 05:16:43 -0000 1.149
@@ -466,8 +466,7 @@
Lisp_Object predicate;
{
DIR *d;
- int bestmatchsize = 0, skip;
- register int compare, matchsize;
+ int bestmatchsize = 0;
int matchcount = 0;
/* If ALL_FLAG is 1, BESTMATCH is the list of all matches, decoded.
If ALL_FLAG is 0, BESTMATCH is either nil
@@ -477,7 +476,10 @@
Lisp_Object encoded_dir;
struct stat st;
int directoryp;
- int passcount;
+ /* If includeall is zero, exclude files in completion-ignored-extensions as
+ well as "." and "..". Until shown otherwise, assume we can't exclude
+ anything. */
+ int includeall = 1;
int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
@@ -518,18 +520,6 @@
encoded_dir = ENCODE_FILE (dirname);
- /* With passcount = 0, ignore files that end in an ignored extension.
- If nothing found then try again with passcount = 1, don't ignore them.
- If looking for all completions, start with passcount = 1,
- so always take even the ignored ones.
-
- ** It would not actually be helpful to the user to ignore any possible
- completions when making a list of them.** */
-
- for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++)
- {
- int inner_count = SPECPDL_INDEX ();
-
BLOCK_INPUT;
d = opendir (SDATA (Fdirectory_file_name (encoded_dir)));
UNBLOCK_INPUT;
@@ -545,6 +535,7 @@
{
DIRENTRY *dp;
int len;
+ int canexclude = 0;
#ifdef VMS
dp = (*readfunc) (d);
@@ -578,6 +569,12 @@
directoryp = ((st.st_mode & S_IFMT) == S_IFDIR);
tem = Qnil;
+ /* If all_flag is set, always include all.
+ It would not actually be helpful to the user to ignore any possible
+ completions when making a list of them. */
+ if (!all_flag)
+ {
+ int skip;
if (directoryp)
{
#ifndef TRIVIAL_DIRECTORY_ENTRY
@@ -585,9 +582,9 @@
#endif
/* "." and ".." are never interesting as completions, and are
actually in the way in a directory with only one file. */
- if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name))
- continue;
- if (!passcount && len > SCHARS (encoded_file))
+ if (TRIVIAL_DIRECTORY_ENTRY (dp->d_name))
+ canexclude = 1;
+ else if (len > SCHARS (encoded_file))
/* Ignore directories if they match an element of
completion-ignored-extensions which ends in a slash. */
for (tem = Vcompletion_ignored_extensions;
@@ -621,7 +618,7 @@
{
/* Compare extensions-to-be-ignored against end of this file name
*/
/* if name is not an exact match against specified string */
- if (!passcount && len > SCHARS (encoded_file))
+ if (len > SCHARS (encoded_file))
/* and exit this for loop if a match is found */
for (tem = Vcompletion_ignored_extensions;
CONSP (tem); tem = XCDR (tem))
@@ -644,15 +641,28 @@
/* If an ignored-extensions match was found,
don't process this name as a completion. */
- if (!passcount && CONSP (tem))
+ if (CONSP (tem))
+ canexclude = 1;
+
+ if (!includeall && canexclude)
+ /* We're not including all files and this file can be excluded. */
continue;
+ if (includeall && !canexclude)
+ { /* If we have one non-excludable file, we want to exclude the
+ excudable files. */
+ includeall = 0;
+ /* Throw away any previous excludable match found. */
+ bestmatch = Qnil;
+ bestmatchsize = 0;
+ matchcount = 0;
+ }
+ }
/* FIXME: If we move this `decode' earlier we can eliminate
the repeated ENCODE_FILE on Vcompletion_ignored_extensions. */
name = make_unibyte_string (dp->d_name, len);
name = DECODE_FILE (name);
- if (!passcount)
{
Lisp_Object regexps;
Lisp_Object zero;
@@ -701,18 +711,17 @@
{
Lisp_Object zero = make_number (0);
/* FIXME: This is a copy of the code in Ftry_completion. */
- compare = min (bestmatchsize, SCHARS (name));
- tem = Fcompare_strings (bestmatch, zero,
+ int compare = min (bestmatchsize, SCHARS (name));
+ Lisp_Object tem
+ = Fcompare_strings (bestmatch, zero,
make_number (compare),
name, zero,
make_number (compare),
completion_ignore_case ? Qt : Qnil);
- if (EQ (tem, Qt))
- matchsize = compare;
- else if (XINT (tem) < 0)
- matchsize = - XINT (tem) - 1;
- else
- matchsize = XINT (tem) - 1;
+ int matchsize
+ = (EQ (tem, Qt) ? compare
+ : XINT (tem) < 0 ? - XINT (tem) - 1
+ : XINT (tem) - 1);
if (completion_ignore_case)
{
@@ -754,11 +763,9 @@
bestmatchsize = matchsize;
}
}
- /* This closes the directory. */
- bestmatch = unbind_to (inner_count, bestmatch);
- }
UNGCPRO;
+ /* This closes the directory. */
bestmatch = unbind_to (count, bestmatch);
if (all_flag || NILP (bestmatch))
- [Emacs-diffs] Changes to emacs/src/dired.c,v, Eli Zaretskii, 2008/05/03
- [Emacs-diffs] Changes to emacs/src/dired.c,v, Eli Zaretskii, 2008/05/09
- [Emacs-diffs] Changes to emacs/src/dired.c,v, Eli Zaretskii, 2008/05/10
- [Emacs-diffs] Changes to emacs/src/dired.c,v, Stefan Monnier, 2008/05/13
- [Emacs-diffs] Changes to emacs/src/dired.c,v,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/src/dired.c,v, Glenn Morris, 2008/05/14
- [Emacs-diffs] Changes to emacs/src/dired.c,v, Eli Zaretskii, 2008/05/16