From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.bugs Subject: bug#6679: locate-library does not provide a default when called interactively Date: Tue, 20 Jul 2010 21:14:09 -0600 Message-ID: <4C466601.5060707@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1279683054 18707 80.91.229.12 (21 Jul 2010 03:30:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Jul 2010 03:30:54 +0000 (UTC) Cc: 6679@debbugs.gnu.org To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 21 05:30:50 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 1ObQ1A-0002AG-Bm for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Jul 2010 05:30:48 +0200 Original-Received: from localhost ([127.0.0.1]:42613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObQ19-0006Oh-Ou for geb-bug-gnu-emacs@m.gmane.org; Tue, 20 Jul 2010 23:30:47 -0400 Original-Received: from [140.186.70.92] (port=41076 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObQ14-0006OY-Ar for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 23:30:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObQ12-0006Kl-UW for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 23:30:42 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54890) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObQ12-0006Kh-TC for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 23:30:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1ObPkv-0007qQ-Su; Tue, 20 Jul 2010 23:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kevin Rodgers Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Jul 2010 03:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6679 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.127968203230147 (code B ref -1); Wed, 21 Jul 2010 03:14:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Jul 2010 03:13: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 1ObPkm-0007qC-7G for submit@debbugs.gnu.org; Tue, 20 Jul 2010 23:13:52 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObPkj-0007q7-T7 for submit@debbugs.gnu.org; Tue, 20 Jul 2010 23:13:50 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:50762) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1ObPl9-0005pj-AG for submit@debbugs.gnu.org; Tue, 20 Jul 2010 23:14:15 -0400 Original-Received: from [140.186.70.92] (port=53672 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObPl7-0004ER-NP for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 23:14:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObPl6-00047H-E2 for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 23:14:13 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:33351) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObPl6-000478-3e for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 23:14:12 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1ObPl4-0006DC-RY for bug-gnu-emacs@gnu.org; Wed, 21 Jul 2010 05:14:10 +0200 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 Jul 2010 05:14:10 +0200 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 Jul 2010 05:14:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 20 Jul 2010 23:14: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:38717 Archived-At: Kevin Rodgers wrote: > See bug 6652 for a use case. > > Here's a patch -- should the default be included in the prompt, or > is the user expected to know to try M-n? I thought to check what find-library does, and found something rather more complicated than (completing-read ... (thing-at-point 'filename)): (interactive (let* ((dirs (or find-function-source-path load-path)) (suffixes (find-library-suffixes)) (def (if (eq (function-called-at-point) 'require) ;; `function-called-at-point' may return 'require ;; with `point' anywhere on this line. So wrap the ;; `save-excursion' below in a `condition-case' to ;; avoid reporting a scan-error here. (condition-case nil (save-excursion (backward-up-list) (forward-char) (forward-sexp 2) (thing-at-point 'symbol)) (error nil)) (thing-at-point 'symbol)))) (when def (setq def (and (locate-file-completion-table dirs suffixes def nil 'lambda) def))) (list (completing-read (if def (format "Library name (default %s): " def) "Library name: ") (apply-partially 'locate-file-completion-table dirs suffixes) nil nil nil nil def)))) Assuming that complexity is justified, it ought to be factored into a read-library-name utility that both find-library and locate-library use. Note that for some reason the DEF argument to completing-read needs to be (substring-no-properties def), to prevent completing read from visiting the file itself when point is on a file name hyperlink in a *Help* buffer (with help-args text property). But I suppose that is a separate bug. `C-h a -library\'' returns apropos-library and load-library in addition to find-library and locate-library, but it's not clear to me that they would benefit from a default. -- Kevin Rodgers Denver, Colorado, USA