I want to perform the same action that one does by hitting C-Space + moving the arrow keys, but in elisp.
Failing to find the right function (if they just were logically grouped in namespaces or somehow tagged…). Which one is it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can translate keystrokes to elisp using C-h k key.
You’ll notice the elisp function for setting the mark
set-mark-command, takes one non-optional argument. Emacs uses the specialinteractivefunction to allow elisp functions to be written naturally with arguments. This allows them to be generic and easy to reuse in other elisp programs, while still possible to invoke directly from a keystroke. It also has some of the C-u prefix logic built-in.In the case of
set-mark-command, its first function is(interactive "P"), which means the prefix is passed in as an argument when called from the keyboard. You can simulate this directly in elisp with:For example, to select the current line in elisp:
Note you have to tell emacs to leave the mark active at the end or else the region won’t remain highlighted (although the point and mark will be where you left them).