]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow a prefix argument to find-library to pop to a different window
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2016 17:25:21 +0000 (19:25 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2016 17:25:21 +0000 (19:25 +0200)
* lisp/emacs-lisp/find-func.el (find-library): Allow a prefix
argument to pop to a different window (bug#2270).

etc/NEWS
lisp/emacs-lisp/find-func.el

index 2aeee96a93003888ed26839b0488fbab1993b94e..ef2b4b01f60449ff167f02f73512457d5bf1e181 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -56,6 +56,10 @@ affected by this, as SGI stopped supporting IRIX in December 2013.
 \f
 * Changes in Emacs 25.2
 
+---
+** `find-library' now takes a prefix argument to pop to a different
+window.
+
 ** `find-library', `help-function-def' and `help-variable-def' now run
 `find-function-after-hook'.
 
index b04a9d2dea53f57f1e30cacfb28a78255795a043..3bbf8091a9e6d694b7274b7c1c2456659902b009 100644 (file)
@@ -255,9 +255,12 @@ TYPE should be nil to find a function, or `defvar' to find a variable."
     (cons (current-buffer) (match-beginning 0))))
 
 ;;;###autoload
-(defun find-library (library)
+(defun find-library (library &optional other-window)
   "Find the Emacs Lisp source of LIBRARY.
-LIBRARY should be a string (the name of the library)."
+LIBRARY should be a string (the name of the library).  If the
+optional OTHER-WINDOW argument (i.e., the command argument) is
+specified, pop to a different window before displaying the
+buffer."
   (interactive
    (let* ((dirs (or find-function-source-path load-path))
           (suffixes (find-library-suffixes))
@@ -279,15 +282,17 @@ LIBRARY should be a string (the name of the library)."
      (when (and def (not (test-completion def table)))
        (setq def nil))
      (list
-      (completing-read (if def (format "Library name (default %s): " def)
+      (completing-read (if def
+                           (format "Library name (default %s): " def)
                         "Library name: ")
-                      table nil nil nil nil def))))
-  (let ((buf (find-file-noselect (find-library-name library))))
-    (condition-case nil
-        (prog1
-            (switch-to-buffer buf)
-          (run-hooks 'find-function-after-hook))
-      (error (pop-to-buffer buf)))))
+                      table nil nil nil nil def)
+      current-prefix-arg)))
+  (prog1
+      (funcall (if other-window
+                   'pop-to-buffer
+                 'pop-to-buffer-same-window)
+               (find-file-noselect (find-library-name library)))
+    (run-hooks 'find-function-after-hook)))
 
 ;;;###autoload
 (defun find-function-search-for-symbol (symbol type library)