all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Charles A. Roelli" <charles@aurox.ch>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 26712@debbugs.gnu.org, p.stephani2@gmail.com
Subject: bug#26712: other-window/frame versions of find-library
Date: Wed, 17 May 2017 21:16:57 +0200	[thread overview]
Message-ID: <afe910cf-4638-8d5f-644b-8002f284a54f@aurox.ch> (raw)
In-Reply-To: <83tw4k61bv.fsf@gnu.org>

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

Thank you for your comments.  Please see again the attachment.

On 16/05/2017 21:36, Eli Zaretskii wrote:
>> +** Two new commands 'find-library-other-window' and
>> +'find-library-other-frame'.
> This is too terse.  A few words regarding what these do would be much
> better.

Updated:

+** Two new commands for finding the source code of Emacs Lisp
+libraries: 'find-library-other-window' and 'find-library-other-frame'.
+

>> +(defun find-library (library)
>> +  "Find the Emacs Lisp source of the LIBRARY near point.
> This is confusing, IMO.  Suggest to reword:
>
>      Find the Emacs Lisp source of LIBRARY.
>    Interactively, prompt for LIBRARY using the one at or near point as
>    the default.

Thanks, I've updated it.

>> +(defun read-library-name ()
>> +  "Read and return a library name, defaulting to the one near point."
> I would explain here what constitutes a "library name", i.e. how does
> the function determine the library name at point.

+A library name is the filename of an Emacs Lisp library located
+in a directory under `load-path' (or `find-function-source-path',
+if non-nil)."

>> +(defun find-library-other-window (library)
>> +  "Find, in another window, the file defining LIBRARY at or near point.
> Any reason why the wording is different from that of find-library?

Nope, I've also amended this.


[-- Attachment #2: 0001-New-commands-find-library-other-window-find-library-.patch --]
[-- Type: text/x-patch, Size: 5347 bytes --]

From 44f5a4f6fce2002c4d0c0030a3ef60d31f4b649a Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
Date: Wed, 17 May 2017 21:13:17 +0200
Subject: [PATCH] New commands: find-library-other-window,
 find-library-other-frame

* lisp/emacs-lisp/find-func.el (find-library-other-window)
(find-library-other-frame): New commands to complement the existing
`find-library' command.
(read-library-name): New function to read a library name.
---
 etc/NEWS                     |    3 +
 lisp/emacs-lisp/find-func.el |   92 ++++++++++++++++++++++++++----------------
 2 files changed, 60 insertions(+), 35 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 25f0f18..2b04ea5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -344,6 +344,9 @@ for DNS-querying functions 'nslookup-host', 'dns-lookup-host',
 and 'run-dig'.  Each function now accepts an optional name server
 argument interactively (with a prefix argument) and non-interactively.
 
+** Two new commands for finding the source code of Emacs Lisp
+libraries: '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..9b98f05 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -271,43 +271,65 @@ find-function-C-source
     (cons (current-buffer) (match-beginning 0))))
 
 ;;;###autoload
-(defun find-library (library &optional other-window)
+(defun find-library (library)
   "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)))
+
+Interactively, prompt for LIBRARY using the one at or near point."
+  (interactive (list (read-library-name)))
+  (prog1
+      (switch-to-buffer (find-file-noselect (find-library-name library)))
+    (run-hooks 'find-function-after-hook)))
+
+(defun read-library-name ()
+  "Read and return a library name, defaulting to the one near point.
+
+A library name is the filename of an Emacs Lisp library located
+in a directory under `load-path' (or `find-function-source-path',
+if non-nil)."
+  (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))
+    (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 the Emacs Lisp source of LIBRARY in another window.
+
+See `find-library' for more details."
+  (interactive (list (read-library-name)))
+  (prog1
+      (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 the Emacs Lisp source of LIBRARY in another frame.
+
+See `find-library' for more details."
+  (interactive (list (read-library-name)))
   (prog1
-      (funcall (if other-window
-                   'pop-to-buffer
-                 'pop-to-buffer-same-window)
-               (find-file-noselect (find-library-name library)))
+      (switch-to-buffer-other-frame (find-file-noselect
+                                     (find-library-name library)))
     (run-hooks 'find-function-after-hook)))
 
 ;;;###autoload
-- 
1.7.4.4


  reply	other threads:[~2017-05-17 19:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afe910cf-4638-8d5f-644b-8002f284a54f@aurox.ch \
    --to=charles@aurox.ch \
    --cc=26712@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.