Xah Talk Show 2021-05-18 emacs lisp coding a show directory as tree
(defun show-dir-tree ()
"Show current directory as a tree.
todo:
* by default, do not show files
* provide a optional arg for listing files. by `universal-argument'
Version 2021-05-18"
(interactive)
(let (
(inputDir default-directory)
allDirs inputDirDepth)
(setq allDirs
(directory-files-recursively
inputDir "." t))
(setq inputDirDepth (length (split-string inputDir "/" )))
(mapc
(lambda (x)
(let* ((splited (split-string x "/" ))
(xDepth (length splited)))
(princ (make-string (* (- xDepth inputDirDepth ) 2) ?\• ))
(princ (file-name-nondirectory x))
(princ "\n")))
allDirs)
))