[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9440: 24.0.50; bad error handling in find-function-C-source-director
bug#9440: 24.0.50; bad error handling in find-function-C-source-directory
Mon, 5 Sep 2011 15:27:10 +0300
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
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))
"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
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."
- (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))
+ ;; otherwise try to add "src"
+ (let ((dir-src (expand-file-name "src" dir)))
+ (if (file-readable-p (expand-file-name "emacs.c" 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"
- bug#9440: 24.0.50; bad error handling in find-function-C-source-directory,
Alexander Klimov <=