From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Newsgroups: gmane.emacs.bugs Subject: bug#24697: 25.1; find-lisp-object-file-name may return wrong locations Date: Sun, 18 Jun 2017 20:59:25 -0600 Message-ID: <87y3soel82.fsf@lylat> References: <87mvi68tg4.fsf@gmail.com> <87r2yiz1w8.fsf@lylat> <5f2268ec-ae50-a75a-cc28-5e407b524974@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1497841275 15652 195.159.176.226 (19 Jun 2017 03:01:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Jun 2017 03:01:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 24697@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 19 05:01:09 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 1dMmw9-0003jv-6n for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Jun 2017 05:01:09 +0200 Original-Received: from localhost ([::1]:40315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMmwC-0002lu-W8 for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Jun 2017 23:01:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMmw7-0002kn-4O for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:01:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMmw2-00083y-9E for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:01:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52812) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMmw2-00083m-3N for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dMmw1-0000nX-O8 for bug-gnu-emacs@gnu.org; Sun, 18 Jun 2017 23:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Jun 2017 03:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24697 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24697-submit@debbugs.gnu.org id=B24697.14978412143003 (code B ref 24697); Mon, 19 Jun 2017 03:01:01 +0000 Original-Received: (at 24697) by debbugs.gnu.org; 19 Jun 2017 03:00:14 +0000 Original-Received: from localhost ([127.0.0.1]:55489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMmvF-0000mN-Ty for submit@debbugs.gnu.org; Sun, 18 Jun 2017 23:00:14 -0400 Original-Received: from mail-it0-f46.google.com ([209.85.214.46]:37305) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dMmvE-0000mA-Eo for 24697@debbugs.gnu.org; Sun, 18 Jun 2017 23:00:13 -0400 Original-Received: by mail-it0-f46.google.com with SMTP id m47so49892693iti.0 for <24697@debbugs.gnu.org>; Sun, 18 Jun 2017 20:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=7GQmB4pXwHKMpqrbsW3Uiecf3I+RlU5ifOsOzLcXe+8=; b=MPnmTUROFcj9tgpRHGcR/Unk6VtJAv8+wINToxHkzayC1grifnuZWhFGJ+D6DMdy5F AKK5PjW7LN4M5b12S/1yg8FfCqRbTn6RI0s1da+Z2GiTpeM0LSVT4yvzIHF0XC+OpExO DkxUrn8ztkczHA58KY6i8DBi8mfyLdIcBXaIkYywJknyXSHIMNYBnIssNWqNqv3AoJZq MwTutfn/55R1RgG3JbbytJY0bYgrsaIAF8uFLnXprOJ7hNzMnp4CZWFL0htL4Bd0pqks vtrrW0DihsfBCIyjDGIfdBYyGXq8yEkwLsaxKJ/s2XOjnbmztkICz4B7FMSnr6Xr1VSP dz8A== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=7GQmB4pXwHKMpqrbsW3Uiecf3I+RlU5ifOsOzLcXe+8=; b=cnbSIP9XVn6LWNRajS/TZ1W7hYR5kG0YVcdzBqBsm6u7tRpHARWB4Pqd4Ex6tG6nHG iUsRFw8WJU7E/vFKSXGWpDfrXsfco71Q/6jWFhGeBzSnJJVzlY45NAVLbbbIWCnf2ST4 x8am9HXniUgPhfSU8a5GnB9drnzC/W63Bat03pcy4UW29tKU6wcFtVKrw+ORUnczQOUF CznlEQCh3XRJTEcfddipUcz1lvpvDZ7spjK/Cvy4oRPAb4LxSWhNYsH6Q5eLXG/F6KvB 6HTjv9EKpa3gHh0BXO1fzsCRvbQtzolh9mQOi7MvBYoJMnnklSg1QD+/gyiZ1Cn5CLwl wIYg== X-Gm-Message-State: AKS2vOx2pblsmXSK5jT1LMIau2Kue4MIDZsg6WNK0rpJiMzoI10+ya7s WikxcS8Bvyj9cX8d X-Received: by 10.36.194.71 with SMTP id i68mr21133381itg.106.1497841206372; Sun, 18 Jun 2017 20:00:06 -0700 (PDT) Original-Received: from lylat (S010664777d9cebe3.ss.shawcable.net. [70.64.85.59]) by smtp.gmail.com with ESMTPSA id b70sm5052184ioe.57.2017.06.18.20.00.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Jun 2017 20:00:05 -0700 (PDT) In-Reply-To: <5f2268ec-ae50-a75a-cc28-5e407b524974@yandex.ru> (Dmitry Gutov's message of "Sun, 18 Jun 2017 22:51:43 +0300") 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:133740 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 6/18/17 1:26 AM, Alex wrote: > >> The first and last of these are fixed by the following diff. >> >> ... >> >> >> The second is a bit odder. For some reason, find-lisp-object-file-name >> searches for an internal function definition using TYPE instead of >> OBJECT. I would have expected it to use OBJECT like the rest of the >> tests do. I see no reason for the current behaviour. > > Thanks. Do you think you can write test cases for these problems? There are some > existing ones in test/lisp/help-fns-tests.el. Sure, I've attached a patch below for the simple cases. As I couldn't find a satisfactory way to make a temporary face, I just made an uninterned symbol that find-lisp-object-file-name would treat as an internal variable. >> Either the documentation should be changed to clearly indicate the >> current behaviour, or the function should be changed so that OBJECTs for >> which (subrp (symbol-function OBJECT)) returns t should return >> 'C-source'. > > With a test case, you might also find it easier to make a choice regarding this > problem. I'm not sure. I still don't understand why the design decision was made. I suppose one benefit is that one can search explicitly for internal functions rather than lisp functions, but the function could have just accepted 'subr instead of 'defun to do that. Perhaps the current use of searching with TYPE should be left in for backwards compatibility (a Github search shows at least 2 instances of 3rd-party code that makes use of that behaviour). For instance, here's how you find mapatoms' file: (find-lisp-object-file-name 'mapatoms (symbol-function 'mapatoms)) You should just be able to do the following: (find-lisp-object-file-name 'mapatoms 'defun) Or without searching for lisp functions named mapatoms first: (find-lisp-object-file-name 'mapatoms 'subr) What do you think? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Only-search-for-a-variable-when-instructed.patch >From 2ff6a3417278a5fae3328b1bdae5afcc7094d646 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Sun, 18 Jun 2017 18:59:11 -0600 Subject: [PATCH] Only search for a variable when instructed * lisp/help-fns.el (find-lisp-object-file-name): Check for 'defvar argument before searching for an internal variable (Bug#24697). * test/lisp/help-fns-tests.el: New tests. --- lisp/help-fns.el | 1 + test/lisp/help-fns-tests.el | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 2c635ffa50..bcf33131fa 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -319,6 +319,7 @@ find-lisp-object-file-name (help-C-file-name type 'subr) 'C-source)) ((and (not file-name) (symbolp object) + (eq type 'defvar) (integerp (get object 'variable-documentation))) ;; A variable defined in C. The form is from `describe-variable'. (if (get-buffer " *DOC*") diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el index 0ab6c3cae7..98898624db 100644 --- a/test/lisp/help-fns-tests.el +++ b/test/lisp/help-fns-tests.el @@ -118,4 +118,16 @@ defgh\\\[universal-argument\]b\`c\'d\\e\"f (goto-char (point-min)) (should (looking-at "^font-lock-comment-face is ")))) + +;;; Tests for find-lisp-object-file-name +(ert-deftest help-fns-test-bug24697-function-search () + (should-not (find-lisp-object-file-name 'tab-width 1))) + +(ert-deftest help-fns-test-bug24697-non-internal-variable () + (let ((help-fns--test-var (make-symbol "help-fns--test-var"))) + ;; simulate an internal variable + (put help-fns--test-var 'variable-documentation 1) + (should-not (find-lisp-object-file-name help-fns--test-var 'defface)) + (should-not (find-lisp-object-file-name help-fns--test-var 1)))) + ;;; help-fns.el ends here -- 2.11.0 --=-=-=--