unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alexander Klimov <alserkli@inbox.ru>
To: 9440@debbugs.gnu.org
Subject: bug#9440: 24.0.50; bad error handling in find-function-C-source-directory
Date: Mon, 5 Sep 2011 15:27:10 +0300	[thread overview]
Message-ID: <TheMailAgent.ad064ca1b5b814@e374c225d124866d827b> (raw)

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





             reply	other threads:[~2011-09-05 12:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-05 12:27 Alexander Klimov [this message]
2011-09-07  1:06 ` bug#9440: 24.0.50; bad error handling in find-function-C-source-directory Stefan Monnier
2011-09-07 12:19   ` Alexander Klimov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TheMailAgent.ad064ca1b5b814@e374c225d124866d827b \
    --to=alserkli@inbox.ru \
    --cc=9440@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).