emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A patch for `pwd' - copying the current directory to the kill ring


From: Marcin Borkowski
Subject: Re: A patch for `pwd' - copying the current directory to the kill ring
Date: Thu, 01 Feb 2018 22:09:51 +0100
User-agent: mu4e 0.9.19; emacs 27.0.50

On 2018-01-25, at 15:36, Stefan Monnier <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]