From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 20 09:53:17 2010 Received: (at submit) by debbugs.gnu.org; 20 Jul 2010 13:53:18 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObDG1-0002JV-2L for submit@debbugs.gnu.org; Tue, 20 Jul 2010 09:53:17 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObDFz-0002JQ-7C for submit@debbugs.gnu.org; Tue, 20 Jul 2010 09:53:16 -0400 Received: from lists.gnu.org ([199.232.76.165]:58870) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1ObDGN-0001bW-7f for submit@debbugs.gnu.org; Tue, 20 Jul 2010 09:53:39 -0400 Received: from [140.186.70.92] (port=49822 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObDGL-0005lT-Sz for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 09:53:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObDGK-0004Ca-Pq for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 09:53:37 -0400 Received: from lo.gmane.org ([80.91.229.12]:48454) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObDGK-0004CV-J8 for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 09:53:36 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1ObDGG-0001e0-Uw for bug-gnu-emacs@gnu.org; Tue, 20 Jul 2010 15:53:32 +0200 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 ; Tue, 20 Jul 2010 15:53:32 +0200 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 ; Tue, 20 Jul 2010 15:53:32 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Kevin Rodgers Subject: locate-library does not provide a default when called interactively Date: Tue, 20 Jul 2010 07:53:32 -0600 Lines: 40 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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) 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-Spam-Score: -5.8 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.8 (-----) 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? 2010-07-20 Kevin Rodgers * subr.el (locate-library): Provide a default LIBRARY when called interactively. *** emacs-23.2/lisp/subr.el~ Sat Apr 3 16:26:12 2010 --- emacs-23.2/lisp/subr.el Tue Jul 20 07:38:58 2010 *************** *** 1583,1589 **** (interactive (list (completing-read "Locate library: " (apply-partially 'locate-file-completion-table ! load-path (get-load-suffixes))) nil nil t)) (let ((file (locate-file library --- 1583,1594 ---- (interactive (list (completing-read "Locate library: " (apply-partially 'locate-file-completion-table ! load-path (get-load-suffixes)) ! nil nil nil nil ! ;; discard text props from default ! ;; to avoid side-effects (visiting file): ! (substring-no-properties ! (thing-at-point 'filename))) nil nil t)) (let ((file (locate-file library -- Kevin Rodgers Denver, Colorado, USA From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 20 23:13:52 2010 Received: (at submit) by debbugs.gnu.org; 21 Jul 2010 03:13:52 +0000 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 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 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 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 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 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 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/ To: bug-gnu-emacs@gnu.org From: Kevin Rodgers Subject: Re: bug#6679: locate-library does not provide a default when called interactively Date: Tue, 20 Jul 2010 21:14:09 -0600 Lines: 51 Message-ID: <4C466601.5060707@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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-Spam-Score: -5.8 (-----) X-Debbugs-Envelope-To: submit Cc: 6679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.8 (-----) 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 From stepnem@gmail.com Sat Mar 28 17:59:24 2020 Received: (at 6679) by debbugs.gnu.org; 30 Mar 2020 02:35:33 +0000 Received: from mail-lf1-f52.google.com ([209.85.167.52]:37856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jIJUB-0000kp-Ov for 6679@debbugs.gnu.org; Sat, 28 Mar 2020 17:59:24 -0400 Received: by mail-lf1-f52.google.com with SMTP id j11so10800078lfg.4 for <6679@debbugs.gnu.org>; Sat, 28 Mar 2020 14:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=uABbj55DEgMLwWITo9C15/eeLKjzVGZyoCTDqdp1DLM=; b=R4Rir3Nd99XvzUAN4eRaIsiP7IK6Zbhc/VKD36BxaBPHO0Nyv/kw1CQXPa8ZMAna5I ey3U4/db7tVi+pgjLV4310YqlPvPa4kVTzffutJR2bVXxf0dDQE4jNF2JFmgIYYuWvZz Msqh7Cu9WYkBnf7yVfdYdSIQOs+yQ193bKjcGnlNgEFYiXyY+jBbFz2zHl4wmu/WBpgQ VFoV/RUVrPkEF8B/8NnPZH+4BX7TJCNoNBcbe9D8AZyqGCnBbt7w0NsFzJipDZrKcely WZDIhM5GMVee7m6k4CmD0ywQrLDyyERYl0EU1S813KkpilFysJW8foYUjqeICj8ddSKB 707w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=uABbj55DEgMLwWITo9C15/eeLKjzVGZyoCTDqdp1DLM=; b=IeXbZg6Ma13Oz1GVqgXAbbODQaEFP25FVFr0hZ/ef0AbygBl2aW2xvCCsCJ0ByljX1 BBjCvhs7uqQ2LDHVSJ0WT7mmmr7MlAgqFuIt89QPaMs0O4rMg6IuvceZRHLMv1h0cxN8 io4uRJsvh79lI6UHUaaTorLZ7OuMw2Po6ZrAWOo5hHQ4WAIGwpkdCU7twKz/IdA1wt7d AhZesY5gStrOX/LrXhGv/a5sliwjyBv5d0tpzr+jpCt5aSSd0Lh6wEiLLZDINQ8Aqwzs R9aoW3h2HFYi0osPRh+Ws2pfe4XV1IeC8xODrSkCuusTuHgSrl+8L/zfzsuW73x4kicu 8KRg== X-Gm-Message-State: AGi0PuYu3GKFGc6xZr7FEvMLlz0pZCsJpACN/HZUjPjkgte953gHcMgJ PJzY6KMg3QpY/689RPYAs4g= X-Google-Smtp-Source: APiQypJwqntuE19l5CgjV0XWF7QK+E2bdrlimE+pc0NnBEE+glBOkaCVjsaniln0u06r99ge+BL6CA== X-Received: by 2002:ac2:5b49:: with SMTP id i9mr3630589lfp.21.1585432757693; Sat, 28 Mar 2020 14:59:17 -0700 (PDT) Received: from localhost ([185.112.167.47]) by smtp.gmail.com with ESMTPSA id d6sm5705621lfn.72.2020.03.28.14.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 14:59:17 -0700 (PDT) From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= To: Kevin Rodgers Cc: 6679@debbugs.gnu.org Subject: Re: bug#6679: locate-library does not provide a default when called interactively In-Reply-To: <4C466601.5060707@gmail.com> (Kevin Rodgers's message of "Tue, 20 Jul 2010 21:14:09 -0600") References: <4C466601.5060707@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Date: Sat, 28 Mar 2020 22:59:44 +0100 Message-ID: <87sghsm97z.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 6679 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Mar 2020 21:59:24 -0000 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 6679 + patch thanks On Tue, 20 Jul 2010 21:14:09 -0600 Kevin Rodgers wrote: > Assuming that complexity is justified, it ought to be factored into a > read-library-name utility that both find-library and locate-library use. The first part has since happened (`read-library-name'), all that is needed is the latter. Patch attached. > `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. The patch also handles `load-library'. The set of arguments/completions expected/provided by `apropos-library' is slightly different and requires other validation, so `read-library-name' wouldn't really help there. --=20 =C5=A0t=C4=9Bp=C3=A1n --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-load-library-locate-library-Use-read-library-name.patch >>From 14acebb7a31da36423c8601033fe209efc95d1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= Date: Sat, 28 Mar 2020 22:16:28 +0100 Subject: [PATCH] load-library, locate-library: Use read-library-name * lisp/emacs-lisp/find-func.el (read-library-name): Add autoload cookie. * lisp/files.el (load-library) * lisp/subr.el (locate-library): Use 'read-library-name' when called interactively. (bug#6652 bug#6679) --- lisp/emacs-lisp/find-func.el | 1 + lisp/files.el | 7 +------ lisp/subr.el | 7 +------ 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 167ead3ce0..e35db56550 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -279,6 +279,7 @@ find-library (switch-to-buffer (find-file-noselect (find-library-name library))) (run-hooks 'find-function-after-hook))) +;;;###autoload (defun read-library-name () "Read and return a library name, defaulting to the one near point. diff --git a/lisp/files.el b/lisp/files.el index 8ce0187f5b..5249b150c5 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1101,12 +1101,7 @@ load-library See Info node `(emacs)Lisp Libraries' for more details. See `load-file' for a different interface to `load'." - (interactive - (let (completion-ignored-extensions) - (list (completing-read "Load library: " - (apply-partially 'locate-file-completion-table - load-path - (get-load-suffixes)))))) + (interactive (list (read-library-name))) (load library)) (defun file-remote-p (file &optional identification connected) diff --git a/lisp/subr.el b/lisp/subr.el index 70f33ee5bd..70a74fba66 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2301,12 +2301,7 @@ locate-library When called from a program, the file name is normally returned as a string. When run interactively, the argument INTERACTIVE-CALL is t, and the file name is displayed in the echo area." - (interactive (list (completing-read "Locate library: " - (apply-partially - 'locate-file-completion-table - load-path (get-load-suffixes))) - nil nil - t)) + (interactive (list (read-library-name) nil nil t)) (let ((file (locate-file library (or path load-path) (append (unless nosuffix (get-load-suffixes)) -- 2.26.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 03 08:01:30 2020 Received: (at 6679-done) by debbugs.gnu.org; 3 Apr 2020 12:01:30 +0000 Received: from localhost ([127.0.0.1]:41322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jKL0s-0003qk-8r for submit@debbugs.gnu.org; Fri, 03 Apr 2020 08:01:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jKL0q-0003qC-3T; Fri, 03 Apr 2020 08:01:28 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jKL0k-0000BL-Ti; Fri, 03 Apr 2020 08:01:22 -0400 Received: from [176.228.60.248] (port=1653 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jKL0k-0006MJ-9F; Fri, 03 Apr 2020 08:01:22 -0400 Date: Fri, 03 Apr 2020 15:01:08 +0300 Message-Id: <83mu7swzgb.fsf@gnu.org> From: Eli Zaretskii To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= In-Reply-To: <87sghsm97z.fsf@gmail.com> (stepnem@gmail.com) Subject: Re: bug#6679: locate-library does not provide a default when called interactively References: <4C466601.5060707@gmail.com> <87sghsm97z.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 6679-done Cc: 6679-done@debbugs.gnu.org, kevin.d.rodgers@gmail.com, 6652-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Štěpán Němec > > Date: Sat, 28 Mar 2020 22:59:44 +0100 > Cc: 6679@debbugs.gnu.org > > On Tue, 20 Jul 2010 21:14:09 -0600 > Kevin Rodgers wrote: > > > Assuming that complexity is justified, it ought to be factored into a > > read-library-name utility that both find-library and locate-library use. > > The first part has since happened (`read-library-name'), all that is > needed is the latter. Patch attached. > > > `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. > > The patch also handles `load-library'. The set of arguments/completions > expected/provided by `apropos-library' is slightly different and > requires other validation, so `read-library-name' wouldn't really help > there. Thanks, pushed to the master branch. From unknown Fri Aug 15 15:36:11 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 02 May 2020 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator