]> git.eshelyaron.com Git - emacs.git/commitdiff
Default argument for find-library
authorVinicius Jose Latorre <viniciusjl@ig.com.br>
Wed, 31 Oct 2007 12:39:44 +0000 (12:39 +0000)
committerVinicius Jose Latorre <viniciusjl@ig.com.br>
Wed, 31 Oct 2007 12:39:44 +0000 (12:39 +0000)
lisp/ChangeLog
lisp/emacs-lisp/find-func.el

index a8e111cb2ed7b1e3c9b818efb7db5f15cca780b7..cdd1822303ddb43a57ed57358d98ec4bcc2b2dd8 100644 (file)
@@ -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>
 
        * shadowfile.el (shadow-join): Remove.
index 20b91b10547a0694093390e5cece95e467efc237..b3c7c339030daff2647eae56d6803fc273bc0a38 100644 (file)
@@ -192,11 +192,21 @@ TYPE should be nil to find a function, or `defvar' to find a variable."
 (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)))))