unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5955: completions in M-x find-library include .elc files
@ 2010-04-16  2:28 Aaron S. Hawley
  2010-07-23 22:59 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron S. Hawley @ 2010-04-16  2:28 UTC (permalink / raw)
  To: 5955

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.
 Appears that this is a general problem with
locate-file-completion-table in files.el.  It appears to put all files
in to the completion table without condition.  The fix is just
removing the first `push' operation.

=== modified file 'lisp/files.el'
--- lisp/files.el	2010-03-31 01:51:54 +0000
+++ lisp/files.el	2010-04-16 01:57:24 +0000
@@ -760,7 +760,6 @@
 	(when (file-directory-p dir)
 	  (dolist (file (file-name-all-completions
 			 string-file dir))
-	    (push file names)
 	    (when (string-match suffix file)
 	      (setq file (substring file 0 (match-beginning 0)))
               (push file names)))))

Hope this can get fixed.  I'd love to have the size of my
*completions* buffers reduced by a factor of 3!

Thanks for Emacs,
/a







^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#5955: completions in M-x find-library include .elc files
  2010-04-16  2:28 bug#5955: completions in M-x find-library include .elc files Aaron S. Hawley
@ 2010-07-23 22:59 ` Stefan Monnier
  2010-07-25  0:44   ` Aaron S. Hawley
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-07-23 22:59 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 5955

> 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.
>  Appears that this is a general problem with
> locate-file-completion-table in files.el.  It appears to put all files
> in to the completion table without condition.  The fix is just
> removing the first `push' operation.

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).


        Stefan







^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#5955: completions in M-x find-library include .elc files
  2010-07-23 22:59 ` Stefan Monnier
@ 2010-07-25  0:44   ` Aaron S. Hawley
  2010-07-25 20:03     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron S. Hawley @ 2010-07-25  0:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 5955

On Fri, Jul 23, 2010 at 6:59 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> 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?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#5955: completions in M-x find-library include .elc files
  2010-07-25  0:44   ` Aaron S. Hawley
@ 2010-07-25 20:03     ` Stefan Monnier
  2010-07-25 23:58       ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-07-25 20:03 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 5955

>>> 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.


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#5955: completions in M-x find-library include .elc files
  2010-07-25 20:03     ` Stefan Monnier
@ 2010-07-25 23:58       ` Stefan Monnier
       [not found]         ` <AANLkTinVv=ZFF7u623bcg_ZHyVuG3SNYck8M60qZ-Fqx@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2010-07-25 23:58 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 5955

>>>>> "Stefan" == Stefan Monnier <monnier@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)))))
 






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#5955: completions in M-x find-library include .elc files
       [not found]         ` <AANLkTinVv=ZFF7u623bcg_ZHyVuG3SNYck8M60qZ-Fqx@mail.gmail.com>
@ 2010-08-19 21:24           ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2010-08-19 21:24 UTC (permalink / raw)
  To: Aaron S. Hawley

>> BTW, please try the patch below, to see if you like the
>> resulting behavior.
> Interesting idea.  Show matches for more than one library without
> suffixes, but if there is only one match show the possible extensions.
> I'd say this is an improvement for users over the current behavior.

I've installed this change (well, a slightly different version).

> However, some libraries names are a prefix for another.  So really,

Yes, it's not perfect, but I think it's good enough.  I don't think it's
a clean enough behavior to warrant documenting.


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-19 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-16  2:28 bug#5955: completions in M-x find-library include .elc files Aaron S. Hawley
2010-07-23 22:59 ` Stefan Monnier
2010-07-25  0:44   ` Aaron S. Hawley
2010-07-25 20:03     ` Stefan Monnier
2010-07-25 23:58       ` Stefan Monnier
     [not found]         ` <AANLkTinVv=ZFF7u623bcg_ZHyVuG3SNYck8M60qZ-Fqx@mail.gmail.com>
2010-08-19 21:24           ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).