From: Drew Adams <drew.adams@oracle.com>
To: Spencer Baugh <sbaugh@catern.com>,
"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Prefix for command to save it as a Lisp expression
Date: Sun, 20 Feb 2022 03:18:47 +0000 [thread overview]
Message-ID: <SJ0PR10MB5488F8B11BAC28D3B7F90C77F3399@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <875ypav2su.fsf@catern.com>
> 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.
This doesn't answer your question directly.
Hopefully someone else will.
___
FWIW, I use `C-x ESC ESC' (aka `C-x M-ESC'),
which is bound to command `repeat-command'.
That doesn't save the Lisp for the `M-x'
command you _will_ enter. It shows you the
Lisp for the command that you last entered.
It shows you, in the minibuffer - to edit
and optionally enter, the Lisp sexp of the
last command invoked with `M-x'.
M-x global-set-key RET
^L ; I hit `C-l'
forward-sexp RET ; I enter forward-sexp
C-x ESC ESC
;; I'm prompted in the minibuffer:
Redo: (global-set-key "^L" 'forward-sexp)
You can grab that text and do anything you
want with it (`M-w' puts it in the kill-ring).
___
(I've written "^L" here (3 chars), but in
reality it's a string with a single char,
Control-L.)
next prev parent reply other threads:[~2022-02-20 3:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 23:45 Prefix for command to save it as a Lisp expression Spencer Baugh
2022-02-20 2:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-20 3:18 ` Drew Adams [this message]
2022-02-20 4:00 ` Eduardo Ochs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SJ0PR10MB5488F8B11BAC28D3B7F90C77F3399@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=sbaugh@catern.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.