all messages for Emacs-related lists mirrored at yhetil.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

* bug#26712: other-window/frame versions of find-library
  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-06  9:56 ` Charles A. Roelli
  1 sibling, 1 reply; 22+ messages in thread
From: Drew Adams @ 2017-04-29 20:33 UTC (permalink / raw)
  To: Charles A. Roelli, 26712

> 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.

FWIW, I proposed this in March 2007 ("Please add
`find-library-other-window'")
http://lists.gnu.org/archive/html/emacs-devel/2007-03/msg01073.html

I was told not to propose new features at that time.

I proposed it again in June 2007 ("how about a
find-library-other-window command?",
http://lists.gnu.org/archive/html/emacs-devel/2007-06/msg01306.html).

That thread was hijacked to a discussion about simulating
all `-other-*' commands automatically (still one of Stefan's
quests, I believe).

I more than once tried to bring the discussion back on topic.
http://lists.gnu.org/archive/html/emacs-devel/2007-06/msg01319.html

["This is all beginning to sound a bit complex. Perhaps worth
exploring, but, in the meantime, could we at least add
`find-library-other-window'? ;-)"]

RMS, at least, responded favorably, asking for a patch.

Juri complained that "polluting the namespace is not a good
thing.  There are too many commands that display a new buffer,
and don't have the duplicate name with the `-other-window'
suffix, and adding more redundant commands will increase the mess."

I sent the patch anyway.
http://lists.gnu.org/archive/html/emacs-devel/2007-06/msg01428.html

RMS agreed to it and asked that someone install it.

Juri complained that the code was repetitive for the 3
commands.  It was never installed.

Glad to see it finally added to Emacs.  I've been using it
for 10 years.  I bind it to `C-x 4 l'.  (I never use plain
`find-library'.)





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

* bug#26712: other-window/frame versions of find-library
  2017-04-29 20:33 ` Drew Adams
@ 2017-04-30 18:16   ` Charles A. Roelli
  2017-05-01 11:11     ` Philipp Stephani
  0 siblings, 1 reply; 22+ messages in thread
From: Charles A. Roelli @ 2017-04-30 18:16 UTC (permalink / raw)
  To: Drew Adams, 26712

Not sure why this mundane feature generates so much contention...






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

* bug#26712: other-window/frame versions of find-library
  2017-04-30 18:16   ` Charles A. Roelli
@ 2017-05-01 11:11     ` Philipp Stephani
  0 siblings, 0 replies; 22+ messages in thread
From: Philipp Stephani @ 2017-05-01 11:11 UTC (permalink / raw)
  To: Charles A. Roelli, Drew Adams, 26712

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

Charles A. Roelli <charles@aurox.ch> schrieb am So., 30. Apr. 2017 um
20:17 Uhr:

> Not sure why this mundane feature generates so much contention...
>

Parkinson's law of triviality.

[-- Attachment #2: Type: text/html, Size: 458 bytes --]

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

* bug#26712: other-window/frame versions of find-library
  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-05-06  9:56 ` Charles A. Roelli
  2017-05-07 12:08   ` Philipp Stephani
  1 sibling, 1 reply; 22+ messages in thread
From: Charles A. Roelli @ 2017-05-06  9:56 UTC (permalink / raw)
  To: 26712

Ping!  Comments?

On 29/04/2017 21:46, Charles A. Roelli wrote:
> 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.





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

* bug#26712: other-window/frame versions of find-library
  2017-05-06  9:56 ` Charles A. Roelli
@ 2017-05-07 12:08   ` Philipp Stephani
  2017-05-07 13:36     ` Charles A. Roelli
  0 siblings, 1 reply; 22+ messages in thread
From: Philipp Stephani @ 2017-05-07 12:08 UTC (permalink / raw)
  To: Charles A. Roelli, 26712

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

My approach has been lately: if nobody has commented on a patch for a week,
then just install it.

Charles A. Roelli <charles@aurox.ch> schrieb am Sa., 6. Mai 2017 um
11:57 Uhr:

> Ping!  Comments?
>
> On 29/04/2017 21:46, Charles A. Roelli wrote:
> > 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: Type: text/html, Size: 1170 bytes --]

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

* bug#26712: other-window/frame versions of find-library
  2017-05-07 12:08   ` Philipp Stephani
@ 2017-05-07 13:36     ` Charles A. Roelli
  2017-05-07 13:45       ` Philipp Stephani
  0 siblings, 1 reply; 22+ messages in thread
From: Charles A. Roelli @ 2017-05-07 13:36 UTC (permalink / raw)
  To: Philipp Stephani, 26712

I would install it, but I don't have commit access.  I'll put in a 
request for that now on Savannah, since I'd also like to work on a few 
issues with the NS port.







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

* bug#26712: other-window/frame versions of find-library
  2017-05-07 13:36     ` Charles A. Roelli
@ 2017-05-07 13:45       ` Philipp Stephani
  2017-05-07 15:07         ` Drew Adams
  0 siblings, 1 reply; 22+ messages in thread
From: Philipp Stephani @ 2017-05-07 13:45 UTC (permalink / raw)
  To: Charles A. Roelli, 26712

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

Charles A. Roelli <charles@aurox.ch> schrieb am So., 7. Mai 2017 um
15:36 Uhr:

> I would install it, but I don't have commit access.


Ah, OK. Then a couple of minor comments:

- Consider renaming `find-library-read' to `find-func--read-library' to
make it internal. It's probably not intended as a public API.

- (funcall 'foo ...) should be written as (foo ...)

- Please revert unrelated whitespace changes (changing tabs to spaces in
find-function-do-it)

[-- Attachment #2: Type: text/html, Size: 821 bytes --]

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

* bug#26712: other-window/frame versions of find-library
  2017-05-07 13:45       ` Philipp Stephani
@ 2017-05-07 15:07         ` Drew Adams
  2017-05-16 19:08           ` Charles A. Roelli
  0 siblings, 1 reply; 22+ messages in thread
From: Drew Adams @ 2017-05-07 15:07 UTC (permalink / raw)
  To: Philipp Stephani, Charles A. Roelli, 26712

> - Consider renaming `find-library-read' to
>   `find-func--read-library' to make it internal.
>   It's probably not intended as a public API.

Why?  No.  Please do not consider that.  Not for a moment.

FWIW, I completely disagree with this point of view and
approach to Emacs Lisp.  Just the opposite.  Unless there is
some _very_ important reason why something _must_ be branded
as "internal", it should not be.

It may be a hard habit to break, but the notion of a "public
API" is generally inappropriate for Emacs Lisp.  Emacs users
are also Emacs-Lisp developers. And yes, they do write their
own libraries that read input.

Just imagine, if an input-reading function such as
`ffap-read-file-or-url', `read-file-name', `completing-read',
`read-face-name', or `read-char' were declared at the outset
to be "internal".  What's the point of such an artificial 
separation?

In fact, I'd suggest that the library prefix be removed from
`find-library-read' - just call it `read-library-name'.
Elevate it; don't hide or suppress it.

GNU Emacs in particular, and free software in general, have
the explicit intention that users _are_ developers and that
they look under the hood, tinker with engine parts, modify
or make their own use of them, to create new and better
things.

And yes, Emacs development is driven not only by its
maintainers or those most active in its C code or fixing
its bugs.  It is driven also, and importantly, by users,
who write their own code for their own uses, and who
sometimes extend that code into 3rd-party libraries.

Some such development even finds its way into distributed
Emacs itself - either directly, by incorporating it, or
indirectly, by copy or inspiration.  The latter happens
more than most people, including Emacs maintainers, are
aware of.

Emacs would not be what it is today if it did not offer
features written by its users (think Org).  And this has
been true of Emacs since Day One - even before GNU Emacs.

So let's please stop with the tendency to view Emacs
development as an internal-vs-external thing: we core
developers and the code we maintain vs you "lusers" and
your customizations.

If we are to have _any_ "internal" functions or variables
then the burden should be to demonstrate strongly why
a given one really _needs_ to be internal.  A priori,
every single one should be "external" or, more exactly, 
"nil-ternal".

I see no good reason why a general function that reads a
library name should be flagged "internal".  Why should
anyone be discouraged from using it in their code?  Why
shouldn't everyone be encouraged to use it, if they want
to read a library name?

This kind of not-for-the-users attitude smacks of
elitism, or at least seems control-freakish, even if it
is unconscious.  Open the corral, please.  Emacs, and
all of its code, belongs to its users.

There is nothing special about this function.  It is
useful generally.  And it should be called something
like `read-library-name'.





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

* bug#26712: other-window/frame versions of find-library
  2017-05-07 15:07         ` Drew Adams
@ 2017-05-16 19:08           ` Charles A. Roelli
  2017-05-16 19:36             ` Eli Zaretskii
  0 siblings, 1 reply; 22+ messages in thread
From: Charles A. Roelli @ 2017-05-16 19:08 UTC (permalink / raw)
  To: Drew Adams, Philipp Stephani, 26712

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

I agree.  Not sure if the `read-library' function should go in a 
different file, but in any case it makes sense to let users take 
advantage of it in their code.


Attached is a revised patch with Philipp's other suggestions taken into 
account.


On 07/05/2017 17:07, Drew Adams wrote:
>> - Consider renaming `find-library-read' to
>>    `find-func--read-library' to make it internal.
>>    It's probably not intended as a public API.
> Why?  No.  Please do not consider that.  Not for a moment.
>
> FWIW, I completely disagree with this point of view and
> approach to Emacs Lisp.  Just the opposite.  Unless there is
> some _very_ important reason why something _must_ be branded
> as "internal", it should not be.
>
> It may be a hard habit to break, but the notion of a "public
> API" is generally inappropriate for Emacs Lisp.  Emacs users
> are also Emacs-Lisp developers. And yes, they do write their
> own libraries that read input.
>
> Just imagine, if an input-reading function such as
> `ffap-read-file-or-url', `read-file-name', `completing-read',
> `read-face-name', or `read-char' were declared at the outset
> to be "internal".  What's the point of such an artificial
> separation?
>
> In fact, I'd suggest that the library prefix be removed from
> `find-library-read' - just call it `read-library-name'.
> Elevate it; don't hide or suppress it.
>
> GNU Emacs in particular, and free software in general, have
> the explicit intention that users _are_ developers and that
> they look under the hood, tinker with engine parts, modify
> or make their own use of them, to create new and better
> things.
>
> And yes, Emacs development is driven not only by its
> maintainers or those most active in its C code or fixing
> its bugs.  It is driven also, and importantly, by users,
> who write their own code for their own uses, and who
> sometimes extend that code into 3rd-party libraries.
>
> Some such development even finds its way into distributed
> Emacs itself - either directly, by incorporating it, or
> indirectly, by copy or inspiration.  The latter happens
> more than most people, including Emacs maintainers, are
> aware of.
>
> Emacs would not be what it is today if it did not offer
> features written by its users (think Org).  And this has
> been true of Emacs since Day One - even before GNU Emacs.
>
> So let's please stop with the tendency to view Emacs
> development as an internal-vs-external thing: we core
> developers and the code we maintain vs you "lusers" and
> your customizations.
>
> If we are to have _any_ "internal" functions or variables
> then the burden should be to demonstrate strongly why
> a given one really _needs_ to be internal.  A priori,
> every single one should be "external" or, more exactly,
> "nil-ternal".
>
> I see no good reason why a general function that reads a
> library name should be flagged "internal".  Why should
> anyone be discouraged from using it in their code?  Why
> shouldn't everyone be encouraged to use it, if they want
> to read a library name?
>
> This kind of not-for-the-users attitude smacks of
> elitism, or at least seems control-freakish, even if it
> is unconscious.  Open the corral, please.  Emacs, and
> all of its code, belongs to its users.
>
> There is nothing special about this function.  It is
> useful generally.  And it should be called something
> like `read-library-name'.


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

From 7edba19c49edeaa5efe244397dcd93f99fa6705d Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
Date: Tue, 16 May 2017 20:40:50 +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 |   90 +++++++++++++++++++++++++-----------------
 2 files changed, 57 insertions(+), 36 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 25f0f18..bea4928 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 '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..43be71b 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -271,44 +271,61 @@ 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 (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."
+  (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, in another window, the file defining LIBRARY at or near point.
+
+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, in another frame, the file defining LIBRARY at or near point.
+
+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


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

* bug#26712: other-window/frame versions of find-library
  2017-05-16 19:08           ` Charles A. Roelli
@ 2017-05-16 19:36             ` Eli Zaretskii
  2017-05-17 19:16               ` Charles A. Roelli
  0 siblings, 1 reply; 22+ messages in thread
From: Eli Zaretskii @ 2017-05-16 19:36 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 26712, p.stephani2

> From: "Charles A. Roelli" <charles@aurox.ch>
> Date: Tue, 16 May 2017 21:08:07 +0200
> 
> Attached is a revised patch with Philipp's other suggestions taken into 
> account.

Thanks.  A few comments:

> +** 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.

> +(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.

> +(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.

> +(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?





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

* bug#26712: other-window/frame versions of find-library
  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 11:47                 ` Eli Zaretskii
  0 siblings, 2 replies; 22+ messages in thread
From: Charles A. Roelli @ 2017-05-17 19:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 26712, p.stephani2

[-- 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


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

* bug#26712: other-window/frame versions of find-library
  2017-05-17 19:16               ` Charles A. Roelli
@ 2017-05-20  0:54                 ` Howard Melman
  2017-05-20  2:04                   ` Drew Adams
  2017-05-21  3:23                   ` Richard Stallman
  2017-05-20 11:47                 ` Eli Zaretskii
  1 sibling, 2 replies; 22+ messages in thread
From: Howard Melman @ 2017-05-20  0:54 UTC (permalink / raw)
  To: 26712


I didn't see this in the patch, but can I suggest that
find-function-setup-keys bind these new commands (and find-library) to "C-x L",
"C-x 4 L" and "C-x 5 L"?

-- 

Howard






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

* bug#26712: other-window/frame versions of find-library
  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
  1 sibling, 1 reply; 22+ messages in thread
From: Drew Adams @ 2017-05-20  2:04 UTC (permalink / raw)
  To: Howard Melman, 26712

> I didn't see this in the patch, but can I suggest that
> find-function-setup-keys bind these new commands (and find-library) to "C-x
> L", "C-x 4 L" and "C-x 5 L"?

+1.  But personally I'd prefer lowercase `l', not `L'.  I almost
_never_ use `count-lines-page', and I use `find-library-other-window'
several times a day.  And I'm probably one of the few people who
actually does use page commands.  That's just not that useful a
command, for me.)

FWIW, I suggsested in my original request for this, years ago, that
we use `C-x 4 l' for other-window.  I've been using that for years.
(I use non-nil `pop-up-frames', so I `other-window' acts like
other-frame.)





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

* bug#26712: other-window/frame versions of find-library
  2017-05-20  2:04                   ` Drew Adams
@ 2017-05-20  3:24                     ` Howard Melman
  0 siblings, 0 replies; 22+ messages in thread
From: Howard Melman @ 2017-05-20  3:24 UTC (permalink / raw)
  To: 26712

Drew Adams <drew.adams@oracle.com> writes:

>> I didn't see this in the patch, but can I suggest that
>> find-function-setup-keys bind these new commands (and find-library) to "C-x
>> L", "C-x 4 L" and "C-x 5 L"?
>
> +1.  But personally I'd prefer lowercase `l', not `L'.  I almost
> _never_ use `count-lines-page', and I use `find-library-other-window'
> several times a day.  And I'm probably one of the few people who
> actually does use page commands.  That's just not that useful a
> command, for me.)
>
> FWIW, I suggsested in my original request for this, years ago, that
> we use `C-x 4 l' for other-window.  I've been using that for years.
> (I use non-nil `pop-up-frames', so I `other-window' acts like
> other-frame.)

I suggested L because it matches with the other bindings in
find-function-setup-keys and I'll remember them better if
all are on upppercase letters rather than some on upper and
some on lowercase.

-- 

Howard






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

* bug#26712: other-window/frame versions of find-library
  2017-05-17 19:16               ` Charles A. Roelli
  2017-05-20  0:54                 ` Howard Melman
@ 2017-05-20 11:47                 ` Eli Zaretskii
  1 sibling, 0 replies; 22+ messages in thread
From: Eli Zaretskii @ 2017-05-20 11:47 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: p.stephani2, 26712-done

> Cc: drew.adams@oracle.com, p.stephani2@gmail.com, 26712@debbugs.gnu.org
> From: "Charles A. Roelli" <charles@aurox.ch>
> Date: Wed, 17 May 2017 21:16:57 +0200
> 
> Thank you for your comments.  Please see again the attachment.

Thanks, pushed.

A couple of nits for the future:

 . etc/NEWS changes should be mentioned in the commit log.
 . If the patches were posted as a bug report, please mention the bug
   number in the log message.
 . We prefer quoting symbol names 'like this', not `like this'.





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

* bug#26712: other-window/frame versions of find-library
  2017-05-20  0:54                 ` Howard Melman
  2017-05-20  2:04                   ` Drew Adams
@ 2017-05-21  3:23                   ` Richard Stallman
  2017-05-29 19:39                     ` Charles A. Roelli
  1 sibling, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2017-05-21  3:23 UTC (permalink / raw)
  To: Howard Melman; +Cc: 26712

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I think find-function is more useful to put on a key than
find-library.  Or perhaps they can be combined.  It should not be hard
to accept an argument and try it first as a function, then as a library.

If the name is both a function and a library, the function definition
is almost surely in that library.
-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#26712: other-window/frame versions of find-library
  2017-05-21  3:23                   ` Richard Stallman
@ 2017-05-29 19:39                     ` Charles A. Roelli
  2017-05-31  4:23                       ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: Charles A. Roelli @ 2017-05-29 19:39 UTC (permalink / raw)
  To: 26712

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

Good idea.  Is the attached patch OK?  It augments 'C-x F', 'C-x 4 F'
and 'C-x 5 F' to suggest library names too.

On 21/05/2017 05:23, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> I think find-function is more useful to put on a key than
> find-library.  Or perhaps they can be combined.  It should not be hard
> to accept an argument and try it first as a function, then as a library.
>
> If the name is both a function and a library, the function definition
> is almost surely in that library.
>

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

From 0c309fb5ad41d4c8c7e356ef365a02b6550a0e2e Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
Date: Mon, 29 May 2017 21:35:24 +0200
Subject: [PATCH] New commands: find-function-or-library
 (-other-window/-frame)

* lisp/emacs-lisp/find-func.el (read-function-or-library-name):
New function for reading a function or library name.
(find-function-or-library, find-function-or-library-other-window)
(find-function-or-library-other-frame): New commands.
(find-function-setup-keys): Replace 'find-function' bindings with
bindings to 'find-function-or-library'.
* etc/NEWS: Mention 'find-function-or-library' and new bindings
made by 'find-function-setup-keys'.
---
 etc/NEWS                     |    6 +++
 lisp/emacs-lisp/find-func.el |   90 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 93 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 60066b7..ee6efb9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -363,6 +363,12 @@ large integers from being displayed as characters.
 ** Two new commands for finding the source code of Emacs Lisp
 libraries: 'find-library-other-window' and 'find-library-other-frame'.
 
+** 'find-function-setup-keys' now binds 'C-x F', 'C-x 4 F' and 'C-x 5
+F' to the new command 'find-function-or-library' and its
+other-window/-frame counterparts.  The new commands find the Emacs
+Lisp source code of a function or library, defaulting to the function
+or library closest to point.
+
 \f
 * Editing Changes in Emacs 26.1
 
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 9b98f05..9943598 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -310,6 +310,40 @@ read-library-name
                        "Library name: ")
                      table nil nil nil nil def)))
 
+(defun read-function-or-library-name ()
+  "Read and return a function or library name, defaulting to the one near point.
+
+A function name is the name of a symbol that satisfies the
+predicate `fboundp'.  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 (completion-table-merge
+                 (apply-partially 'completion-table-with-predicate
+                                  obarray 'fboundp t)
+                 (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))
+                (symbol-name (function-called-at-point)))))
+    (when (and def (not (test-completion def table)))
+      (setq def nil))
+    (completing-read (if def
+                         (format "Function or library name (default %s): " def)
+                       "Function or 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.
@@ -537,6 +571,56 @@ find-function-other-frame
   (find-function-do-it function nil 'switch-to-buffer-other-frame))
 
 ;;;###autoload
+(defun find-function-or-library (function-or-library)
+  "Find the definition of the FUNCTION-OR-LIBRARY near point.
+
+Finds the source file containing the definition of the
+function (selected by `function-called-at-point') or
+library (loaded with `require') near point in a buffer and places
+point before the definition.
+
+FUNCTION-OR-LIBRARY is searched for in
+`find-function-source-path', if non-nil, otherwise in
+`load-path'.  See also `find-function-recenter-line' and
+`find-function-after-hook'.
+
+If FUNCTION-OR-LIBRARY names both a function and a library, finds
+the corresponding function definition."
+  (interactive (list (read-function-or-library-name)))
+  (let ((sym (if (stringp function-or-library)
+                 (intern function-or-library)
+               function-or-library)))
+    (if (fboundp sym)
+        (find-function-do-it sym nil 'switch-to-buffer)
+      (find-library function-or-library))))
+
+;;;###autoload
+(defun find-function-or-library-other-window (function-or-library)
+  "Find, in another window, the definition of FUNCTION-OR-LIBRARY near point.
+
+See `find-function' for more details."
+  (interactive (list (read-function-or-library-name)))
+  (let ((sym (if (stringp function-or-library)
+                 (intern function-or-library)
+               function-or-library)))
+    (if (fboundp sym)
+        (find-function-do-it sym nil 'switch-to-buffer-other-window)
+      (find-library-other-window function-or-library))))
+
+;;;###autoload
+(defun find-function-or-library-other-frame (function-or-library)
+  "Find, in another frame, the definition of FUNCTION-OR-LIBRARY near point.
+
+See `find-function' for more details."
+  (interactive (list (read-function-or-library-name)))
+  (let ((sym (if (stringp function-or-library)
+                 (intern function-or-library)
+               function-or-library)))
+    (if (fboundp sym)
+        (find-function-do-it sym nil 'switch-to-buffer-other-frame)
+      (find-library-other-frame function-or-library))))
+
+;;;###autoload
 (defun find-variable-noselect (variable &optional file)
   "Return a pair `(BUFFER . POINT)' pointing to the definition of VARIABLE.
 
@@ -691,9 +775,9 @@ find-variable-at-point
 ;;;###autoload
 (defun find-function-setup-keys ()
   "Define some key bindings for the find-function family of functions."
-  (define-key ctl-x-map "F" 'find-function)
-  (define-key ctl-x-4-map "F" 'find-function-other-window)
-  (define-key ctl-x-5-map "F" 'find-function-other-frame)
+  (define-key ctl-x-map "F" 'find-function-or-library)
+  (define-key ctl-x-4-map "F" 'find-function-or-library-other-window)
+  (define-key ctl-x-5-map "F" 'find-function-or-library-other-frame)
   (define-key ctl-x-map "K" 'find-function-on-key)
   (define-key ctl-x-4-map "K" 'find-function-on-key-other-window)
   (define-key ctl-x-5-map "K" 'find-function-on-key-other-frame)
-- 
1.7.4.4


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

* bug#26712: other-window/frame versions of find-library
  2017-05-29 19:39                     ` Charles A. Roelli
@ 2017-05-31  4:23                       ` Richard Stallman
  2017-06-02 18:39                         ` Charles A. Roelli
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2017-05-31  4:23 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 26712, hmelman

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Your change does what I had in mind.  (I haven't checked the code.)

But why should we have find-function-setup-keys?
Why not make those bindings standard and document them as such?

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#26712: other-window/frame versions of find-library
  2017-05-31  4:23                       ` Richard Stallman
@ 2017-06-02 18:39                         ` Charles A. Roelli
  2017-06-04  2:54                           ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: Charles A. Roelli @ 2017-06-02 18:39 UTC (permalink / raw)
  To: rms; +Cc: 26712, hmelman

Sounds good to me.


Where do you think the documentation should go in the Emacs manual?

It seems "(emacs) Misc Help" could be ok.


On 31/05/2017 06:23, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> Your change does what I had in mind.  (I haven't checked the code.)
>
> But why should we have find-function-setup-keys?
> Why not make those bindings standard and document them as such?
>






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

* bug#26712: other-window/frame versions of find-library
  2017-06-02 18:39                         ` Charles A. Roelli
@ 2017-06-04  2:54                           ` Richard Stallman
  2017-06-11 10:44                             ` Charles A. Roelli
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2017-06-04  2:54 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 26712, hmelman

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > It seems "(emacs) Misc Help" could be ok.

I agree.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.






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

* bug#26712: other-window/frame versions of find-library
  2017-06-04  2:54                           ` Richard Stallman
@ 2017-06-11 10:44                             ` Charles A. Roelli
  0 siblings, 0 replies; 22+ messages in thread
From: Charles A. Roelli @ 2017-06-11 10:44 UTC (permalink / raw)
  To: rms; +Cc: 26712, hmelman

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

Please see the attached two patches.  The first implements
'find-function-or-library' (what I sent previously).  The second patch
makes the 'find-function-setup-keys' bindings by default, and they're
documented in the manual.


On 04/06/2017 04:54, Richard Stallman wrote:
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>    > It seems "(emacs) Misc Help" could be ok.
>
> I agree.
>


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

From f21249122162835e1d22ca72fec6212944328859 Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
Date: Mon, 29 May 2017 21:35:24 +0200
Subject: [PATCH 1/2] New commands: find-function-or-library
 (-other-window/-frame)

* lisp/emacs-lisp/find-func.el (read-function-or-library-name):
New function for reading a function or library name.
(find-function-or-library, find-function-or-library-other-window)
(find-function-or-library-other-frame): New commands.
(find-function-setup-keys): Replace 'find-function' bindings with
bindings to 'find-function-or-library'.
* etc/NEWS: Mention 'find-function-or-library' and new bindings
made by 'find-function-setup-keys'.
---
 etc/NEWS                     |    7 +++-
 lisp/emacs-lisp/find-func.el |   90 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 93 insertions(+), 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 7972511..6ed668c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -364,13 +364,18 @@ large integers from being displayed as characters.
 ** Two new commands for finding the source code of Emacs Lisp
 libraries: 'find-library-other-window' and 'find-library-other-frame'.
 
-+++
 ** The new variable 'display-raw-bytes-as-hex' allows to change the
 display of raw bytes from octal to hex.
 
 ** You can now provide explicit field numbers in format specifiers.
 For example, '(format "%2$s %1$s" "X" "Y")' produces "Y X".
 
+** 'find-function-setup-keys' now binds 'C-x F', 'C-x 4 F' and 'C-x 5
+F' to the new command 'find-function-or-library' and its
+other-window/-frame counterparts.  The new commands find the Emacs
+Lisp source code of a function or library, defaulting to the function
+or library closest to point.
+
 \f
 * Editing Changes in Emacs 26.1
 
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 9b98f05..9943598 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -310,6 +310,40 @@ read-library-name
                        "Library name: ")
                      table nil nil nil nil def)))
 
+(defun read-function-or-library-name ()
+  "Read and return a function or library name, defaulting to the one near point.
+
+A function name is the name of a symbol that satisfies the
+predicate `fboundp'.  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 (completion-table-merge
+                 (apply-partially 'completion-table-with-predicate
+                                  obarray 'fboundp t)
+                 (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))
+                (symbol-name (function-called-at-point)))))
+    (when (and def (not (test-completion def table)))
+      (setq def nil))
+    (completing-read (if def
+                         (format "Function or library name (default %s): " def)
+                       "Function or 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.
@@ -537,6 +571,56 @@ find-function-other-frame
   (find-function-do-it function nil 'switch-to-buffer-other-frame))
 
 ;;;###autoload
+(defun find-function-or-library (function-or-library)
+  "Find the definition of the FUNCTION-OR-LIBRARY near point.
+
+Finds the source file containing the definition of the
+function (selected by `function-called-at-point') or
+library (loaded with `require') near point in a buffer and places
+point before the definition.
+
+FUNCTION-OR-LIBRARY is searched for in
+`find-function-source-path', if non-nil, otherwise in
+`load-path'.  See also `find-function-recenter-line' and
+`find-function-after-hook'.
+
+If FUNCTION-OR-LIBRARY names both a function and a library, finds
+the corresponding function definition."
+  (interactive (list (read-function-or-library-name)))
+  (let ((sym (if (stringp function-or-library)
+                 (intern function-or-library)
+               function-or-library)))
+    (if (fboundp sym)
+        (find-function-do-it sym nil 'switch-to-buffer)
+      (find-library function-or-library))))
+
+;;;###autoload
+(defun find-function-or-library-other-window (function-or-library)
+  "Find, in another window, the definition of FUNCTION-OR-LIBRARY near point.
+
+See `find-function' for more details."
+  (interactive (list (read-function-or-library-name)))
+  (let ((sym (if (stringp function-or-library)
+                 (intern function-or-library)
+               function-or-library)))
+    (if (fboundp sym)
+        (find-function-do-it sym nil 'switch-to-buffer-other-window)
+      (find-library-other-window function-or-library))))
+
+;;;###autoload
+(defun find-function-or-library-other-frame (function-or-library)
+  "Find, in another frame, the definition of FUNCTION-OR-LIBRARY near point.
+
+See `find-function' for more details."
+  (interactive (list (read-function-or-library-name)))
+  (let ((sym (if (stringp function-or-library)
+                 (intern function-or-library)
+               function-or-library)))
+    (if (fboundp sym)
+        (find-function-do-it sym nil 'switch-to-buffer-other-frame)
+      (find-library-other-frame function-or-library))))
+
+;;;###autoload
 (defun find-variable-noselect (variable &optional file)
   "Return a pair `(BUFFER . POINT)' pointing to the definition of VARIABLE.
 
@@ -691,9 +775,9 @@ find-variable-at-point
 ;;;###autoload
 (defun find-function-setup-keys ()
   "Define some key bindings for the find-function family of functions."
-  (define-key ctl-x-map "F" 'find-function)
-  (define-key ctl-x-4-map "F" 'find-function-other-window)
-  (define-key ctl-x-5-map "F" 'find-function-other-frame)
+  (define-key ctl-x-map "F" 'find-function-or-library)
+  (define-key ctl-x-4-map "F" 'find-function-or-library-other-window)
+  (define-key ctl-x-5-map "F" 'find-function-or-library-other-frame)
   (define-key ctl-x-map "K" 'find-function-on-key)
   (define-key ctl-x-4-map "K" 'find-function-on-key-other-window)
   (define-key ctl-x-5-map "K" 'find-function-on-key-other-frame)
-- 
1.7.4.4


[-- Attachment #3: 0002-Make-find-function-setup-keys-bindings-default.patch --]
[-- Type: text/x-patch, Size: 6356 bytes --]

From ec6d7c242f7d19bfcaa760e9a991e83244f44974 Mon Sep 17 00:00:00 2001
From: Charles A. Roelli <charles@aurox.ch>
Date: Sun, 4 Jun 2017 11:56:58 +0200
Subject: [PATCH 2/2] Make 'find-function-setup-keys' bindings default

* etc/NEWS: Mention the default bindings that were formerly made by
'find-function-setup-keys'.  Remove a previous entry that has been
superceded by the recent addition of 'find-library-other-window'.
* doc/emacs/help.texi (Misc Help): Document the new bindings.
* lisp/bindings.el: Add bindings formerly made by
'find-function-setup-keys': 'C-x F', 'C-x K', 'C-x V' and
'C-x 4'/'C-x 5' variants.
* lisp/find-func.el (find-function-setup-keys): Alias to #'ignore,
and make it obsolete.
---
 doc/emacs/help.texi          |   49 ++++++++++++++++++++++++++++++++++++++++++
 etc/NEWS                     |   17 ++++++-------
 lisp/bindings.el             |   11 +++++++++
 lisp/emacs-lisp/find-func.el |   14 ++---------
 4 files changed, 71 insertions(+), 20 deletions(-)

diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 548ca6a..74a06f5 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -588,6 +588,55 @@ Misc Help
 which marks a defun.  However, @kbd{@key{ESC} @key{F1}} and
 @kbd{@key{ESC} ?} work fine.)
 
+@kindex C-x F
+@findex find-function-or-library
+@kindex C-x 4 F
+@findex find-function-or-library-other-window
+@kindex C-x 5 F
+@findex find-function-or-library-other-frame
+@kindex C-x K
+@findex find-function-on-key
+@kindex C-x 4 K
+@findex find-function-on-key-other-window
+@kindex C-x 5 K
+@findex find-function-on-key-other-frame
+@kindex C-x V
+@findex find-variable
+@kindex C-x 4 V
+@findex find-variable-other-window
+@kindex C-x 5 V
+@findex find-variable-other-frame
+  When reading or writing Emacs Lisp code, it is often helpful to
+visit the source of other Emacs Lisp functions, libraries and
+variables.  The following commands are helpful for doing that:
+
+@table @kbd
+@item C-x F
+Find a function or library, with the function or library closest to
+point as a suggestion (@code{find-function-or-library}).
+@item C-x 4 F
+Idem., in another window
+(@code{find-function-or-library-other-window}).
+@item C-x 5 F
+Idem., in another frame (@code{find-function-or-library-other-frame}).
+@item C-x K
+Find a function on a given key, which you type interactively
+(@code{find-function-on-key}).
+@item C-x 4 K
+Idem., in another window
+(@code{find-function-on-key-other-window}).
+@item C-x 5 K
+Idem., in another frame (@code{find-function-on-key-other-frame}).
+@item C-x V
+Find a variable, with the variable closest to point as a suggestion
+(@code{find-variable}).
+@item C-x 4 V
+Idem., in another window
+(@code{find-variable-other-window}).
+@item C-x 5 V
+Idem., in another frame (@code{find-variable-other-frame}).
+@end table
+
 @node Help Files
 @section Help Files
 
diff --git a/etc/NEWS b/etc/NEWS
index 6ed668c..2b31cc0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -211,10 +211,6 @@ face instead of the 'escape-glyph' face.
 part of minibuffers.
 
 ---
-** 'find-library' now takes a prefix argument to pop to a different
-window.
-
----
 ** 'process-attributes' on Darwin systems now returns more information.
 
 +++
@@ -370,11 +366,14 @@ display of raw bytes from octal to hex.
 ** You can now provide explicit field numbers in format specifiers.
 For example, '(format "%2$s %1$s" "X" "Y")' produces "Y X".
 
-** 'find-function-setup-keys' now binds 'C-x F', 'C-x 4 F' and 'C-x 5
-F' to the new command 'find-function-or-library' and its
-other-window/-frame counterparts.  The new commands find the Emacs
-Lisp source code of a function or library, defaulting to the function
-or library closest to point.
+** 'C-x F', 'C-x 4 F' and 'C-x 5 F' are bound to the new command
+'find-function-or-library' and its other-window/-frame counterparts.
+The new commands find the Emacs Lisp source code of a function or
+library, defaulting to the function or library closest to point.  'C-x
+K' and 'C-x V' are bound to 'find-function-on-key' and
+'find-variable', with equivalent other-window/-frame commands in the
+'C-x 4' and 'C-x 5' keymaps.  These were formerly bound by the
+function 'find-function-setup-keys', which is now obsolete.
 
 \f
 * Editing Changes in Emacs 26.1
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 0994b71..4807b57 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1325,6 +1325,17 @@ esc-map
 (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
 (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
 
+;; from emacs-lisp/find-func.el
+(define-key ctl-x-map "F" 'find-function-or-library)
+(define-key ctl-x-4-map "F" 'find-function-or-library-other-window)
+(define-key ctl-x-5-map "F" 'find-function-or-library-other-frame)
+(define-key ctl-x-map "K" 'find-function-on-key)
+(define-key ctl-x-4-map "K" 'find-function-on-key-other-window)
+(define-key ctl-x-5-map "K" 'find-function-on-key-other-frame)
+(define-key ctl-x-map "V" 'find-variable)
+(define-key ctl-x-4-map "V" 'find-variable-other-window)
+(define-key ctl-x-5-map "V" 'find-variable-other-frame)
+
 ;; Signal handlers
 (define-key special-event-map [sigusr1] 'ignore)
 (define-key special-event-map [sigusr2] 'ignore)
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 9943598..c08df49 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -773,17 +773,9 @@ find-variable-at-point
       (find-variable-other-window symb))))
 
 ;;;###autoload
-(defun find-function-setup-keys ()
-  "Define some key bindings for the find-function family of functions."
-  (define-key ctl-x-map "F" 'find-function-or-library)
-  (define-key ctl-x-4-map "F" 'find-function-or-library-other-window)
-  (define-key ctl-x-5-map "F" 'find-function-or-library-other-frame)
-  (define-key ctl-x-map "K" 'find-function-on-key)
-  (define-key ctl-x-4-map "K" 'find-function-on-key-other-window)
-  (define-key ctl-x-5-map "K" 'find-function-on-key-other-frame)
-  (define-key ctl-x-map "V" 'find-variable)
-  (define-key ctl-x-4-map "V" 'find-variable-other-window)
-  (define-key ctl-x-5-map "V" 'find-variable-other-frame))
+(defalias 'find-function-setup-keys 'ignore)
+(make-obsolete 'find-function-setup-keys
+  "commands from `find-func' are bound by default." "26.1")
 
 (provide 'find-func)
 
-- 
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 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.