changeset 79289:a6f04138250e

Default argument for find-library
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Wed, 31 Oct 2007 12:46:29 +0000
parents 60939d2c4cf8
children 38be7cabc3fb
files lisp/ChangeLog lisp/emacs-lisp/find-func.el
diffstat 2 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Oct 31 12:19:55 2007 +0000
+++ b/lisp/ChangeLog	Wed Oct 31 12:46:29 2007 +0000
@@ -1,3 +1,8 @@
+2007-10-31  Sean O'Rourke  <sorourke@cs.ucsd.edu>
+
+	* emacs-lisp/find-func.el (find-library): use library at
+	point as default interactive argument.
+
 2007-10-31  Juanma Barranquero  <lekktu@gmail.com>
 
 	* emacs-lisp/elp.el (elp-report-limit, elp-restore-all)
--- a/lisp/emacs-lisp/find-func.el	Wed Oct 31 12:19:55 2007 +0000
+++ b/lisp/emacs-lisp/find-func.el	Wed Oct 31 12:46:29 2007 +0000
@@ -194,11 +194,21 @@
 (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* ((path (cons (or find-function-source-path load-path)
+		      (find-library-suffixes)))
+	  (def (if (eq (function-called-at-point) 'require)
+		   (save-excursion
+		     (backward-up-list)
+		     (forward-char)
+		     (backward-sexp -2)
+		     (thing-at-point 'symbol))
+		 (thing-at-point 'symbol))))
+     (when def
+       (setq def (and (locate-file-completion def path 'test) def)))
+     (list
+      (completing-read (if def (format "Library name (default %s): " def)
+			 "Library name: ")
+		       'locate-file-completion path nil nil nil def))))
   (let ((buf (find-file-noselect (find-library-name library))))
     (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))