]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ztree/ztree-dir.el
multishell - Merge commit '8d70b90b6f5b326749fbd1b8597ecf5cfc9b47d0'
[gnu-emacs-elpa] / packages / ztree / ztree-dir.el
index 47a57cd9cea1dd9388201cebc89abef9c7d6f07e..3dd87b7f78e462f598a0b939b6956fc1c52a3c5f 100644 (file)
@@ -1,4 +1,4 @@
-;;; ztree-dir.el --- Text mode directory tree
+;;; ztree-dir.el --- Text mode directory tree -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2013-2015  Free Software Foundation, Inc.
 ;;
@@ -8,7 +8,7 @@
 ;;
 ;; Keywords: files tools
 ;; URL: https://github.com/fourier/ztree
-;; Compatibility: GNU Emacs GNU Emacs 24.x
+;; Compatibility: GNU Emacs 24.x
 ;;
 ;; This file is part of GNU Emacs.
 ;;
   "Hidden files regexp.
 By default all filest starting with dot '.', including . and ..")
 
+;;
+;; Configurable variables
+;; 
+
+(defvar ztree-dir-move-focus nil
+  "If set to true moves the focus to opened window when the
+user press RETURN on file ")t
+
 
 ;;
 ;; Faces
@@ -76,15 +84,15 @@ By default all filest starting with dot '.', including . and ..")
   "Insert the header to the ztree buffer."
   (let ((start (point)))
     (insert "Directory tree")
-    (newline-and-begin)
+    (insert "\n")
     (insert "==============")
     (set-text-properties start (point) '(face ztreep-header-face)))
-  (newline-and-begin))
+  (insert "\n"))
 
 (defun ztree-file-not-hidden (filename)
   "Determines if the file with FILENAME should be visible."
   (not (string-match ztree-hidden-files-regexp
-                     (file-short-name filename))))
+                     (ztree-file-short-name filename))))
 
 (defun ztree-find-file (node hard)
   "Find the file at NODE.
@@ -92,9 +100,12 @@ By default all filest starting with dot '.', including . and ..")
 If HARD is non-nil, the file is opened in another window.
 Otherwise, the ztree window is used to find the file."
   (when (and (stringp node) (file-readable-p node))
-    (if hard
-        (save-selected-window (find-file-other-window node))
-      (find-file node))))
+    (cond ((and hard ztree-dir-move-focus)
+           (find-file-other-window node))
+          (hard
+           (save-selected-window (find-file-other-window node)))
+          (t 
+           (find-file node)))))
 
 ;;;###autoload
 (defun ztree-dir (path)
@@ -106,7 +117,7 @@ Otherwise, the ztree window is used to find the file."
                   (expand-file-name (substitute-in-file-name path))
                   'ztree-file-not-hidden
                   'ztree-insert-buffer-header
-                  'file-short-name
+                  'ztree-file-short-name
                   'file-directory-p
                   'string-equal
                   '(lambda (x) (directory-files x 'full))