From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#5955: completions in M-x find-library include .elc files Date: Mon, 26 Jul 2010 01:58:49 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1280102900 350 80.91.229.12 (26 Jul 2010 00:08:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 26 Jul 2010 00:08:20 +0000 (UTC) Cc: 5955@debbugs.gnu.org To: "Aaron S. Hawley" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 26 02:08:19 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OdBEp-0005Hq-Bs for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jul 2010 02:08:11 +0200 Original-Received: from localhost ([127.0.0.1]:49718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdBEo-0006BH-GV for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Jul 2010 20:08:10 -0400 Original-Received: from [140.186.70.92] (port=55517 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdBEG-0005xo-S1 for bug-gnu-emacs@gnu.org; Sun, 25 Jul 2010 20:07:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdBEF-0006Zu-K0 for bug-gnu-emacs@gnu.org; Sun, 25 Jul 2010 20:07:36 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41617) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdBEF-0006Zo-Gr for bug-gnu-emacs@gnu.org; Sun, 25 Jul 2010 20:07:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OdB5x-0004ns-I8; Sun, 25 Jul 2010 19:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Jul 2010 23:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5955 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5955-submit@debbugs.gnu.org id=B5955.128010233218455 (code B ref 5955); Sun, 25 Jul 2010 23:59:01 +0000 Original-Received: (at 5955) by debbugs.gnu.org; 25 Jul 2010 23:58:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdB5n-0004nc-49 for submit@debbugs.gnu.org; Sun, 25 Jul 2010 19:58:51 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdB5l-0004nX-EN for 5955@debbugs.gnu.org; Sun, 25 Jul 2010 19:58:49 -0400 Original-Received: from ceviche.home (vpn-132-204-232-49.acd.umontreal.ca [132.204.232.49]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id o6PNwovf031297; Sun, 25 Jul 2010 19:58:51 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 863FA660B6; Mon, 26 Jul 2010 01:58:49 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Sun, 25 Jul 2010 22:03:13 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3585=0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 25 Jul 2010 19:59:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:38927 Archived-At: >>>>> "Stefan" == Stefan Monnier writes: >>>> Typing TAB or ? in M-x find-library shows .el and .elc files when it >>>> probably should just be the name of the library without the extension. >>> I added the `push' because in load-library I often want to >>> select a particular file (i.e. either the .el or the .elc file). >> Doesn't M-x load-library and specifying no extension load the .elc? > Usually, yes. BTW, please try the patch below, to see if you like the resulting behavior. Stefan === modified file 'lisp/files.el' --- lisp/files.el 2010-06-13 19:52:42 +0000 +++ lisp/files.el 2010-07-25 23:57:51 +0000 @@ -777,9 +777,12 @@ (if x (1- (length x)) (length suffix)))))) (t (let ((names nil) + (stripsuffix t) (suffix (concat (regexp-opt suffixes t) "\\'")) (string-dir (file-name-directory string)) (string-file (file-name-nondirectory string))) + (while + (progn (dolist (dir dirs) (unless dir (setq dir default-directory)) @@ -787,10 +790,15 @@ (when (file-directory-p dir) (dolist (file (file-name-all-completions string-file dir)) + (if (not (string-match suffix file)) (push file names) - (when (string-match suffix file) + (unless stripsuffix (push file names)) (setq file (substring file 0 (match-beginning 0))) (push file names))))) + ;; Remove duplicates of the first element. + (setq names (cons (car names) (delete (car names) (cdr names)))) + (prog1 (and stripsuffix (= 1 (length names))) + (setq stripsuffix nil)))) (completion-table-with-context string-dir names string-file pred action)))))