aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2006-08-07 18:06:28 +0000
committerStefan Monnier2006-08-07 18:06:28 +0000
commit4a63ceb8901f019161baa9f481b1b12f4134fea4 (patch)
tree5f3b74ef753dfaa6e3fa04914e833d4bb7adc2e6
parent65c986aa9470183c3a546b21dbd1d14eae109626 (diff)
downloademacs-4a63ceb8901f019161baa9f481b1b12f4134fea4.tar.gz
emacs-4a63ceb8901f019161baa9f481b1b12f4134fea4.zip
(PC-do-completion): Strip out completion-ignored-extensions
before checking whether there are multiple completions. Don't use `list' unnecessarily when building completion tables.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/complete.el73
2 files changed, 43 insertions, 40 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3f94298abca..ff97d539496 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12006-08-07 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * complete.el (PC-do-completion): Strip out completion-ignored-extensions
4 before checking whether there are multiple completions.
5 Don't use `list' unnecessarily when building completion tables.
6
12006-08-06 Richard Stallman <rms@gnu.org> 72006-08-06 Richard Stallman <rms@gnu.org>
2 8
3 * help.el (describe-mode): Make minor mode list more concise. 9 * help.el (describe-mode): Make minor mode list more concise.
@@ -672,8 +678,8 @@
672 678
6732006-07-10 Chong Yidong <cyd@stupidchicken.com> 6792006-07-10 Chong Yidong <cyd@stupidchicken.com>
674 680
675 * progmodes/cc-awk.el (defconst): Use eval-and-compile to avoid 681 * progmodes/cc-awk.el (c-awk-escaped-nls*): Use eval-and-compile to
676 compilation error. 682 avoid compilation error.
677 683
678 * subr.el (sit-for): New function. 684 * subr.el (sit-for): New function.
679 685
diff --git a/lisp/complete.el b/lisp/complete.el
index c49ad488536..90c1ceceb32 100644
--- a/lisp/complete.el
+++ b/lisp/complete.el
@@ -543,8 +543,8 @@ of `minibuffer-completion-table' and the minibuffer contents.")
543 (let ((compl (all-completions (if env-on 543 (let ((compl (all-completions (if env-on
544 (file-name-nondirectory (substring str 0 p)) 544 (file-name-nondirectory (substring str 0 p))
545 (substring str 0 p)) 545 (substring str 0 p))
546 table 546 table
547 pred))) 547 pred)))
548 (setq p compl) 548 (setq p compl)
549 (while p 549 (while p
550 (and (string-match regex (car p)) 550 (and (string-match regex (car p))
@@ -553,6 +553,34 @@ of `minibuffer-completion-table' and the minibuffer contents.")
553 (setq poss (cons (car p) poss)))) 553 (setq poss (cons (car p) poss))))
554 (setq p (cdr p))))) 554 (setq p (cdr p)))))
555 555
556 ;; Handle completion-ignored-extensions
557 (and filename
558 (not (eq mode 'help))
559 (let ((p2 poss))
560
561 ;; Build a regular expression representing the extensions list
562 (or (equal completion-ignored-extensions PC-ignored-extensions)
563 (setq PC-ignored-regexp
564 (concat "\\("
565 (mapconcat
566 'regexp-quote
567 (setq PC-ignored-extensions
568 completion-ignored-extensions)
569 "\\|")
570 "\\)\\'")))
571
572 ;; Check if there are any without an ignored extension.
573 ;; Also ignore `.' and `..'.
574 (setq p nil)
575 (while p2
576 (or (string-match PC-ignored-regexp (car p2))
577 (string-match "\\(\\`\\|/\\)[.][.]?/?\\'" (car p2))
578 (setq p (cons (car p2) p)))
579 (setq p2 (cdr p2)))
580
581 ;; If there are "good" names, use them
582 (and p (setq poss p))))
583
556 ;; Now we have a list of possible completions 584 ;; Now we have a list of possible completions
557 (cond 585 (cond
558 586
@@ -575,34 +603,6 @@ of `minibuffer-completion-table' and the minibuffer contents.")
575 ((or (cdr (setq helpposs poss)) 603 ((or (cdr (setq helpposs poss))
576 (memq mode '(help word))) 604 (memq mode '(help word)))
577 605
578 ;; Handle completion-ignored-extensions
579 (and filename
580 (not (eq mode 'help))
581 (let ((p2 poss))
582
583 ;; Build a regular expression representing the extensions list
584 (or (equal completion-ignored-extensions PC-ignored-extensions)
585 (setq PC-ignored-regexp
586 (concat "\\("
587 (mapconcat
588 'regexp-quote
589 (setq PC-ignored-extensions
590 completion-ignored-extensions)
591 "\\|")
592 "\\)\\'")))
593
594 ;; Check if there are any without an ignored extension.
595 ;; Also ignore `.' and `..'.
596 (setq p nil)
597 (while p2
598 (or (string-match PC-ignored-regexp (car p2))
599 (string-match "\\(\\`\\|/\\)[.][.]?/?\\'" (car p2))
600 (setq p (cons (car p2) p)))
601 (setq p2 (cdr p2)))
602
603 ;; If there are "good" names, use them
604 (and p (setq poss p))))
605
606 ;; Is the actual string one of the possible completions? 606 ;; Is the actual string one of the possible completions?
607 (setq p (and (not (eq mode 'help)) poss)) 607 (setq p (and (not (eq mode 'help)) poss))
608 (while (and p 608 (while (and p
@@ -623,7 +623,8 @@ of `minibuffer-completion-table' and the minibuffer contents.")
623 623
624 ;; Check if next few letters are the same in all cases 624 ;; Check if next few letters are the same in all cases
625 (if (and (not (eq mode 'help)) 625 (if (and (not (eq mode 'help))
626 (setq prefix (try-completion (PC-chunk-after basestr skip) (mapcar 'list poss)))) 626 (setq prefix (try-completion (PC-chunk-after basestr skip)
627 poss)))
627 (let ((first t) i) 628 (let ((first t) i)
628 ;; Retain capitalization of user input even if 629 ;; Retain capitalization of user input even if
629 ;; completion-ignore-case is set. 630 ;; completion-ignore-case is set.
@@ -669,13 +670,9 @@ of `minibuffer-completion-table' and the minibuffer contents.")
669 (+ beg (length dirname)) end) 670 (+ beg (length dirname)) end)
670 skip) 671 skip)
671 (mapcar 672 (mapcar
672 (function 673 (lambda (x)
673 (lambda (x) 674 (when (string-match skip x)
674 (list 675 (substring x (match-end 0))))
675 (and (string-match skip x)
676 (substring
677 x
678 (match-end 0))))))
679 poss))) 676 poss)))
680 (or (> i 0) (> (length prefix) 0)) 677 (or (> i 0) (> (length prefix) 0))
681 (or (not (eq mode 'word)) 678 (or (not (eq mode 'word))