Giving a "name" to a keyboard macro defines the macro as the
symbol-function for the symbol that has that name as its
symbol-name. In other words, the name you provide names a command.
What do you mean by "when I try to name a macro using
M-x"? Just what did you do?
It doesn't sound like you just provided
M-x as the name of your keyboard macro. There's no problem doing that. That defines a symbol
M-x, giving it a
symbol-function value that is the macro. So you can then do
M-x M-x to run the macro. Or you can then bind that command,
M-x to a key.
But if you don't bind your command
M-x to a key then the key
M-x is still bound to command
So it's not clear just what you tried to do.
Here is what
C-h k C-x C-k n says, BTW:
C-x C-k n runs the command
kmacro-name-last-macro, which is an
interactive compiled Lisp function in
It is bound to
C-x C-k n.
Assign a name to the last keyboard macro defined.
SYMBOL is the name to define.
The symbol's function definition becomes the keyboard macro string.
Such a "function" cannot be called from Lisp, but it is a valid editor command.
Note the last sentence, in case your problem was that you were trying to call it from Lisp.