I'm completely new to elisp, and I want a function which cycles through 3 options:
- Highlight the word.
- Highlight the sentence.
- Then highlight the paragraph.
What is the proper way to get the function to (setq setnewpoint t)
and (setq cyclemarker 1)
if I C-g
mid-cycle?
(setq cyclemarker 1)
(setq setnewpoint t)
(defun highlight-cycle ()
(interactive)
(if setnewpoint
(progn
(forward-word)
(backward-word)
(point-to-register 1)
(setq setnewpoint nil)))
(cond ((= cyclemarker 1)
(progn
(register-to-point 1)
(setq setnewpoint t)
(setq cyclemarker 2)
(keyboard-quit)))
((= cyclemarker 2)
(progn
(register-to-point 1)
(mark-word)
(setq cyclemarker 3)))
((= cyclemarker 3)
(progn
(register-to-point 1)
(mark-end-of-sentence 1)
(forward-sentence 1)
(backward-sentence 1)
(setq cyclemarker 4)
))
((= cyclemarker 4)
(progn
(register-to-point 1)
(mark-paragraph)
(cond ((/= (line-beginning-position) (point-min))
(next-line)
(beginning-of-line)))
(setq cyclemarker 1)))
))
unwind-protect
.condition-case
withquit
, and have the behavior be that when you useC-g
(quit
) during the command it resets the things you want to reset and then reinvokes the command. I would not advisekeyboard-quit
or in any other way try to have aC-g
outside of the command affect the state for the command.