(if delete-from-left
#'ztree-diff-node-set-left-path
#'ztree-diff-node-set-right-path)))
- (mapcar (lambda (x) (funcall update-fun x nil))
- (cons node (ztree-diff-node-children node))))
+ (mapc (lambda (x) (funcall update-fun x nil))
+ (cons node (ztree-diff-node-children node))))
;; and update diff status
;; if was ignored keep the old status
(unless (eql (ztree-diff-node-different node) 'ignore)
(define-derived-mode ztree-mode special-mode "Ztree"
"A major mode for displaying the directory tree in text mode."
;; only spaces
- (setq indent-tabs-mode nil))
+ (setq indent-tabs-mode nil)
+ (setq buffer-read-only t))
+
(defun ztree-find-node-in-line (line)
"Return the node for the LINE specified.
(delete-region (point) (line-end-position))
;; every indentation level is 4 characters
(when (> depth 0)
- (dotimes (i depth)
- (insert-char ?\s 4))) ; insert 4 spaces
+ (insert-char ?\s (* 4 depth))) ; insert 4 spaces
(when (> (length short-name) 0)
(let ((start-pos (point)))
(if expandable
;; used in 2-side tree mode
(when ztree-node-side-fun
(setq ztree-line-tree-properties (make-hash-table)))
- (toggle-read-only)
- (erase-buffer)
- (funcall ztree-tree-header-fun)
- (setq ztree-start-line (line-number-at-pos (point)))
- (ztree-insert-node-contents ztree-start-node)
- (scroll-to-line (if line line ztree-start-line))
- (toggle-read-only)))
+ (let ((buffer-read-only nil))
+ (erase-buffer)
+ (funcall ztree-tree-header-fun)
+ (setq ztree-start-line (line-number-at-pos (point)))
+ (ztree-insert-node-contents ztree-start-node)
+ (scroll-to-line (if line line ztree-start-line)))))
(defun ztree-view (
action-fun
&optional
node-side-fun
- post-create-hook
)
"Create a ztree view buffer configured with parameters given.
Argument BUFFER-NAME Name of the buffer created.
Argument CHILDREN-FUN Function to get children from the node.
Argument FACE-FUN Function to determine face of the node.
Argument ACTION-FUN an action to perform when the Return is pressed.
-Optional argument NODE-SIDE-FUN Determines the side of the node.
-Optional argument POST-CREATE-FUN"
+Optional argument NODE-SIDE-FUN Determines the side of the node."
(let ((buf (get-buffer-create buffer-name)))
(switch-to-buffer buf)
(ztree-mode)