This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Home
Alexey Veretennikov edited this page Apr 8, 2018
·
4 revisions
Here is located the user functions/tricks/workarounds which are not the part of official ztree package.
Based on use-package page: https://github.com/jwiegley/use-package
(use-package ztree
:bind (("<f8>" . ztree-dir)
("C-<f8>" . ztree-diff)))
- Only for ztree-dir module.
(use-package ztree-dir
:bind (:map ztreedir-mode-map
("f" . ztree-dir-narrow-to-dir)
("b" . ztree-dir-widen-to-parent)))
- For both ztree-dir and ztree-diff module
(use-package ztree-view
:bind (:map ztree-mode-map
("n" . next-line)
("p" . previous-line)))
The ztree-toggle-show-number-of-children
function will allow the user to turn on or off the number of directory entries. With this method, the function can be called by hitting /
from both ztree-dir and ztree-diff module.
(use-package ztree-view
:bind (:map ztree-mode-map
("n" . next-line)
("p" . previous-line)
("/" . ztree-toggle-show-number-of-children))
:preface
(defun ztree-toggle-show-number-of-children ()
(interactive)
(setf ztree-show-number-of-children
(not ztree-show-number-of-children))
(ztree-refresh-buffer)))
It is convenient sometimes to have a look at other files in the same directory as the current file is. It is convenient to bind this operation to some key, i.e. F9:
(require 'subr-x)
(defun open-ztree-for-current-buffer ()
"Open ztree in the directory of the current buffer"
(interactive)
(when-let ((current-file (buffer-file-name (current-buffer)))
(dir (file-name-directory current-file)))
(ztree-dir dir)))
(global-set-key [f9] 'open-ztree-for-current-buffer)