Closed ghost closed 9 years ago
Not sure what do you want to achieve. Ztree buffer is a normal buffer, and therefore if you create a window of a proper dimensions before running the ztree-dir command, you will be switched to the ztree buffer inside this window. You can write a wrapper to create a window of a proper size before calling the ztree-dir. Am I missing something?
when i raised this question, i had vim's nerdtree in mind... i found it to be user-friendly, since the user can keep the tree on his left side and do his coding on the right... With ztree, i can see either my code (or) directory structure, unless i make a seperate window for ztree and then use it.... having said that, this issue is just a suggestion... feel free to close it....
I'm just trying to understand what is not correct with it. My simplified workflow with it could be the following: 1) Start Emacs 2) Split window vertically (C-x 3) 3) Resize window to have left window less in width than right 4) Run ztree-dir in the left window. 5) Select the file I'm interested in with Enter - it will be opened in the right window. 6) Jump to other (right) window with C-x o if I want to edit it or use my bindings to scroll-other-window/scroll-other-window-down to scroll through it without switching to it.
What I'm trying to understand am I missing something here?
my work flow is this, 1) i open a buffer in a project, start editing it.... 2) then i feel i need to open another buffer from inside the folder tree. I do ztree-toggle (i know, toggling feature is not there as of know, but it is good to have it, i suggest). ztree-toggle senses, there is no ztree buffer open 3) it creates a new ztree window on the left/right 4) after doing C-x,o, i navigate to the other file in ztree i like to edit, open it. 5) now, again i do ztree-toggle, the ztree window vanishes so that i can use all my screen space
Of course, the user opening a window (and that too, with 50% of space for navigation tree), then calling ztree is doable but not very intuitive....
Ok, I think I understand what do you mean now. I would suggest you to implement window handling manually, like split window, resize one of them to a proper size you like, launch ztree in this window(or switch to an appropriate buffer if it is already open). I don't feel like I need to add window handling code to the ztree, I expect this could be done for different persons differently depending on their needs.
This could be a starting point for you:
(defun ztree-toggle ()
(interactive)
(if (one-window-p)
(progn
(split-window-horizontally)
(window-resize (get-buffer-window) (/ (window-body-width) -2) :horizontal t)
(let ((file (buffer-file-name (current-buffer))))
(if (and file (file-exists-p file))
(ztree-dir (file-name-directory file))
(call-interactively 'ztree-dir))))
(delete-other-windows)))
it works beautifully... thanks a lot man...
I am using ztree to navigate through the folder contents. When i do, M-x ztree-dir it displays the directory tree taking up the entire space, hiding current buffer contents.
I wrote this code to make it open on the right corner, with 30% of the space. It is not working.
I don't know, if ztree has any other custom option to do this instead of going via display-buffer-alist. Emacs.stackexchange question is @ http://emacs.stackexchange.com/questions/14457/dock-ztree-directory-window-on-the-side