changeset 72310:e45c648eb3ad

(PC-do-completion): Strip out completion-ignored-extensions before checking whether there are multiple completions. Don't use `list' unnecessarily when building completion tables.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 07 Aug 2006 18:06:28 +0000
parents e5f74bc78986
children 4501a3a3a336
files lisp/ChangeLog lisp/complete.el
diffstat 2 files changed, 43 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Aug 07 17:47:55 2006 +0000
+++ b/lisp/ChangeLog	Mon Aug 07 18:06:28 2006 +0000
@@ -1,3 +1,9 @@
+2006-08-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* complete.el (PC-do-completion): Strip out completion-ignored-extensions
+	before checking whether there are multiple completions.
+	Don't use `list' unnecessarily when building completion tables.
+
 2006-08-06  Richard Stallman  <rms@gnu.org>
 
 	* help.el (describe-mode): Make minor mode list more concise.
@@ -672,8 +678,8 @@
 
 2006-07-10  Chong Yidong  <cyd@stupidchicken.com>
 
-	* progmodes/cc-awk.el (defconst): Use eval-and-compile to avoid
-	compilation error.
+	* progmodes/cc-awk.el (c-awk-escaped-nls*): Use eval-and-compile to
+	avoid compilation error.
 
 	* subr.el (sit-for): New function.
 
--- a/lisp/complete.el	Mon Aug 07 17:47:55 2006 +0000
+++ b/lisp/complete.el	Mon Aug 07 18:06:28 2006 +0000
@@ -543,8 +543,8 @@
 	(let ((compl (all-completions (if env-on
 					  (file-name-nondirectory (substring str 0 p))
 					(substring str 0 p))
-                                        table
-                                        pred)))
+                                      table
+                                      pred)))
 	  (setq p compl)
 	  (while p
 	    (and (string-match regex (car p))
@@ -553,6 +553,34 @@
 		   (setq poss (cons (car p) poss))))
 	    (setq p (cdr p)))))
 
+      ;; Handle completion-ignored-extensions
+      (and filename
+           (not (eq mode 'help))
+           (let ((p2 poss))
+
+             ;; Build a regular expression representing the extensions list
+             (or (equal completion-ignored-extensions PC-ignored-extensions)
+                 (setq PC-ignored-regexp
+                       (concat "\\("
+                               (mapconcat
+                                'regexp-quote
+                                (setq PC-ignored-extensions
+                                      completion-ignored-extensions)
+                                "\\|")
+                               "\\)\\'")))
+
+             ;; Check if there are any without an ignored extension.
+             ;; Also ignore `.' and `..'.
+             (setq p nil)
+             (while p2
+               (or (string-match PC-ignored-regexp (car p2))
+                   (string-match "\\(\\`\\|/\\)[.][.]?/?\\'" (car p2))
+                   (setq p (cons (car p2) p)))
+               (setq p2 (cdr p2)))
+
+             ;; If there are "good" names, use them
+             (and p (setq poss p))))
+
       ;; Now we have a list of possible completions
       (cond
 
@@ -575,34 +603,6 @@
        ((or (cdr (setq helpposs poss))
 	    (memq mode '(help word)))
 
-	;; Handle completion-ignored-extensions
-	(and filename
-	     (not (eq mode 'help))
-	     (let ((p2 poss))
-
-	       ;; Build a regular expression representing the extensions list
-	       (or (equal completion-ignored-extensions PC-ignored-extensions)
-		   (setq PC-ignored-regexp
-			 (concat "\\("
-				 (mapconcat
-				  'regexp-quote
-				  (setq PC-ignored-extensions
-					completion-ignored-extensions)
-				  "\\|")
-				 "\\)\\'")))
-
-	       ;; Check if there are any without an ignored extension.
-	       ;; Also ignore `.' and `..'.
-	       (setq p nil)
-	       (while p2
-		 (or (string-match PC-ignored-regexp (car p2))
-		     (string-match "\\(\\`\\|/\\)[.][.]?/?\\'" (car p2))
-		     (setq p (cons (car p2) p)))
-		 (setq p2 (cdr p2)))
-
-	       ;; If there are "good" names, use them
-	       (and p (setq poss p))))
-
 	;; Is the actual string one of the possible completions?
 	(setq p (and (not (eq mode 'help)) poss))
 	(while (and p
@@ -623,7 +623,8 @@
 
 	    ;; Check if next few letters are the same in all cases
 	    (if (and (not (eq mode 'help))
-		     (setq prefix (try-completion (PC-chunk-after basestr skip) (mapcar 'list poss))))
+		     (setq prefix (try-completion (PC-chunk-after basestr skip)
+                                                  poss)))
 		(let ((first t) i)
 		  ;; Retain capitalization of user input even if
 		  ;; completion-ignore-case is set.
@@ -669,13 +670,9 @@
 					      (+ beg (length dirname)) end)
 					     skip)
 					    (mapcar
-					     (function
-					      (lambda (x)
-						(list
-						 (and (string-match skip x)
-						      (substring
-						       x
-						       (match-end 0))))))
+                                             (lambda (x)
+                                               (when (string-match skip x)
+                                                 (substring x (match-end 0))))
 					     poss)))
 			      (or (> i 0) (> (length prefix) 0))
 			      (or (not (eq mode 'word))