To change cursor dynamically, depending on the contents of the current line add this to your .emacs
:
(defun cursor-shape-hook ()
(if (equal (thing-at-point 'line) "\n") (setq cursor-type 'bar)
(setq cursor-type 'box)))
(add-hook 'post-command-hook 'cursor-shape-hook)
All possibilities for cursor shape are:
nil don't display a cursor
box display a filled box cursor
hollow display a hollow box cursor
bar display a vertical bar cursor with default width
(bar . WIDTH) display a vertical bar cursor with width WIDTH
hbar display a horizontal bar cursor with default height
(hbar . HEIGHT) display a horizontal bar cursor with height HEIGHT
ANYTHING ELSE display a hollow box cursor