
;;; Adapted from https://www.reddit.com/r/emacs/comments/3v17cy/atoms_activatepowermode_counterpart_in_emacs/
(defun elmord/reddit-animated-self-insert ()
  (let* ((undo-entry (car buffer-undo-list))
         (beginning (and (consp undo-entry) (car undo-entry)))
         (end (and (consp undo-entry) (cdr undo-entry)))
         (str (when (and (numberp beginning)
                       (numberp end))
                (buffer-substring-no-properties beginning end)))
         (animate-n-steps 3))
    (when str
      (delete-region beginning end)
      (animate-string str (1- (line-number-at-pos)) (current-column)))))

(define-minor-mode elmord/reddit-animated-self-insert-mode
  "Animated self insert mode"
  nil nil nil
  (cond (elmord/reddit-animated-self-insert-mode
         (add-hook 'post-self-insert-hook 'elmord/reddit-animated-self-insert nil t))
        (t
         (remove-hook 'post-self-insert-hook 'elmord/reddit-animated-self-insert t))))
