GNU bug report logs - #5955
completions in M-x find-library include .elc files

Previous Next

Package: emacs;

Reported by: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>

Date: Fri, 16 Apr 2010 02:40:03 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: 5955 <at> debbugs.gnu.org
Subject: bug#5955: completions in M-x find-library include .elc files
Date: Mon, 26 Jul 2010 01:58:49 +0200
>>>>> "Stefan" == Stefan Monnier <monnier <at> IRO.UMontreal.CA> 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)))))
 





This bug report was last modified 14 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.