all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
@ 2022-12-20  4:44 Stefan Kangas
  2022-12-20 14:04 ` Eli Zaretskii
  2022-12-20 17:24 ` Drew Adams
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Kangas @ 2022-12-20  4:44 UTC (permalink / raw)
  To: 60213

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

Severity: wishlist

The attached patch make `Info-goto-node-web' copy the URL as kill with a
prefix argument, instead of opening it with `browse-url'.  I've seen
this feature requested a couple of times now by various people.

Since `Info-goto-node-web' is new in Emacs 29, this could perhaps be
considered safe enough for emacs-29, but master is also fine, of course.

[-- Attachment #2: 0002-Copy-Info-goto-node-web-URL-as-kill-with-prefix-arg.patch --]
[-- Type: text/x-diff, Size: 2246 bytes --]

From 76593b37c06c18920cb2c1f704bbd1590d59e471 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Tue, 20 Dec 2022 05:35:03 +0100
Subject: [PATCH 2/2] Copy Info-goto-node-web URL as kill with prefix arg

* lisp/info.el (Info-goto-node-web): Copy URL as kill with prefix
argument.
---
 lisp/info.el | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/lisp/info.el b/lisp/info.el
index f939c42874..8c689147dc 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1781,17 +1781,27 @@ Info-goto-node
     (Info-find-node (if (equal filename "") nil filename)
                     (if (equal nodename "") "Top" nodename) nil strict-case)))
 
-(defun Info-goto-node-web (node)
+(defun Info-goto-node-web (node &optional arg)
   "Use `browse-url' to go to the gnu.org web server's version of NODE.
-By default, go to the current Info node."
+By default, go to the current Info node.
+
+With a prefix argument ARG, copy the URL to the kill ring instead
+of visiting."
   (interactive (list (Info-read-node-name
-                      "Go to node (default current page): " Info-current-node))
+                      (if current-prefix-arg
+                          "Copy node URL as kill (default current page): "
+                        "Go to node (default current page): ")
+                      Info-current-node)
+                     current-prefix-arg)
                Info-mode)
-  (browse-url-button-open-url
-   (Info-url-for-node (format "(%s)%s" (file-name-sans-extension
-                                        (file-name-nondirectory
-                                         Info-current-file))
-                              node))))
+  (let ((url (Info-url-for-node (format "(%s)%s" (file-name-sans-extension
+                                                  (file-name-nondirectory
+                                                   Info-current-file))
+                                        node))))
+    (if current-prefix-arg
+        (progn (kill-new url)
+               (message "%s" url))
+      (browse-url-button-open-url url))))
 
 (defvar info--url-for-node-manuals-built-in
   ;; All manuals are at https://www.gnu.org/software/emacs/manual/
-- 
2.35.1


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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-20  4:44 bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument Stefan Kangas
@ 2022-12-20 14:04 ` Eli Zaretskii
  2022-12-20 17:24 ` Drew Adams
  1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2022-12-20 14:04 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 60213

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Mon, 19 Dec 2022 22:44:33 -0600
> 
> The attached patch make `Info-goto-node-web' copy the URL as kill with a
> prefix argument, instead of opening it with `browse-url'.  I've seen
> this feature requested a couple of times now by various people.
> 
> Since `Info-goto-node-web' is new in Emacs 29, this could perhaps be
> considered safe enough for emacs-29, but master is also fine, of course.

I prefer master.  We aren't even sure how popular the new command will
be, and this addition modifies its behavior in very non-trivial ways.
I'm not aware of many command in Emacs that, given an argument, just
copy a name to the kill-ring instead of acting on that name.





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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-20  4:44 bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument Stefan Kangas
  2022-12-20 14:04 ` Eli Zaretskii
@ 2022-12-20 17:24 ` Drew Adams
  2022-12-21  1:57   ` Stefan Kangas
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2022-12-20 17:24 UTC (permalink / raw)
  To: Stefan Kangas, 60213@debbugs.gnu.org

> The attached patch make `Info-goto-node-web' copy the URL as kill with a
> prefix argument, instead of opening it with `browse-url'.  I've seen
> this feature requested a couple of times now by various people.

Couple of times, various people?  Any besides
the one time and one person (Marcin)?  Based
on what, a month of experience with the new
command?  What's the inconvenience that the
enhancement request would overcome - just
killing/copying the URL in the minibuffer?

What about using the prefix arg to open the
URL in a separate browser window?  After all,
that's the behavior of `Info-goto-node-web'
(the original).

[If not then `info+.el' will keep needing to 
define the command (now REdefine), even after
Emacs 29.  OK, I'm used to it...]

That's the behavior users have enjoyed for
almost a decade.  During those years, I never
once received a request to add copying the
URL to the kill-ring.  Not that that's a
horrible idea - but how useful is it compared
to the longstanding prefix-arg behavior?

Consider also: how hard is it to get the URL
to the kill-ring?  Just copy (or kill & yank)
it in the minibuffer to begin with.  If you
forget to do that, then when you use the same
minibuffer history again, `M-p C-k' retrieves
the URL and adds it to the kill ring.  Not a
big deal.

And compare, e.g., `find-file'.  There we
have a separate command for `other-window'.
(Not a browser window, but ~same idea.)  We
don't have anything special for saving the
file location (abs-name) to the kill-ring.
We haven't needed that for 40 years...  Has
anyone even requested it?

For `find-file' and such, it's apparently
enough that you can get to the file name
with `M-p' - we've felt no need to add it
to the kill-ring.

Or perhaps combine both optional behaviors,
as I suggested in my msg in thread #60190?

If you insist on doing what you're doing
then I'd suggest you at least add another
command for opening the URL in a separate
browser window.  And perhaps yet another
to open it in a separate browser tab.

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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-20 17:24 ` Drew Adams
@ 2022-12-21  1:57   ` Stefan Kangas
  2022-12-21  6:01     ` Drew Adams
  2022-12-21  8:30     ` Juri Linkov
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Kangas @ 2022-12-21  1:57 UTC (permalink / raw)
  To: Drew Adams, 60213

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

>> The attached patch make `Info-goto-node-web' copy the URL as kill
>> with a prefix argument, instead of opening it with `browse-url'.
>> I've seen this feature requested a couple of times now by various
>> people.
>
> Couple of times, various people?  Any besides the one time and one
> person (Marcin)?

One of them is yours truly, the other is Marcin.  I also saw it
requested on Reddit somewhere, I think.

> Based on what, a month of experience with the new command?  What's the
> inconvenience that the enhancement request would overcome - just
> killing/copying the URL in the minibuffer?

I myself never need to open the URL.  I only ever need to copy it (to
give to others, or use elsewhere).  So firing up a web browser mostly
just gets in the way for me.

> What about using the prefix arg to open the URL in a separate browser
> window?  After all, that's the behavior of `Info-goto-node-web' (the
> original).

That can be customized in `browse-url', so I'd personally use the prefix
argument for something more useful.  But I won't protest if someone
wants to do that.

Anyways, we could consider moving the functionality I want to a positive
prefix argument of `Info-copy-current-node-name'.  Or a negative prefix
argument of `Info-goto-node-web'.  I don't really care which it is, as
long as its somewhere.





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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-21  1:57   ` Stefan Kangas
@ 2022-12-21  6:01     ` Drew Adams
  2022-12-21  8:36       ` Stefan Kangas
  2022-12-21  8:30     ` Juri Linkov
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2022-12-21  6:01 UTC (permalink / raw)
  To: Stefan Kangas, 60213@debbugs.gnu.org

> > What's the inconvenience that the enhancement request
> > would overcome - just killing/copying the URL in the minibuffer?
> 
> I myself never need to open the URL.  I only ever need to copy it (to
> give to others, or use elsewhere).  So firing up a web browser mostly
> just gets in the way for me.

I don't understand.  We're talking about
`Info-goto-node-web', right?  Its purpose
is to visit a manual node in a web browser.

If all you want to do is copy the URL that
the command would use to open that page in
a web browser, then you can do that with a
new command that does just that.

> > What about using the prefix arg to open the URL in a separate browser
> > window?  After all, that's the behavior of `Info-goto-node-web' (the
> > original).
> 
> That can be customized in `browse-url', so I'd personally use the prefix
> argument for something more useful.  But I won't protest if someone
> wants to do that.

If you're not really talking about what
`Info-goto-node-web' does or is for, then
maybe you should ask for what you want as
a separate enhancement request: an Info
command that copies the URL for a given
node to the kill-ring.

That's not what `Info-goto-node-web' is
about.  Accessing the manual with a web
browser is what the command is about.

You might find what you want to be "more
useful", but this is a command whose job
it is to get you to the manual in a web
browser.

> Anyways, we could consider moving the functionality I want to a positive
> prefix argument of `Info-copy-current-node-name'.  Or a negative prefix
> argument of `Info-goto-node-web'.  I don't really care which it is, as
> long as its somewhere.

It sounds like what you want should be a
new command.  It's not about copying the
node _name_ to the kill-ring, and it's
not about visiting the node on the web.

Yes, by a loose analogy with
`dired-copy-filename-as-kill' we could
imagine that `Info-copy-current-node-name'
with some prefix arg would copy the node's
URL instead of its name.  The URL can be
thought of as another "name" for the node.

[Dunno why only a zero prefix arg for
`Info-copy-current-node-name' has any
significance.  Odd.
That command isn't in Emacs 20, and in
Emacs 22 the prefix-arg behavior is
already limited to zero.  Maybe it was
introduced in Emacs 21 and other prefix
arg values had some other behavior?]

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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-21  1:57   ` Stefan Kangas
  2022-12-21  6:01     ` Drew Adams
@ 2022-12-21  8:30     ` Juri Linkov
  2022-12-21 16:05       ` Drew Adams
  1 sibling, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2022-12-21  8:30 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 60213, Drew Adams

>> What about using the prefix arg to open the URL in a separate browser
>> window?  After all, that's the behavior of `Info-goto-node-web' (the
>> original).
>
> That can be customized in `browse-url', so I'd personally use the prefix
> argument for something more useful.  But I won't protest if someone
> wants to do that.

It would make sense to use eww by default to browse an external Info
in the same Emacs window.  And with a prefix argument open that Info
in an external browser.

> Anyways, we could consider moving the functionality I want to a positive
> prefix argument of `Info-copy-current-node-name'.  Or a negative prefix
> argument of `Info-goto-node-web'.  I don't really care which it is, as
> long as its somewhere.

Using a different prefix argument for `w' (`Info-copy-current-node-name')
makes sense as well like in `dired-copy-filename-as-kill' where the prefix
argument supports different values.  Another variant is to add new key 'W'
for URL copying.  OTOH, 'W' has a nice mnemonic to open a web browser.





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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-21  6:01     ` Drew Adams
@ 2022-12-21  8:36       ` Stefan Kangas
  2022-12-21 16:07         ` Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Kangas @ 2022-12-21  8:36 UTC (permalink / raw)
  To: Drew Adams, 60213@debbugs.gnu.org

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

> Yes, by a loose analogy with `dired-copy-filename-as-kill' we could
> imagine that `Info-copy-current-node-name' with some prefix arg would
> copy the node's URL instead of its name.

So let's do that, then.





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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-21  8:30     ` Juri Linkov
@ 2022-12-21 16:05       ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2022-12-21 16:05 UTC (permalink / raw)
  To: Juri Linkov, Stefan Kangas; +Cc: 60213@debbugs.gnu.org

> >> What about using the prefix arg to open the URL in a separate browser
> >> window?  After all, that's the behavior of `Info-goto-node-web' (the
> >> original).
> >
> > That can be customized in `browse-url', so I'd personally use the
> > prefix argument for something more useful.  But I won't protest
> > if someone wants to do that.
> 
> It would make sense to use eww by default to browse an external Info
> in the same Emacs window.  And with a prefix argument open that Info
> in an external browser.

Not sure what you're suggesting.  But (for me) the
point of a command such as `Info-goto-node-web' is
to visit a URL (for a manual node) in your browser
of choice - not to substitute whatever browser we
might think you should use - whether within Emacs
or not.

I'm not saying that's what you're suggesting.  I
don't know just what you're suggesting.  But we
should (1) let users tell Emacs which browser they
want to use by default, for such things and (2)
use that browser by default, for such things.

One reason to open a manual in a web browser might
just be to get HTML rendering.  Another, perhaps
more important reason (IMO), might be in order to
use a non-Emacs web browser.

> Using a different prefix argument for `w' (`Info-copy-current-node-name')
> makes sense as well like in `dired-copy-filename-as-kill' where the
> prefix argument supports different values.  Another variant is to add new key
> 'W' for URL copying.  OTOH, 'W' has a nice mnemonic to open a web browser.

I chose `G' for `Info-goto-node-web' to correspond
to `g' for `Info-goto-node' - i.e., for "go to".






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

* bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument
  2022-12-21  8:36       ` Stefan Kangas
@ 2022-12-21 16:07         ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2022-12-21 16:07 UTC (permalink / raw)
  To: Stefan Kangas, 60213@debbugs.gnu.org

> > Yes, by a loose analogy with `dired-copy-filename-as-kill' we could
> > imagine that `Info-copy-current-node-name' with some prefix arg would
> > copy the node's URL instead of its name.
> 
> So let's do that, then.

OK by me.  See what Eli says.

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

end of thread, other threads:[~2022-12-21 16:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-20  4:44 bug#60213: [PATCH] Copy Info-goto-node-web URL as kill with prefix argument Stefan Kangas
2022-12-20 14:04 ` Eli Zaretskii
2022-12-20 17:24 ` Drew Adams
2022-12-21  1:57   ` Stefan Kangas
2022-12-21  6:01     ` Drew Adams
2022-12-21  8:36       ` Stefan Kangas
2022-12-21 16:07         ` Drew Adams
2022-12-21  8:30     ` Juri Linkov
2022-12-21 16:05       ` Drew Adams

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.