[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Prefix for command to save it as a Lisp expression
From: |
Eduardo Ochs |
Subject: |
Re: Prefix for command to save it as a Lisp expression |
Date: |
Sun, 20 Feb 2022 01:00:27 -0300 |
On Sat, 19 Feb 2022 at 23:15, Spencer Baugh <sbaugh@catern.com> wrote:
> Hi,
>
> Is there any prefix I can type before entering a command which will add
> that command as a Lisp expression to my kill ring?
>
> For example, [prefix] C-n would add "(next-line)" to my kill-ring.
>
> The specific use case I have in mind is [prefix] M-x global-set-key,
> where after I finish running the global-set-key I'd have a Lisp
> expression I can put into my init.el.
>
> Currently, I can do this after the fact by looking at
> list-command-history and kill things out of that. But it would be cool
> if I could type some prefix and just automatically have the command be
> added to my kill ring.
>
> Alternatively, maybe there's a way to yank things directly from
> command-history? Then I could just do that after the fact, rather than
> using a prefix ahead of time, which might be even nicer.
>
> Thanks!
Hi Spencer,
I tried to implement your idea but it seems to be a bit tricky...
there are lots of occurrences of `command-history' and `add-to-history'
in the Emacs sources. But if you are interested in something that will
be ready in 5 minutes and that does a part of what you want you can
try this:
1) install eev with M-x list-packages,
2) run these two sexps:
(require 'eev-load)
(defun ch () (interactive) (find-eppp command-history))
The first sexp loads all modules of eev without turning eev-mode on,
and the second one defines `M-x ch' to be a function that
pretty-prints the value of the variable `command-history' and displays
that in an _editable_ temporary buffer. I played a bit with both `M-x
command-history' and `M-x ch' here and I found `M-x ch' much more
convenient, because I can edit some individual lines, kill other ones,
and run `M-x reverse-region' in a range of lines...
For more info on what eev-mode does, see:
http://angg.twu.net/eev-intros/find-eev-quick-intro.html#1
For more info on `find-eppp', see:
http://angg.twu.net/eev-current/eev-blinks.el.html#find-epp
Cheers,
Eduardo Ochs
http://angg.twu.net/#eev