From 40e5357566b6d617eb356e501240b8b10f4b76fc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 17 Feb 2018 18:51:14 -0500 Subject: [PATCH] tools/neotree: keep cursor at beginning-of-text, not bol --- modules/tools/neotree/config.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/tools/neotree/config.el b/modules/tools/neotree/config.el index c2560e4c8..6d57badde 100644 --- a/modules/tools/neotree/config.el +++ b/modules/tools/neotree/config.el @@ -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))