I'm trying to get Emacs to imitate Vim's EOL behavior. Namely at the end of line ("\n"), the cursor comes to a halt instead of progressing to the start of the next line.
The following works fine and dandy but the cursor gets stuck before empty lines:
(defun make-eol-intangible () (interactive) (add-hook 'post-command-hook (lambda () (when (and (point) (looking-at "\n")) (backward-char)) t t)))
I could put an additional condition that tests for (point) looking-back however Emacs docs mention that looking-back should be avoided, and is possibly deprecated. On that note it's probably less optimal to use looking-at either.
I would like some suggestions.
Amended function (doesn't work as expected):
(defun make-eol-intangible () (interactive) (add-hook 'post-command-hook (lambda () (when (and (eq (char-before (point)) ?\n) (eq (char-after (point)) ?\.)) (backward-char))))) (make-eol-intangible)