From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Name completion for library Date: Mon, 08 Aug 2005 13:20:07 -0600 Message-ID: References: <20050806183656.GE1786@johnsons-web.com> <0ee1a7db2af8c2fd10582f9158f254ff@Web.DE> <20050806193145.GF1786@johnsons-web.com> <42F511F4.6050302@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1123529290 28741 80.91.229.2 (8 Aug 2005 19:28:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Aug 2005 19:28:10 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 08 21:28:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E2DGI-0005mv-C3 for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Aug 2005 21:26:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E2DJJ-0003zV-AG for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Aug 2005 15:29:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E2DIJ-0003wF-BL for help-gnu-emacs@gnu.org; Mon, 08 Aug 2005 15:28:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E2DIE-0003ss-O3 for help-gnu-emacs@gnu.org; Mon, 08 Aug 2005 15:28:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E2DIE-0003s5-DT for help-gnu-emacs@gnu.org; Mon, 08 Aug 2005 15:28:14 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1E2DR0-0007Kx-SK for help-gnu-emacs@gnu.org; Mon, 08 Aug 2005 15:37:19 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1E2DBb-0005Gg-Re for help-gnu-emacs@gnu.org; Mon, 08 Aug 2005 21:21:23 +0200 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 08 Aug 2005 21:21:23 +0200 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 08 Aug 2005 21:21:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 54 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: <42F511F4.6050302@student.lu.se> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:28558 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28558 Lennart Borgman wrote: > Tim Johnson wrote: >> Shucks! Xemacs will complete a library name, was hoping GNU >> emacs would also. >> > It will. Soon I hope. When next version is released. Or you can crib the Emacs 22 code from CVS. I've almost got it working in Emacs 21 (see the comments): ;; From Emacs 22 src/lread.c: (defvar load-suffixes '(".elc" ".el") "List of suffixes to try for files to load. This list should not include the empty string.") (eval-when-compile (require 'cl)) ; Emacs 21 ;; From Emacs 22 lisp/files.el: (defun locate-file-completion (string path-and-suffixes action) "Do completion for file names passed to `locate-file'. PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)." (if (file-name-absolute-p string) (read-file-name-internal string nil action) (let ((names nil) (suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'")) (string-dir (file-name-directory string))) (dolist (dir (car path-and-suffixes)) (unless dir (setq dir default-directory)) (if string-dir (setq dir (expand-file-name string-dir dir))) (when (file-directory-p dir) (dolist (file (file-name-all-completions (file-name-nondirectory string) dir)) (push (if string-dir (concat string-dir file) file) names) (when (string-match suffix file) (setq file (substring file 0 (match-beginning 0))) (push (if string-dir (concat string-dir file) file) names))))) (setq names (mapcar 'list names)) ; Emacs 21 (cond ((eq action t) (all-completions string names)) ((null action) (try-completion string names)) (t nil) ; Emacs 21 (t (test-completion string names)))))) (defadvice load-library (before interactive activate) "Provide completion when reading the library name." (interactive (list (completing-read "Load library: " 'locate-file-completion (cons load-path load-suffixes))))) -- Kevin Rodgers