(let ((saved-frame-width (frame-width)) (word "ABCDEFGH")) (with-temp-buffer (switch-to-buffer (current-buffer)) (delete-other-windows) (set-frame-width (selected-frame) 15) (visual-line-mode 1) (insert (concat "0123456789 " word)) (dolist (ch (append (vconcat word) nil)) (goto-char (point-min)) (recenter 0) (search-forward (char-to-string ch)) (backward-char) (let (old-row new-row) (setq old-row (cdr (posn-col-row (posn-at-point)))) (recenter 0) (setq new-row (cdr (posn-col-row (posn-at-point)))) (message "%c was on %d, after recenter it is on %d" ch old-row new-row)))) (set-frame-width (selected-frame) saved-frame-width))