From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#26355: 26.0.50; find-library doesn't handle load-history entries with nil FILE-NAME Date: Mon, 03 Apr 2017 21:27:31 -0400 Message-ID: <87efx9vu64.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1491269246 20125 195.159.176.226 (4 Apr 2017 01:27:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Apr 2017 01:27:26 +0000 (UTC) To: 26355@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 04 03:27:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvDFb-00043w-0F for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Apr 2017 03:27:15 +0200 Original-Received: from localhost ([::1]:33528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvDFg-0001WE-HS for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Apr 2017 21:27:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvDFS-0001Ud-TH for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:27:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvDFO-0001n6-P7 for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:27:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvDFO-0001mw-LU for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cvDFO-0000Bb-FY for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Apr 2017 01:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26355 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1491269198683 (code B ref -1); Tue, 04 Apr 2017 01:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Apr 2017 01:26:38 +0000 Original-Received: from localhost ([127.0.0.1]:59659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvDEz-0000Ax-Qq for submit@debbugs.gnu.org; Mon, 03 Apr 2017 21:26:38 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39467) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvDEx-0000Ak-SV for submit@debbugs.gnu.org; Mon, 03 Apr 2017 21:26:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvDEl-0001Qp-O0 for submit@debbugs.gnu.org; Mon, 03 Apr 2017 21:26:30 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cvDEl-0001Qc-LF for submit@debbugs.gnu.org; Mon, 03 Apr 2017 21:26:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvDEf-0001KM-7l for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:26:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvDEZ-0001A2-4x for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:26:17 -0400 Original-Received: from mail-it0-x22d.google.com ([2607:f8b0:4001:c0b::22d]:32888) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvDEX-000176-U0 for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2017 21:26:10 -0400 Original-Received: by mail-it0-x22d.google.com with SMTP id 68so14542652itx.0 for ; Mon, 03 Apr 2017 18:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:mime-version; bh=Vln5nZVGZw714KzfV2qi5dhFnNHM5qYXUeVJDRignkk=; b=T1iQo9t2V00FRQHAydUGijJXJWHqD8uWM6x/iRRwu/VErjSdwVqPzNZPThEwq9JYYM Izr69AXoYAkBxZGEGIQ6Y4Gf1QRUu9uHfJwor9PCghL9UQJHFHDrbAfWRKNBqWWjyaCF W51EEdWWYwTCJoA6N/La6cR8HoPBQTM98ZQwH/KEw1A1CQOJD37lOODl8weJpbVCPlST jNhQI68oGNoiMbRgwsHpvRMNOjz/kJhaxA6xwvxaY65nNDcYWQBNm40aCsIIEUM5cGPb SdjdzEUYL/YZPZrUzhhMkVMZmM+AOlnfqgAl+u3vYmcf7A5+czWITuxlijKMiFhsDUhQ ONpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version; bh=Vln5nZVGZw714KzfV2qi5dhFnNHM5qYXUeVJDRignkk=; b=YkID4QYBVNnn2GJ5PHA2aeMTg9+fkNmxVB4jKNoUBAhr05UIysG5yjQaRYgns/qWCw d1UCXBgZ6udP7BsBUdswDozxyiGsJfQjh5Xb2nQm/vjVvtf6V6D/paF3hKlEFFAEPFaO pU4gTUE4BiRIZZof+XxoEYB7bNxkmbtD8VhcBlr8gRZfqlFmZV5RNkEngpuNowVa3/Q7 BohgO4XQNtEa/LRQg9dynwe9cwOcjgrdWyV1my00nUHB+ueNIjR8hLITufQuInHYujhu MUJ5Meth66EANwUTQ3vMRntsGrMY1jCBH970p/NeSVj9+EqY1J7mDzJbQBdlq6jxK42J TVfw== X-Gm-Message-State: AFeK/H0qgs/TsMoMdgcge0taGFNcYyO0mhZplX6DbtCR8I/108yirZghtAdhIaUh43BSCg== X-Received: by 10.36.208.134 with SMTP id m128mr13428832itg.44.1491269169043; Mon, 03 Apr 2017 18:26:09 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id l129sm10361173ite.1.2017.04.03.18.26.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Apr 2017 18:26:08 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131257 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Severiy: minor Tags: patch emacs -Q Insert (defun foo ()) and C-M-x on it. M-x find-library blah RET gives "Wrong type argument: stringp, nil" Expected "find-library-name: Can=E2=80=99t find library blah" Here is a patch. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Let-find-library-name-handle-load-history-entries.patch Content-Description: pathc >From bbd991199206e9d23170d47e0ae2bfb616ba6fff Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 25 Mar 2017 22:41:34 -0400 Subject: [PATCH v1] Let find-library-name handle load-history entries with nil file-name * lisp/emacs-lisp/find-func.el (find-library--from-load-history): Rename from find-library--from-load-path. Check for `load-history' entries with nil FILE-NAMEs. Simplify by not double checking for suffixes and making use of `locate-file'. --- lisp/emacs-lisp/find-func.el | 48 ++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 6699e3fd2b..d0acc14775 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -43,7 +43,7 @@ ;;; Code: -(require 'seq) +(eval-when-compile (require 'cl-lib)) ;;; User variables: @@ -203,43 +203,21 @@ find-library-name (locate-file rel (or find-function-source-path load-path) load-file-rep-suffixes))))) - (find-library--from-load-path library) + (find-library--from-load-history library) (error "Can't find library %s" library))) -(defun find-library--from-load-path (library) +(defun find-library--from-load-history (library) ;; In `load-history', the file may be ".elc", ".el", ".el.gz", and - ;; LIBRARY may be "foo.el" or "foo", so make sure that we get all - ;; potential matches, and then see whether any of them lead us to an - ;; ".el" or an ".el.gz" file. - (let* ((elc-regexp "\\.el\\(c\\(\\..*\\)?\\)\\'") - (suffix-regexp - (concat "\\(" - (mapconcat 'regexp-quote (find-library-suffixes) "\\'\\|") - "\\|" elc-regexp "\\)\\'")) - (potentials - (mapcar - (lambda (entry) - (if (string-match suffix-regexp (car entry)) - (replace-match "" t t (car entry)) - (car entry))) - (seq-filter - (lambda (entry) - (string-match - (concat "\\`" - (regexp-quote - (replace-regexp-in-string suffix-regexp "" library)) - suffix-regexp) - (file-name-nondirectory (car entry)))) - load-history))) - result) - (dolist (file potentials) - (dolist (suffix (find-library-suffixes)) - (when (not result) - (cond ((file-exists-p file) - (setq result file)) - ((file-exists-p (concat file suffix)) - (setq result (concat file suffix))))))) - result)) + ;; LIBRARY may be "foo.el" or "foo". + (let ((load-re + (concat "\\(" (regexp-quote (file-name-sans-extension library)) "\\)" + (regexp-opt (get-load-suffixes)) "\\'"))) + (cl-loop + for (file . _) in load-history thereis + (and (stringp file) (string-match load-re file) + (let ((dir (substring file 0 (match-beginning 1))) + (basename (match-string 1 file))) + (locate-file basename (list dir) (find-library-suffixes))))))) (defvar find-function-C-source-directory (let ((dir (expand-file-name "src" source-directory))) -- 2.11.1 --=-=-=--