On Jun 21, 2011, at 8:22 , Alan Schmitt wrote:

As a related question, is it possible to change the cursor depending on the mode?

This doesn't seem THAT related question and probably deserves it's own thread :)  But yes, it is possible to change cursor according to mode by exploiting the various hooks provided.  I tend to think this should be built into viper mode, but it's not.

---

(add-hook 'viper-insert-state-hook 'viper-set-cursor t)
(add-hook 'viper-emacs-state-hook 'viper-set-cursor t)
(add-hook 'viper-vi-state-hook 'viper-set-cursor t)

(defun viper-set-cursor ()
  "Set the cursor for a given state"
  (cond
   ((eq viper-current-state 'emacs-state) (setq cursor-type 'bar))
   ((eq viper-current-state 'vi-state) (setq cursor-type 'hollow))
   ((eq viper-current-state 'viper-mark-state) (setq cursor-type 'bar))
   ((eq viper-current-state 'visual-state) (setq cursor-type 'hbar))))

(defun viper-restore-cursor-type ()
  (viper-set-cursor))

---

Tim