This question already has an answer here:
I have the following function, which does what it says on the tin -- swaps the values of the
(defun swap-left-and-right-alt () "Swap left and right alt keys" (setq ns-alternate-modifier (prog1 ns-right-alternate-modifier (setq ns-right-alternate-modifier ns-alternate-modifier))))
When I put this in my
init.el, I don't get any errors, but I also don't get a
M-x autocomplete for
swap-left-and-right-alt, and if I type it out I get
I've read the manual section on defun and the section following it on installing function definitions, and it seems reasonable to think my problem is that the function isn't installed. However, when I try to install it by hand (following the manual) by opening the
init.el, placing the cursor at the end of the function definition, and hitting
C-x C-e, though this does do something (I see
swap-left-and-right-alt in the minibuffer), it still doesn't do what I want, i.e.
M-x swap-left-and-right-alt still gets me
(There is one difference: after the
C-x C-e experiment, if I try to evaluate
swap-left-and-right-alt, I get
Symbol's value as variable is void, whereas just having it in the init file I get the debugger, with
Lisp error: (void-variable swap-left-and-right-alt). Also, evaluating
(swap-left-and-right-alt), with parentheses, does appear to run the function, i.e., the keys get swapped.)
Clearly there's a conceptual piece that I'm missing, but I haven't been able to hit on the right combination of Emacs-speak search terms to find the answer.
What do I need to put in my init file to
- install the function, and
- be able to autocomplete and run the function as a command?