diff lisp/help-fns.el @ 83627:422451dd396a

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 765-770) - Update from CVS - Merge from emacs--rel--22 - Merge from gnus--rel--5.10 * emacs--rel--22 (patch 24-25) * gnus--rel--5.10 (patch 222-223) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-16
author Miles Bader <miles@gnu.org>
date Fri, 25 May 2007 02:47:22 +0000
parents b8d9a391daf3 fc951d52295d
children 65663fcd2caa
line wrap: on
line diff
--- a/lisp/help-fns.el	Thu May 24 02:14:22 2007 +0000
+++ b/lisp/help-fns.el	Fri May 25 02:47:22 2007 +0000
@@ -232,6 +232,23 @@
 	      libname)
 	  file))))
 
+(defun find-source-lisp-file (file-name)
+  (let* ((elc-file (locate-file (concat file-name
+				 (if (string-match "\\.el" file-name)
+				     "c"
+				   ".elc"))
+				 load-path))
+	 (str (if (and elc-file (file-readable-p elc-file))
+		  (with-temp-buffer 
+		    (insert-file-contents-literally elc-file nil 0 256)
+		    (buffer-string))))
+	 (src-file (and str
+			(string-match ";;; from file \\(.*\\.el\\)" str)
+			(match-string 1 str))))
+    (if (and src-file (file-readable-p src-file))
+	src-file
+      file-name)))
+
 ;;;###autoload
 (defun describe-function-1 (function)
   (let* ((def (if (symbolp function)
@@ -309,6 +326,10 @@
       ;; but that's completely wrong when the user used load-file.
       (princ (if (eq file-name 'C-source) "C source code" file-name))
       (princ "'")
+      ;; See if lisp files are present where they where installed from.
+      (if (not (eq file-name 'C-source))
+	  (setq file-name (find-source-lisp-file file-name)))
+
       ;; Make a hyperlink to the library.
       (with-current-buffer standard-output
         (save-excursion