+(defun find-library-suffixes ()
+ (let ((suffixes nil))
+ (dolist (suffix load-suffixes (nreverse suffixes))
+ (unless (string-match "elc" suffix) (push suffix suffixes)))))
+
+(defun find-library-name (library)
+ "Return the full name of the elisp source of LIBRARY."
+ ;; If the library is byte-compiled, try to find a source library by
+ ;; the same name.
+ (if (string-match "\\.el\\(c\\(\\..*\\)\\)\\'" library)
+ (setq library (replace-match "" t t library 1)))
+ (or (locate-file library
+ (or find-function-source-path load-path)
+ (find-library-suffixes))
+ (error "Can't find library %s" file)))
+
+;;;###autoload
+(defun find-library (library)
+ "Find the elisp source of LIBRARY."
+ (interactive
+ (list
+ (completing-read "Library name: "
+ 'locate-file-completion
+ (cons (or find-function-source-path load-path)
+ (find-library-suffixes)))))
+ (let ((buf (find-file-noselect (find-library-name library))))
+ (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
+