tools/neotree: keep cursor at beginning-of-text, not bol

This commit is contained in:
Henrik Lissner 2018-02-17 18:51:14 -05:00
parent 2425893cc9
commit 40e5357566
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -38,4 +38,18 @@
'((quit . current) (select . t)))
(when (bound-and-true-p winner-mode)
(push neo-buffer-name winner-boring-buffers)))
(push neo-buffer-name winner-boring-buffers))
;; The cursor always sits at bol. `+neotree*fix-cursor' and
;; `+neotree*indent-cursor' change that behavior, so that the cursor is always
;; on the first non-blank character on the line, in the neo buffer.
(defun +neotree*fix-cursor (&rest _)
(with-current-buffer neo-global--buffer
(+neotree*indent-cursor)))
(add-hook 'neo-enter-hook #'+neotree*fix-cursor)
(defun +neotree*indent-cursor (&rest _)
(beginning-of-line)
(skip-chars-forward " \t\r"))
(advice-add #'neotree-next-line :after #'+neotree*indent-cursor)
(advice-add #'neotree-previous-line :after #'+neotree*indent-cursor))