unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9440: 24.0.50; bad error handling in find-function-C-source-directory
@ 2011-09-05 12:27 Alexander Klimov
  2011-09-07  1:06 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Klimov @ 2011-09-05 12:27 UTC (permalink / raw)
  To: 9440

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-07 12:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05 12:27 bug#9440: 24.0.50; bad error handling in find-function-C-source-directory Alexander Klimov
2011-09-07  1:06 ` Stefan Monnier
2011-09-07 12:19   ` Alexander Klimov

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).