From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alexander Klimov Newsgroups: gmane.emacs.bugs Subject: bug#9440: 24.0.50; bad error handling in find-function-C-source-directory Date: Mon, 5 Sep 2011 15:27:10 +0300 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: dough.gmane.org 1315246633 3355 80.91.229.12 (5 Sep 2011 18:17:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Sep 2011 18:17:13 +0000 (UTC) To: 9440@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 05 20:17:09 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R0djI-0007uJ-HA for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Sep 2011 20:17:08 +0200 Original-Received: from localhost ([::1]:38882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0djI-000893-0z for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Sep 2011 14:17:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0dia-00080c-Oz for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2011 14:16:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0diW-0004pv-K0 for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2011 14:16:24 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0diW-0004pr-IQ for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2011 14:16:20 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1R0dm6-0003UG-QW; Mon, 05 Sep 2011 14:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alexander Klimov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Sep 2011 18:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9440 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.131524679913388 (code B ref -1); Mon, 05 Sep 2011 18:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Sep 2011 18:19:59 +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 1R0dm2-0003Tn-3F for submit@debbugs.gnu.org; Mon, 05 Sep 2011 14:19:59 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R0YKN-0005BY-WA for submit@debbugs.gnu.org; Mon, 05 Sep 2011 08:31:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0YGn-0007Ng-Gy for submit@debbugs.gnu.org; Mon, 05 Sep 2011 08:27:22 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:33358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0YGn-0007Na-FW for submit@debbugs.gnu.org; Mon, 05 Sep 2011 08:27:21 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0YGm-0002p5-EA for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2011 08:27:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0YGk-0007NA-VM for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2011 08:27:20 -0400 Original-Received: from www.eitan.edu ([199.203.54.24]:53272 helo=eitan.edu) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1R0YGk-0007N0-Mu for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2011 08:27:18 -0400 Original-Received: (qmail 13457 invoked from network); 5 Sep 2011 12:27:10 -0000 Original-Received: from unknown (HELO localhost) (127.0.0.1) by localhost with SMTP; 5 Sep 2011 12:27:10 -0000 X-detected-operating-system: by eggs.gnu.org: Solaris 9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 05 Sep 2011 14:19:56 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 05 Sep 2011 14:20:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-Mailman-Approved-At: Mon, 05 Sep 2011 14:17:06 -0400 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:50615 Archived-At: How to reproduce: Make sure that source-directory used to build Emacs does not currently exist. Run Emacs and try to find implementation of, for example, `eq': C-h f eq RET C-x o TAB RET Now, suppose, you do not know what exactly `Emacs C source dir' means and thus you enter say, `~/emacs/trunk'. Now you get find-function-C-source: The C source file data.c is not available and guess that the directory should actually be `~/emacs/trunk/src'. You try to correct the mistake by repeating the process (pressing RET on `C source code'), but now you are not asked about the directory and simply get the same error message again. To avoid the problem, Emacs should check that the directory indeed contains Emacs C sources. It is also a good idea to try to silently fix user's mistake by appending "src" to the directory he entered. The following patch fixes the problem: === modified file 'lisp/emacs-lisp/find-func.el' --- lisp/emacs-lisp/find-func.el 2011-08-21 17:43:31 +0000 +++ lisp/emacs-lisp/find-func.el 2011-09-05 11:59:04 +0000 @@ -181,7 +181,7 @@ (when (and (file-directory-p dir) (file-readable-p dir)) dir)) "Directory where the C source files of Emacs can be found. -If nil, do not try to find the source code of functions and variables +If nil, ask user when he tries to find the source code of functions and variables defined in C.") (declare-function ad-get-advice-info "advice" (function)) @@ -200,7 +200,14 @@ TYPE should be nil to find a function, or `defvar' to find a variable." (unless find-function-C-source-directory (setq find-function-C-source-directory - (read-directory-name "Emacs C source dir: " nil nil t))) + (let ((dir (read-directory-name "Emacs C source dir: " nil nil t))) + (if (file-readable-p (expand-file-name "emacs.c" dir)) + dir + ;; otherwise try to add "src" + (let ((dir-src (expand-file-name "src" dir))) + (if (file-readable-p (expand-file-name "emacs.c" dir-src)) + dir-src + (error "%s does not contain Emacs C sources" dir))))))) (setq file (expand-file-name file find-function-C-source-directory)) (unless (file-readable-p file) (error "The C source file %s is not available" -- Regards, ASK