visual-line-mode enabled in Emacs, long lines wrap at natural breaks in the text, allowing me to see all of the text on any given line.
Wrap appears in my status bar. Sometimes I want to the lines to not wrap. I can toggle that state by command:
M-x visual-line-mode. However, when I do that,
C-e does not take me to the end of the line, but instead somewhere towards a "screenwidth" or so, though it seems to be variable.
I can fix that problem by calling
M-x toggle-truncate-lines after running the
M-x visual-line-mode, but what I'd like to do is use a single Function key command to run both commands in sequence.
.emacs file I currently have this:
(global-set-key [f8] 'toggle-truncate-lines) (global-set-key [f9] 'visual-line-mode)
With these keys defined, I can use the function keys
f8 in sequence to get the results I want. I thought I could write an elisp function to call the two functions in sequence, and then map a single function key to that function, like so:
(defun unwrap-lines () "Unwrap lines, and fix the C-e not to the end problem" (interactive) (visual-line-mode) (toggle-truncate-lines)) (global-set-key [f10] 'unwrap-lines)
However, after defining this function, it seems to only call the second command in my function
toggle-truncate-lines, and skips the
visual-line-mode aspect of the function.
What am I doing wrong?