Here is the problem that I'm solving: Convert a region of text into a string data structure for subsequent processing by elisp program. The challenge is that
- I want to execute an elisp program interactively without affecting the selection of a region
- store the string value into a variable so that I can further manipulate it.
By my understanding, a region is defined by a mark and the subsequent cursor position. And I usually execute elisp program in *scratch* buffer. Furthermore, the region is also in the *scratch* buffer.
But to write the function call and execute it in the buffer, I need to move the cursor away from the end of the text selection (region) in order to write the program of
(setq grabbed (buffer-substring-no-properties (region-beginning) (region-end)))
but then the region of selection would change due to the cursor movement.
So I wonder how I could execute the elisp program while keeping the selection intact and still can access the return value.
emacs -Q
(no init file), and saying what you see at each step and what you expected to see instead. - Drew