unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A patch for `pwd' - copying the current directory to the kill ring
@ 2018-01-25 13:13 Marcin Borkowski
  2018-01-25 13:44 ` Kaushal Modi
  2018-01-25 15:47 ` Yuri Khan
  0 siblings, 2 replies; 20+ messages in thread
From: Marcin Borkowski @ 2018-01-25 13:13 UTC (permalink / raw)
  To: emacs-devel

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

Hi all,

from time to time I have a need to insert the current directory name
somewhere.  Some time ago, I submitted a bug report suggesting that C-u
M-x pwd could insert the current dir at point.  Someone made that patch
a few years ago, and that is great.  However, it is not enough:
sometimes I want to be able to yank this dir to some other application
(usually the terminal - I want to cd to that dir).  I made a simple
patch that makes `pwd' copy the current dir to the kill ring (and - by
default - to the system clipboard) if prefixed with C-u C-u.  I attach
the patch.  WDYT?

-- 
Marcin Borkowski

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-pwd-copy-current-dir-to-kill-ring-when-run-with.patch --]
[-- Type: text/x-patch, Size: 1289 bytes --]

From bffb831838f16182fe4e26629c0c6b85ffe98419 Mon Sep 17 00:00:00 2001
From: Marcin Borkowski <mbork@mbork.pl>
Date: Thu, 25 Jan 2018 14:06:41 +0100
Subject: [PATCH] Make pwd copy current dir to kill ring when run with C-u C-u

---
 lisp/files.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 7194b56fef..0ebc7b5b9d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -714,14 +714,16 @@ read-directory-name
 		  'file-directory-p))
 
 \f
-(defun pwd (&optional insert)
-  "Show the current default directory.
-With prefix argument INSERT, insert the current default directory
-at point instead."
+(defun pwd (&optional arg)
+  "Show the current default directory. With \\[universal-argument], insert
+the current default directory at point instead.  With \\[universal-argument] \\[universal-argument],
+show the current default directory and put it in the kill ring."
   (interactive "P")
-  (if insert
+  (if (equal arg '(4))
       (insert default-directory)
-    (message "Directory %s" default-directory)))
+    (message "Directory %s" default-directory)
+    (when (equal arg '(16))
+      (kill-new default-directory))))
 
 (defvar cd-path nil
   "Value of the CDPATH environment variable, as a list.
-- 
2.15.1


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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 13:13 A patch for `pwd' - copying the current directory to the kill ring Marcin Borkowski
@ 2018-01-25 13:44 ` Kaushal Modi
  2018-01-25 14:36   ` Stefan Monnier
  2018-02-01 21:08   ` Marcin Borkowski
  2018-01-25 15:47 ` Yuri Khan
  1 sibling, 2 replies; 20+ messages in thread
From: Kaushal Modi @ 2018-01-25 13:44 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: emacs-devel

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

On Thu, Jan 25, 2018 at 8:13 AM Marcin Borkowski <mbork@mbork.pl> wrote:

> Hi all,
>
> from time to time I have a need to insert the current directory name
> somewhere.  Some time ago, I submitted a bug report suggesting that C-u
> M-x pwd could insert the current dir at point.  Someone made that patch
> a few years ago, and that is great.  However, it is not enough:
> sometimes I want to be able to yank this dir to some other application
> (usually the terminal - I want to cd to that dir).  I made a simple
> patch that makes `pwd' copy the current dir to the kill ring (and - by
> default - to the system clipboard) if prefixed with C-u C-u.  I attach
> the patch.  WDYT?
>

I wouldn't even mind copying the default-directory to kill ring by default.
Then you don't need C-u C-u.

- M-x pwd would show the pwd and *also copy it to kill-ring*.
- C-u M-x pwd will only insert the pwd at point (as before).

If someone did M-x pwd to know the current directory, most likely they
would consider it harmless to save that kill-ring too. And if they didn't
intend to do that, it doesn't hurt.. you always have M-y by your side :)

What do you and others think of this?

As a side, in your patch:

> +  "Show the current default directory. With \\[universal-argument],
insert
> +the current default directory at point instead.  With
\\[universal-argument] \\[universal-argument],

M-x checkdoc would fail there.. the first visual line in a doc-string must
be a complete sentence and end in a full-stop. In your patch, the first
visual line is incomplete (ends in ", insert"). The older version, the one
your patch is based on, did it correctly:

> -  "Show the current default directory.
> -With prefix argument INSERT, insert the current default directory

-- 

Kaushal Modi

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

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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 13:44 ` Kaushal Modi
@ 2018-01-25 14:36   ` Stefan Monnier
  2018-01-25 20:13     ` Stefan Monnier
  2018-02-01 21:09     ` Marcin Borkowski
  2018-02-01 21:08   ` Marcin Borkowski
  1 sibling, 2 replies; 20+ messages in thread
From: Stefan Monnier @ 2018-01-25 14:36 UTC (permalink / raw)
  To: emacs-devel

> I wouldn't even mind copying the default-directory to kill ring by default.
> Then you don't need C-u C-u.
> - M-x pwd would show the pwd and *also copy it to kill-ring*.
> - C-u M-x pwd will only insert the pwd at point (as before).

I don't have an opinion on this change, but it gives me the impression
that we'd be better served by a more general solution, something like

    (defvar copy-next-command-output--marker nil)
    (defun copy-next-command-output ()
      "Add the output of the next command to the `kill-ring`."
      (interactive)
      (cl-labels ((pre ()
                       (remove-hook 'pre-command-hook #'pre)
                       (add-hook 'post-command-hook #'post)
                       (setq copy-next-command-output--marker
                             (with-current-buffer "*Messages*"
                               (point-max-marker))))
                  (post ()
                        (remove-hook 'post-command-hook #'post)
                        (when copy-next-command-output--marker
                          (with-current-buffer
                              (marker-buffer copy-next-command-output--marker)
                            (when (< copy-next-command-output--marker
                                     (point-max))
                              (kill-new (buffer-substring
                                         copy-next-command-output--marker
                                         (point-max)))))
                          (setq copy-next-command-output--marker nil))))
        (add-hook 'pre-command-hook #'pre)))

Except making it work with M-x (the above will grab the "output" of the
M-x itself (i.e. no output), rather than the output of the command Emacs
runs after running the commands bound to M-x, p, w, d, and RET).


        Stefan




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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 13:13 A patch for `pwd' - copying the current directory to the kill ring Marcin Borkowski
  2018-01-25 13:44 ` Kaushal Modi
@ 2018-01-25 15:47 ` Yuri Khan
  1 sibling, 0 replies; 20+ messages in thread
From: Yuri Khan @ 2018-01-25 15:47 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: emacs-devel

On Thu, Jan 25, 2018 at 8:13 PM, Marcin Borkowski <mbork@mbork.pl> wrote:

> from time to time I have a need to insert the current directory name
> somewhere.  Some time ago, I submitted a bug report suggesting that C-u
> M-x pwd could insert the current dir at point.  Someone made that patch
> a few years ago, and that is great.  However, it is not enough:
> sometimes I want to be able to yank this dir to some other application
> (usually the terminal - I want to cd to that dir).  I made a simple
> patch that makes `pwd' copy the current dir to the kill ring (and - by
> default - to the system clipboard) if prefixed with C-u C-u.  I attach
> the patch.  WDYT?

Long ago, on a different OS, I used a file manager that had a
relatively easy key to copy the full path to the currently selected
file(s) to clipboard.

It was crazy efficient, to the point that I hated programs that used
the system-provided “select a directory” dialog box without letting me
paste a path in there.

In that file manager, if I were editing a file and needed its
containing directory’s path, I’d press Ctrl+F10 (to jump to its
directory in a file panel), then Backspace (go to parent directory),
then Alt+Shift+Ins (to copy the full path of the selected file, which
now happens to be the original file’s containing directory).

In Emacs, this translates to two ‘dired-jump’s (which I have bound to
M-S-up) followed by ‘dired-copy-filename-as-kill’ with a zero argument
(easily accessible with 0 w). Alternatively, dired-jump
beginning-of-buffer dired-copy-filename-as-kill (M-S-up M-< w) also
works.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 14:36   ` Stefan Monnier
@ 2018-01-25 20:13     ` Stefan Monnier
  2018-01-25 23:05       ` Richard Copley
  2018-01-26  7:55       ` Eli Zaretskii
  2018-02-01 21:09     ` Marcin Borkowski
  1 sibling, 2 replies; 20+ messages in thread
From: Stefan Monnier @ 2018-01-25 20:13 UTC (permalink / raw)
  To: emacs-devel

> Except making it work with M-x (the above will grab the "output" of the
> M-x itself (i.e. no output), rather than the output of the command Emacs
> runs after running the commands bound to M-x, p, w, d, and RET).

The version below seems to work (tested with M-: and M-x)


        Stefan


(defvar copy-next-command-output--marker nil)
(defun copy-next-command-output ()
  "Prefix command to add the output of the next command to the `kill-ring`."
  (interactive)
  (let ((ml (minibuffer-depth)))
    (cl-labels ((pre ()
                     (add-hook 'post-command-hook #'post)
                     (setq copy-next-command-output--marker
                           (with-current-buffer "*Messages*"
                             (point-max-marker))))
                (post ()
                      (unless (> (minibuffer-depth) ml)
                        (remove-hook 'pre-command-hook #'pre)
                        (remove-hook 'post-command-hook #'post)
                        (when copy-next-command-output--marker
                          (with-current-buffer
                              (marker-buffer copy-next-command-output--marker)
                            (when (< copy-next-command-output--marker
                                     (point-max))
                              (kill-new (buffer-substring
                                         copy-next-command-output--marker
                                         (point-max)))))
                          (setq copy-next-command-output--marker nil)))))
      (add-hook 'pre-command-hook #'pre))))




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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 20:13     ` Stefan Monnier
@ 2018-01-25 23:05       ` Richard Copley
  2018-01-25 23:23         ` Stefan Monnier
  2018-01-26  7:55       ` Eli Zaretskii
  1 sibling, 1 reply; 20+ messages in thread
From: Richard Copley @ 2018-01-25 23:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs Development

On 25 January 2018 at 20:13, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Except making it work with M-x (the above will grab the "output" of the
>> M-x itself (i.e. no output), rather than the output of the command Emacs
>> runs after running the commands bound to M-x, p, w, d, and RET).
>
> The version below seems to work (tested with M-: and M-x)
>
>
>         Stefan
>
>
> (defvar copy-next-command-output--marker nil)
> (defun copy-next-command-output ()
>   "Prefix command to add the output of the next command to the `kill-ring`."
>   (interactive)
>   (let ((ml (minibuffer-depth)))
>     (cl-labels ((pre ()
>                      (add-hook 'post-command-hook #'post)
>                      (setq copy-next-command-output--marker
>                            (with-current-buffer "*Messages*"
>                              (point-max-marker))))
>                 (post ()
>                       (unless (> (minibuffer-depth) ml)
>                         (remove-hook 'pre-command-hook #'pre)
>                         (remove-hook 'post-command-hook #'post)
>                         (when copy-next-command-output--marker
>                           (with-current-buffer
>                               (marker-buffer copy-next-command-output--marker)
>                             (when (< copy-next-command-output--marker
>                                      (point-max))
>                               (kill-new (buffer-substring
>                                          copy-next-command-output--marker
>                                          (point-max)))))
>                           (setq copy-next-command-output--marker nil)))))
>       (add-hook 'pre-command-hook #'pre))))

I evaluated those two forms, and this one:

(global-set-key [?\C-c ?p] #'copy-next-command-output)

Then in an empty buffer,

;; Put "x" on the kill ring
x
<C-backspace>    ;; backward-kill-word
;; Test the new prefix command on "M-x pwd"
C-c p
M-x pwd RET
C-y        ;; yank

The result is "x" (in emacs-26 -Q). Where did I go wrong?

The interactive message output of a command (in this case, e.g.,
"Directory C:/Users/Buster") is not usually going to be useful as a
building block.

I think the generalisation is unwarranted in this case anyway. I bind
C-c f to a command that puts the pwd on the kill ring, with a few
tweaks to make it more useful to me (it optionally replaces "/" with
"\", and if called in a buffer visiting a file, returns the file's
name). It's more specialised, not more general. I use it a lot.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 23:05       ` Richard Copley
@ 2018-01-25 23:23         ` Stefan Monnier
  2018-02-01 21:11           ` Marcin Borkowski
  0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2018-01-25 23:23 UTC (permalink / raw)
  To: emacs-devel

> I evaluated those two forms, and this one:
> (global-set-key [?\C-c ?p] #'copy-next-command-output)

Probably in a buffer not using lexical-binding.
This code (like most of the code I write) presumes lexical-binding.

> I think the generalisation is unwarranted in this case anyway.  I bind
> C-c f to a command that puts the pwd on the kill ring, with a few
> tweaks to make it more useful to me (it optionally replaces "/" with
> "\", and if called in a buffer visiting a file, returns the file's
> name). It's more specialised, not more general. I use it a lot.

One doesn't oppose the other.  I just think it's a fairly common request
to be able to insert the output of a command in the current buffer or
copy it to the clipboard, and rather than tweak each and every command
to add some clever way to do that, I think Emacs would benefit from
having a way to do it in general.


        Stefan




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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 20:13     ` Stefan Monnier
  2018-01-25 23:05       ` Richard Copley
@ 2018-01-26  7:55       ` Eli Zaretskii
  2018-01-26 14:40         ` Stefan Monnier
  1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2018-01-26  7:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Thu, 25 Jan 2018 15:13:37 -0500
> 
> > Except making it work with M-x (the above will grab the "output" of the
> > M-x itself (i.e. no output), rather than the output of the command Emacs
> > runs after running the commands bound to M-x, p, w, d, and RET).
> 
> The version below seems to work (tested with M-: and M-x)

It won't work for me without some documentation.

Thanks.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-26  7:55       ` Eli Zaretskii
@ 2018-01-26 14:40         ` Stefan Monnier
  2018-01-26 15:40           ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2018-01-26 14:40 UTC (permalink / raw)
  To: emacs-devel

>> > Except making it work with M-x (the above will grab the "output" of the
>> > M-x itself (i.e. no output), rather than the output of the command Emacs
>> > runs after running the commands bound to M-x, p, w, d, and RET).
>> The version below seems to work (tested with M-: and M-x)
> It won't work for me without some documentation.

Not sure I understand what you mean:
Are you saying you'd be happy to see this code in simple.el but under
condition that I add something in the Texinfo manual about it?

Or do you mean that you need some explanation about what it does in
order for you to make it work to see for yourself?

Or do you want a more extensive docstring?

So far the code I sent was meant as a "proof of concept" mostly.


        Stefan




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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-26 14:40         ` Stefan Monnier
@ 2018-01-26 15:40           ` Eli Zaretskii
  0 siblings, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2018-01-26 15:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Fri, 26 Jan 2018 09:40:31 -0500
> 
> >> > Except making it work with M-x (the above will grab the "output" of the
> >> > M-x itself (i.e. no output), rather than the output of the command Emacs
> >> > runs after running the commands bound to M-x, p, w, d, and RET).
> >> The version below seems to work (tested with M-: and M-x)
> > It won't work for me without some documentation.
> 
> Not sure I understand what you mean:
> Are you saying you'd be happy to see this code in simple.el but under
> condition that I add something in the Texinfo manual about it?
> 
> Or do you mean that you need some explanation about what it does in
> order for you to make it work to see for yourself?
> 
> Or do you want a more extensive docstring?

The former, of course.

> So far the code I sent was meant as a "proof of concept" mostly.

Yes, I know.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 13:44 ` Kaushal Modi
  2018-01-25 14:36   ` Stefan Monnier
@ 2018-02-01 21:08   ` Marcin Borkowski
  1 sibling, 0 replies; 20+ messages in thread
From: Marcin Borkowski @ 2018-02-01 21:08 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-devel


On 2018-01-25, at 14:44, Kaushal Modi <kaushal.modi@gmail.com> wrote:

> On Thu, Jan 25, 2018 at 8:13 AM Marcin Borkowski <mbork@mbork.pl> wrote:
>
>> Hi all,
>>
>> from time to time I have a need to insert the current directory name
>> somewhere.  Some time ago, I submitted a bug report suggesting that C-u
>> M-x pwd could insert the current dir at point.  Someone made that patch
>> a few years ago, and that is great.  However, it is not enough:
>> sometimes I want to be able to yank this dir to some other application
>> (usually the terminal - I want to cd to that dir).  I made a simple
>> patch that makes `pwd' copy the current dir to the kill ring (and - by
>> default - to the system clipboard) if prefixed with C-u C-u.  I attach
>> the patch.  WDYT?
>
> I wouldn't even mind copying the default-directory to kill ring by default.
> Then you don't need C-u C-u.

Fair enough.

> As a side, in your patch:
>
>> +  "Show the current default directory. With \\[universal-argument],
> insert
>> +the current default directory at point instead.  With
> \\[universal-argument] \\[universal-argument],
>
> M-x checkdoc would fail there.. the first visual line in a doc-string must
> be a complete sentence and end in a full-stop. In your patch, the first
> visual line is incomplete (ends in ", insert"). The older version, the one
> your patch is based on, did it correctly:
>
>> -  "Show the current default directory.
>> -With prefix argument INSERT, insert the current default directory

You're right, though sometimes it's difficult to satisfy checkdoc...

Thanks,

-- 
Marcin Borkowski



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 14:36   ` Stefan Monnier
  2018-01-25 20:13     ` Stefan Monnier
@ 2018-02-01 21:09     ` Marcin Borkowski
  1 sibling, 0 replies; 20+ messages in thread
From: Marcin Borkowski @ 2018-02-01 21:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel


On 2018-01-25, at 15:36, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> I wouldn't even mind copying the default-directory to kill ring by default.
>> Then you don't need C-u C-u.
>> - M-x pwd would show the pwd and *also copy it to kill-ring*.
>> - C-u M-x pwd will only insert the pwd at point (as before).
>
> I don't have an opinion on this change, but it gives me the impression
> that we'd be better served by a more general solution, something like
>
>     (defvar copy-next-command-output--marker nil)
>     (defun copy-next-command-output ()
>       "Add the output of the next command to the `kill-ring`."
>       (interactive)
>       (cl-labels ((pre ()
>                        (remove-hook 'pre-command-hook #'pre)
>                        (add-hook 'post-command-hook #'post)
>                        (setq copy-next-command-output--marker
>                              (with-current-buffer "*Messages*"
>                                (point-max-marker))))
>                   (post ()
>                         (remove-hook 'post-command-hook #'post)
>                         (when copy-next-command-output--marker
>                           (with-current-buffer
>                               (marker-buffer copy-next-command-output--marker)
>                             (when (< copy-next-command-output--marker
>                                      (point-max))
>                               (kill-new (buffer-substring
>                                          copy-next-command-output--marker
>                                          (point-max)))))
>                           (setq copy-next-command-output--marker nil))))
>         (add-hook 'pre-command-hook #'pre)))
>
> Except making it work with M-x (the above will grab the "output" of the
> M-x itself (i.e. no output), rather than the output of the command Emacs
> runs after running the commands bound to M-x, p, w, d, and RET).

I quite like it.  It's kind of Vim-like: "do this action on the next
command".  My concern is whether it is really needed...

Thanks,

-- 
Marcin Borkowski



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-01-25 23:23         ` Stefan Monnier
@ 2018-02-01 21:11           ` Marcin Borkowski
  2018-02-01 22:03             ` Alexis
  2018-02-02  1:59             ` Stefan Monnier
  0 siblings, 2 replies; 20+ messages in thread
From: Marcin Borkowski @ 2018-02-01 21:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel


On 2018-01-26, at 00:23, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> I evaluated those two forms, and this one:
>> (global-set-key [?\C-c ?p] #'copy-next-command-output)
>
> Probably in a buffer not using lexical-binding.
> This code (like most of the code I write) presumes lexical-binding.
>
>> I think the generalisation is unwarranted in this case anyway.  I bind
>> C-c f to a command that puts the pwd on the kill ring, with a few
>> tweaks to make it more useful to me (it optionally replaces "/" with
>> "\", and if called in a buffer visiting a file, returns the file's
>> name). It's more specialised, not more general. I use it a lot.
>
> One doesn't oppose the other.  I just think it's a fairly common request
> to be able to insert the output of a command in the current buffer or
> copy it to the clipboard, and rather than tweak each and every command
> to add some clever way to do that, I think Emacs would benefit from
> having a way to do it in general.

Could you give more examples of commands that would benefit from that?
Not that I think there aren't any, just I can't think of them right now.

Best,

-- 
Marcin Borkowski



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-01 21:11           ` Marcin Borkowski
@ 2018-02-01 22:03             ` Alexis
  2018-02-02  1:59             ` Stefan Monnier
  1 sibling, 0 replies; 20+ messages in thread
From: Alexis @ 2018-02-01 22:03 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Stefan Monnier, emacs-devel


Marcin Borkowski <mbork@mbork.pl> writes:

> Could you give more examples of commands that would benefit from 
> that?
> Not that I think there aren't any, just I can't think of them 
> right
> now.

emacs-version and the describe-* commands immediately leap to 
mind;
they're commands whose output one might want to share with others 
when
trying to solve issues with Emacs, by pasting that output in a 
message
buffer. So +1 from me to Stefan's approach.


Alexis.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-01 21:11           ` Marcin Borkowski
  2018-02-01 22:03             ` Alexis
@ 2018-02-02  1:59             ` Stefan Monnier
  2018-02-02  8:51               ` Eli Zaretskii
  2018-02-06 21:03               ` Marcin Borkowski
  1 sibling, 2 replies; 20+ messages in thread
From: Stefan Monnier @ 2018-02-02  1:59 UTC (permalink / raw)
  To: emacs-devel

> Could you give more examples of commands that would benefit from that?

Several commands use C-u for similar purposes
(e.g. describe-key-briefly and eval-expression come to mind).


        Stefan




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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-02  1:59             ` Stefan Monnier
@ 2018-02-02  8:51               ` Eli Zaretskii
  2018-02-02 17:29                 ` Stefan Monnier
  2018-02-02 23:59                 ` Richard Copley
  2018-02-06 21:03               ` Marcin Borkowski
  1 sibling, 2 replies; 20+ messages in thread
From: Eli Zaretskii @ 2018-02-02  8:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Thu, 01 Feb 2018 20:59:18 -0500
> 
> > Could you give more examples of commands that would benefit from that?
> 
> Several commands use C-u for similar purposes
> (e.g. describe-key-briefly and eval-expression come to mind).

Not to forget M-! and M-|.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-02  8:51               ` Eli Zaretskii
@ 2018-02-02 17:29                 ` Stefan Monnier
  2018-02-03  0:02                   ` Richard Copley
  2018-02-02 23:59                 ` Richard Copley
  1 sibling, 1 reply; 20+ messages in thread
From: Stefan Monnier @ 2018-02-02 17:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> > Could you give more examples of commands that would benefit from that?
>> Several commands use C-u for similar purposes
>> (e.g. describe-key-briefly and eval-expression come to mind).
> Not to forget M-! and M-|.

Tho these don't put their result in the echo area, so they won't work
with my current copy-next-command-output prefix-command.

This said, it might make sense to add some hook to
copy-next-command-output such that the subsequent command can explain
where the output can be found.


        Stefan



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-02  8:51               ` Eli Zaretskii
  2018-02-02 17:29                 ` Stefan Monnier
@ 2018-02-02 23:59                 ` Richard Copley
  1 sibling, 0 replies; 20+ messages in thread
From: Richard Copley @ 2018-02-02 23:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Monnier, Emacs Development

On 2 February 2018 at 08:51, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Date: Thu, 01 Feb 2018 20:59:18 -0500
>>
>> > Could you give more examples of commands that would benefit from that?
>>
>> Several commands use C-u for similar purposes
>> (e.g. describe-key-briefly and eval-expression come to mind).
>
> Not to forget M-! and M-|.

Of course. And M-| uses C-u for a completely separate (and
actually useful!) purpose. M-! is one thing for which Stefan's
copy-next-command-output makes perfect sense. Any other example?

You can all keep ignoring the fact that it doesn't work for the
provoking example if you like. My ego isn't delicate and I don't
require any acknowledgement. I care more about the actual
project we're involved in.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-02 17:29                 ` Stefan Monnier
@ 2018-02-03  0:02                   ` Richard Copley
  0 siblings, 0 replies; 20+ messages in thread
From: Richard Copley @ 2018-02-03  0:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, Emacs Development

On 2 February 2018 at 17:29, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> > Could you give more examples of commands that would benefit from that?
>>> Several commands use C-u for similar purposes
>>> (e.g. describe-key-briefly and eval-expression come to mind).
>> Not to forget M-! and M-|.
>
> Tho these don't put their result in the echo area, so they won't work
> with my current copy-next-command-output prefix-command.
>
> This said, it might make sense to add some hook to
> copy-next-command-output such that the subsequent command can explain
> where the output can be found.

Yes! Sounds good.



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

* Re: A patch for `pwd' - copying the current directory to the kill ring
  2018-02-02  1:59             ` Stefan Monnier
  2018-02-02  8:51               ` Eli Zaretskii
@ 2018-02-06 21:03               ` Marcin Borkowski
  1 sibling, 0 replies; 20+ messages in thread
From: Marcin Borkowski @ 2018-02-06 21:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel


On 2018-02-02, at 02:59, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> Could you give more examples of commands that would benefit from that?
>
> Several commands use C-u for similar purposes
> (e.g. describe-key-briefly and eval-expression come to mind).

I will only answer here, but consider this to be an answer to the whole
thread.

I'm convinced (even if I wasn't at first).

Does that mean that we should throw away my patch?  (I'd probably vote
yes.)

Best,

--
Marcin Borkowski



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

end of thread, other threads:[~2018-02-06 21:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 13:13 A patch for `pwd' - copying the current directory to the kill ring Marcin Borkowski
2018-01-25 13:44 ` Kaushal Modi
2018-01-25 14:36   ` Stefan Monnier
2018-01-25 20:13     ` Stefan Monnier
2018-01-25 23:05       ` Richard Copley
2018-01-25 23:23         ` Stefan Monnier
2018-02-01 21:11           ` Marcin Borkowski
2018-02-01 22:03             ` Alexis
2018-02-02  1:59             ` Stefan Monnier
2018-02-02  8:51               ` Eli Zaretskii
2018-02-02 17:29                 ` Stefan Monnier
2018-02-03  0:02                   ` Richard Copley
2018-02-02 23:59                 ` Richard Copley
2018-02-06 21:03               ` Marcin Borkowski
2018-01-26  7:55       ` Eli Zaretskii
2018-01-26 14:40         ` Stefan Monnier
2018-01-26 15:40           ` Eli Zaretskii
2018-02-01 21:09     ` Marcin Borkowski
2018-02-01 21:08   ` Marcin Borkowski
2018-01-25 15:47 ` Yuri Khan

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

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

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