branch: master
commit d44da81f5c43b330106154e5f3ebe17a760f6a65
Author: Alexey Veretennikov <[email protected]>
Commit: Alexey Veretennikov <[email protected]>
Fixed issue #1 with electric-indent-mode by turning it off
---
ztree-diff.el | 16 ++++++++--------
ztree-dir.el | 4 ++--
ztree-util.el | 5 +++++
ztree-view.el | 11 +++++++++--
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/ztree-diff.el b/ztree-diff.el
index 044ab90..9d01d8e 100644
--- a/ztree-diff.el
+++ b/ztree-diff.el
@@ -107,27 +107,27 @@ including . and ..")
(defun ztree-diff-insert-buffer-header ()
(insert-with-face "Differences tree" ztreep-diff-header-face)
- (newline)
+ (newline-and-begin)
(when ztree-diff-dirs-pair
(insert-with-face (concat "Left: " (car ztree-diff-dirs-pair))
ztreep-diff-header-small-face)
- (newline)
+ (newline-and-begin)
(insert-with-face (concat "Right: " (cdr ztree-diff-dirs-pair))
ztreep-diff-header-small-face)
- (newline))
+ (newline-and-begin))
(insert-with-face "Legend:" ztreep-diff-header-small-face)
- (newline)
+ (newline-and-begin)
(insert-with-face " Normal file " ztreep-diff-model-normal-face)
(insert-with-face "- same on both sides" ztreep-diff-header-small-face)
- (newline)
+ (newline-and-begin)
(insert-with-face " Orphan file " ztreep-diff-model-add-face)
(insert-with-face "- does not exist on other side"
ztreep-diff-header-small-face)
- (newline)
+ (newline-and-begin)
(insert-with-face " Mismatch file " ztreep-diff-model-diff-face)
(insert-with-face "- different from other side"
ztreep-diff-header-small-face)
- (newline)
+ (newline-and-begin)
(insert-with-face "==============" ztreep-diff-header-face)
- (newline))
+ (newline-and-begin))
(defun ztree-diff-full-rescan ()
"Forces full rescan of the directory trees"
diff --git a/ztree-dir.el b/ztree-dir.el
index 5d67b64..d321d16 100644
--- a/ztree-dir.el
+++ b/ztree-dir.el
@@ -80,10 +80,10 @@ including . and ..")
(defun ztree-insert-buffer-header ()
(let ((start (point)))
(insert "Directory tree")
- (newline)
+ (newline-and-begin)
(insert "==============")
(set-text-properties start (point) '(face ztreep-header-face)))
- (newline))
+ (newline-and-begin))
(defun ztree-file-not-hidden (filename)
(not (string-match ztree-hidden-files-regexp
diff --git a/ztree-util.el b/ztree-util.el
index 0fbdadc..6698d7d 100644
--- a/ztree-util.el
+++ b/ztree-util.el
@@ -51,6 +51,11 @@ Taken from
http://www.emacswiki.org/emacs/ElispCookbook#toc39"
http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg01238.html"
(printable-string (file-name-nondirectory (directory-file-name file))))
+
+(defun newline-and-begin ()
+ (newline)
+ (beginning-of-line))
+
(defun car-atom (value)
"Returns value if value is an atom, otherwise (car value) or nil.
Used since car-safe returns nil for atoms"
diff --git a/ztree-view.el b/ztree-view.el
index e2a460e..2e0980f 100644
--- a/ztree-view.el
+++ b/ztree-view.el
@@ -179,9 +179,16 @@ the buffer is split to 2 trees")
;;;###autoload
(define-derived-mode ztree-mode special-mode "Ztree"
+ "A major mode for displaying the directory tree in text mode."
;; only spaces
(setq indent-tabs-mode nil)
- "A major mode for displaying the directory tree in text mode.")
+ ;; fix for electric-indent-mode
+ ;; for emacs 24.4
+ (if (fboundp 'electric-indent-local-mode)
+ (electric-indent-local-mode -1)
+ ;; for emacs 24.3 or less
+ (add-hook 'electric-indent-functions
+ (lambda (arg) 'no-indent) nil 'local)))
(defun ztree-find-node-in-line (line)
@@ -454,7 +461,7 @@ list of leafs"
(puthash line side ztree-line-tree-properties))
(ztree-insert-single-entry short-name depth expandable expanded 0))
(puthash line node ztree-line-to-node-table)
- (newline)
+ (newline-and-begin)
line))
(defun ztree-insert-single-entry (short-name depth