aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/complete.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/complete.el')
-rw-r--r--lisp/complete.el73
1 files changed, 35 insertions, 38 deletions
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))