all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* patch: default argument for find-library
@ 2007-10-23  6:19 Sean O'Rourke
  0 siblings, 0 replies; only message in thread
From: Sean O'Rourke @ 2007-10-23  6:19 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 314 bytes --]

This patch uses the library name at point as the interactive
default to `find-library' -- `find-variable' and `find-function'
already have analogous defaults.

/s

2007-10-22  Sean O'Rourke  <sorourke@cs.ucsd.edu>

	* emacs-lisp/find-func.el (find-library): use library at
	point as default interactive argument.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1453 bytes --]

Index: find-func.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/find-func.el,v
retrieving revision 1.82
diff -p -u -w -r1.82 find-func.el
--- find-func.el	17 Oct 2007 23:49:00 -0000	1.82
+++ find-func.el	23 Oct 2007 06:17:37 -0000
@@ -192,11 +192,21 @@ TYPE should be nil to find a function, o
 (defun find-library (library)
   "Find the elisp source of LIBRARY."
   (interactive
+   (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 "Library name: "
-		     'locate-file-completion
-		     (cons (or find-function-source-path load-path)
-			   (find-library-suffixes)))))
+      (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)))))
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-23  6:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-23  6:19 patch: default argument for find-library Sean O'Rourke

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.