Commit ab18d2ed authored by Aborn Jiang's avatar Aborn Jiang Committed by GitHub

Merge pull request #240 from davidelbaze/feat_autorefresh

Feature: Automatic Refresh
parents 385f95d2 f82fc45c
......@@ -235,6 +235,11 @@ the mode-line format."
:type 'boolean
:group 'neotree)
(defcustom neo-autorefresh t
"*If non-nil, the neotree buffer will auto refresh."
:type 'boolean
:group 'neotree)
(defcustom neo-window-width 25
"*Specifies the width of the NeoTree window."
:type 'integer
......@@ -525,6 +530,8 @@ Used only when \(vc-state node\) returns nil."
(defvar neo-global--window nil)
(defvar neo-global--autorefresh-timer nil)
(defvar neo-mode-line-format
......@@ -739,8 +746,20 @@ If INIT-P is non-nil and global NeoTree buffer not exists, then create it."
(member neo-global--window windows))))
(defun neo-global--do-autorefresh ()
"Do auto refresh."
(when (neo-global--window-exists-p)
(let ((cw (selected-window)))
(neo-buffer--refresh t)
(select-window cw)
(defun neo-global--open ()
"Show the NeoTree window."
(let ((valid-start-node-p nil))
(setf valid-start-node-p (neo-buffer--valid-start-node-p)))
......@@ -807,6 +826,8 @@ The description of ARG is in `neotree-enter'."
(defun neo-global--detach ()
"Detach the global neotree buffer."
(when neo-global--autorefresh-timer
(cancel-timer neo-global--autorefresh-timer))
(setq neo-global--buffer nil)
......@@ -814,6 +835,11 @@ The description of ARG is in `neotree-enter'."
(defun neo-global--attach ()
"Attach the global neotree buffer"
(when neo-global--autorefresh-timer
(cancel-timer neo-global--autorefresh-timer))
(when neo-autorefresh
(setq neo-global--autorefresh-timer
(run-with-idle-timer 2 10 'neo-global--do-autorefresh)))
(setq neo-global--buffer (get-buffer neo-buffer-name))
(setq neo-global--window (get-buffer-window
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment