unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26712: other-window/frame versions of find-library
@ 2017-04-29 19:46 Charles A. Roelli
  2017-04-29 20:33 ` Drew Adams
  2017-05-06  9:56 ` Charles A. Roelli
  0 siblings, 2 replies; 22+ messages in thread
From: Charles A. Roelli @ 2017-04-29 19:46 UTC (permalink / raw)
  To: 26712

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

Attached is a patch to add other-window/frames version of the 
`find-library' command.

BTW, after I added the two new commands and rebuilt Emacs (with just 
`make'), I could not complete to them with `M-x find-library- TAB'.  I 
could only do this after loading the `find-func' library that contains 
them.  So I ran `make bootstrap' instead and then I could complete to 
them as expected.  I guess this means the autoloads had not been updated 
with just `make'... which command should I have run?  Bootstrapping 
takes awhile.

[-- Attachment #2: 0001-find-library-other-window-find-library-other-frame-N.patch --]
[-- Type: text/x-patch, Size: 5836 bytes --]

From 9e4f4ba788635240b84ccdaa336760aacaa93417 Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
Date: Sat, 29 Apr 2017 19:40:11 +0200
Subject: [PATCH] find-library-other-window, find-library-other-frame: New
 commands

* lisp/emacs-lisp/find-func.el (find-library-other-window)
(find-library-other-frame): New commands to complement the existing
`find-library' command.
(find-library-read): New function to read a library name.
(find-function-do-it): Fix indentation.
; * etc/NEWS (Changes in Emacs 26.1): Mention the new commands.
---
 etc/NEWS                     |    3 +
 lisp/emacs-lisp/find-func.el |  100 +++++++++++++++++++++++++-----------------
 2 files changed, 63 insertions(+), 40 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 9d4c72d..0425996 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -340,6 +340,9 @@ want to reverse the direction of the scroll, customize
 ** Emacsclient has a new option -u/--suppress-output.  The option
 suppresses display of return values from the server process.
 
+** Two new commands 'find-library-other-window' and
+'find-library-other-frame'.
+
 \f
 * Editing Changes in Emacs 26.1
 
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index d0acc14..1aea30c 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -271,42 +271,62 @@ find-function-C-source
     (cons (current-buffer) (match-beginning 0))))
 
 ;;;###autoload
-(defun find-library (library &optional other-window)
-  "Find the Emacs Lisp source of 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))
-          (table (apply-partially 'locate-file-completion-table
-                                  dirs suffixes))
-	  (def (if (eq (function-called-at-point) 'require)
-		   ;; `function-called-at-point' may return 'require
-		   ;; with `point' anywhere on this line.  So wrap the
-		   ;; `save-excursion' below in a `condition-case' to
-		   ;; avoid reporting a scan-error here.
-		   (condition-case nil
-		       (save-excursion
-			 (backward-up-list)
-			 (forward-char)
-			 (forward-sexp 2)
-			 (thing-at-point 'symbol))
-		     (error nil))
-		 (thing-at-point 'symbol))))
-     (when (and def (not (test-completion def table)))
-       (setq def nil))
-     (list
-      (completing-read (if def
-                           (format "Library name (default %s): " def)
-			 "Library name: ")
-		       table nil nil nil nil def)
-      current-prefix-arg)))
+(defun find-library (library)
+  "Find the Emacs Lisp source of the LIBRARY near point.
+
+LIBRARY should be a string (the name of the library)."
+  (interactive (find-library-read))
+  (prog1
+      (funcall 'switch-to-buffer
+               (find-file-noselect (find-library-name library)))
+    (run-hooks 'find-function-after-hook)))
+
+(defun find-library-read ()
+  "Read and return a library name, defaulting to the one near point."
+  (let* ((dirs (or find-function-source-path load-path))
+         (suffixes (find-library-suffixes))
+         (table (apply-partially 'locate-file-completion-table
+                                 dirs suffixes))
+         (def (if (eq (function-called-at-point) 'require)
+                  ;; `function-called-at-point' may return 'require
+                  ;; with `point' anywhere on this line.  So wrap the
+                  ;; `save-excursion' below in a `condition-case' to
+                  ;; avoid reporting a scan-error here.
+                  (condition-case nil
+                      (save-excursion
+                        (backward-up-list)
+                        (forward-char)
+                        (forward-sexp 2)
+                        (thing-at-point 'symbol))
+                    (error nil))
+                (thing-at-point 'symbol))))
+    (when (and def (not (test-completion def table)))
+      (setq def nil))
+    (list
+     (completing-read (if def
+                          (format "Library name (default %s): " def)
+                        "Library name: ")
+                      table nil nil nil nil def))))
+
+;;;###autoload
+(defun find-library-other-window (library)
+  "Find, in another window, the file defining LIBRARY at or near point.
+
+See `find-library' for more details."
+  (interactive (find-library-read))
+  (prog1
+      (funcall 'switch-to-buffer-other-window
+               (find-file-noselect (find-library-name library)))
+    (run-hooks 'find-function-after-hook)))
+
+;;;###autoload
+(defun find-library-other-frame (library)
+  "Find, in another frame, the file defining LIBRARY at or near point.
+
+See `find-library' for more details."
+  (interactive (find-library-read))
   (prog1
-      (funcall (if other-window
-                   'pop-to-buffer
-                 'pop-to-buffer-same-window)
+      (funcall 'switch-to-buffer-other-frame
                (find-file-noselect (find-library-name library)))
     (run-hooks 'find-function-after-hook)))
 
@@ -470,11 +490,11 @@ find-function-do-it
 
 Set mark before moving, if the buffer already existed."
   (let* ((orig-point (point))
-	(orig-buffers (buffer-list))
-	(buffer-point (save-excursion
-			(find-definition-noselect symbol type)))
-	(new-buf (car buffer-point))
-	(new-point (cdr buffer-point)))
+         (orig-buffers (buffer-list))
+         (buffer-point (save-excursion
+                         (find-definition-noselect symbol type)))
+         (new-buf (car buffer-point))
+         (new-point (cdr buffer-point)))
     (when buffer-point
       (when (memq new-buf orig-buffers)
 	(push-mark orig-point))
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-06-11 10:44 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-29 19:46 bug#26712: other-window/frame versions of find-library Charles A. Roelli
2017-04-29 20:33 ` Drew Adams
2017-04-30 18:16   ` Charles A. Roelli
2017-05-01 11:11     ` Philipp Stephani
2017-05-06  9:56 ` Charles A. Roelli
2017-05-07 12:08   ` Philipp Stephani
2017-05-07 13:36     ` Charles A. Roelli
2017-05-07 13:45       ` Philipp Stephani
2017-05-07 15:07         ` Drew Adams
2017-05-16 19:08           ` Charles A. Roelli
2017-05-16 19:36             ` Eli Zaretskii
2017-05-17 19:16               ` Charles A. Roelli
2017-05-20  0:54                 ` Howard Melman
2017-05-20  2:04                   ` Drew Adams
2017-05-20  3:24                     ` Howard Melman
2017-05-21  3:23                   ` Richard Stallman
2017-05-29 19:39                     ` Charles A. Roelli
2017-05-31  4:23                       ` Richard Stallman
2017-06-02 18:39                         ` Charles A. Roelli
2017-06-04  2:54                           ` Richard Stallman
2017-06-11 10:44                             ` Charles A. Roelli
2017-05-20 11:47                 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).