I have written a macro that makes an alias and generates global keybinding based on the name. I expect that if I add to my emacs config the following code for example:
(defkey-alias cool-function make-directory)
I will have command my-cool-function which creates a directory and a keybinding C-c c f to it. But after evaluation I have keybindings but have no command my-cool-function.
And if I do C-h k C-c c f I see:
C-c c f runs the command my-cool-function, which is an alias for `make-directory'.
I can not evaluate (my-cool-function) in scratch either.
But if I try to (macroexpand '(defkey-alias cool-function make-directory)) and then evaluate expanded s-expr it works.
What is the difference between calling macro and calling macroexpanding and then evaluation? And why alias is not callable? Thank you.
Emacs version is GNU Emacs 24.2.1, Windows 7
;;; defining keys (defun name-to-key(funname) " works like: 'my-cool-function -> \"\C-cmcl\" " (apply 'concat "\C-c" (mapcar (lambda(str)(substring str 0 1)) (split-string (symbol-name funname) "-")))) (defmacro defkey-alias(alias function) "works like defalias but you should not quote symbols and sets global key mapping Usage: (defkey-alias mkdir make-directory)" (let ((myalias (make-symbol (concat "my-" (symbol-name alias))))) `(progn (defalias ',myalias ',function) (global-set-key ,(name-to-key alias) ',myalias))))
UPDATED: Using (defun ...(interactive)(call-interactively 'function)) also does not work