Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs dirtree - Directory tree view setup

I am very new to emacs, I am trying to get a directory tree. I have followed another StackOverFlow Emacs dirtree question and my .emacs and .emacs-d are as follows:

.emacs

;; line number plugin
(add-to-list 'load-path' "~/.emacs-load-path")
(require 'linum)
(global-linum-mode 1)
;; auto complete plugin
(add-to-list 'load-path "~/.emacs.d")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
;; directory tree plugin
(add-to-list 'load-path "~/.emacs.d")
(require 'dirtree)
(require 'tree-mode)
(require 'windata)
(autoload 'dirtree "dirtree" "Add directory to tree view" t)

.emacs.d

dirtree.el
tree-mode.el
windata.el

My questions are:

  1. Have I set this up correctly, if not, what do I need to do?

  2. How do you launch and use dirtree in emacs?

like image 575
user1152142 Avatar asked Dec 12 '22 04:12

user1152142


2 Answers

I tested your setup (as close as I could) and it loads the dirtree functions (and dependencies) fine. The dirtree.el file tries to map Cntl-o (\C-o) to dirtree-display function but on my system that function fails.

Happily the function dirtree-show works fine. To invoke it manually do:

  1. M-x (type Alt-x or Esc-x)
  2. Type: dirtree-show
  3. Hit Return
  4. It will prompt you for the directory to display - hit Return to show dir of current file
  5. The dirtree display will pop up in a frame on the left

Take a look at the "Tree" menu (if you have menus showing in emacs) and it will show you the keystroke shortcuts you can use. ("e" will toggle expand/collaspe of the current node, for example.)

If you don't want to type M-x dirtree-show each time, then you can bind a keystroke to it. I have bound Cntl-o like this in my .emacs:

(global-set-key "\C-o" 'dirtree-show)

So my full setup for dirtree is this:

(require 'tree-mode)
(require 'windata)
(require 'dirtree)
(autoload 'dirtree "dirtree" "Add directory to tree view" t)
(global-set-key "\C-o" 'dirtree-show)

Also, as far I can tell the line (autoload 'dirtree "dirtree" "Add directory to tree view" t) isn't required for basic functionality, but perhaps it is needed for some feature I haven't used.

Lastly, just to make sure we are on the same page, I downloaded all the .el files for this from https://github.com/zkim/emacs-dirtree.

like image 143
quux00 Avatar answered Dec 31 '22 12:12

quux00


Try NeoTree. It's easy to install and easy to use.

NeoTree screenshot, from EmacsWiki

like image 36
Tony Avatar answered Dec 31 '22 12:12

Tony