Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • janitor-team/proposed/ztree
  • emacsen-team/ztree
2 results
Show changes
Commits on Source (32)
2017-01-05 Alexey Veretennikov <alexey.veretennikov@gmail.com>
1) Implemented feature: narrow/widen directories in ztree-dir 2) Fixed
regression in TRAMP mode while in ztree-diff 3) Updated docstrings.
Merge commit '3a4df17edddef84160194802acc034cfa2dbd678'
2016-12-27 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge commit '2751b96aca36cc5c31dc105ec985c269126420a0'
2016-12-26 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Issue #18: files considered different if they have different sizes
Merge commit '6826c3f3f3735fbf060206072392d67f0990f817'
2016-09-25 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge commit 'e5eb534859acc0cc0a13403fd166457db9fb7eb5'
Added fix for debbugs 24200 debbugs.gnu.org/24200 proposed by Michael
Albinus
2016-09-24 Alexey Veretennikov <alexey.veretennikov@gmail.com>
ztree: increased version
2016-09-24 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge commit '07009d7695eb7b82225712336fe388495dd48169'
- Fixed broken 'x' button in ztree-dir
- Fixed broken compare over tramp
2016-07-11 Paul Eggert <eggert@cs.ucla.edu>
Fix some quoting problems in doc strings
Most of these are minor issues involving, e.g., quoting `like this'
instead of 'like this'. A few involve escaping ` and ' with a preceding
\= when the characters should not be turned into curved single quotes.
2016-01-28 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merged from upstream with StefanM's changes
2016-01-24 Stefan Monnier <monnier@iro.umontreal.ca>
* ztree/ztree-diff-model.el (ztree-diff-node): Use cl-defstruct
(ztree-diff-model-partial-rescan, ztree-diff-model-subtree)
(ztree-diff-node-update-diff-from-children, )
(ztree-diff-node-traverse):
* ztree/ztree-diff.el (ztree-diff-copy-file, ztree-diff-copy-dir)
(ztree-diff-delete-file): Adjust accordingly.
* ztree/ztree-dir.el (ztree-dir): Don't quote lambda.
* ztree/ztree.el: Fix up maintainer address. Add cl-lib dependency.
* ztree/ztree-util.el (ztree-defrecord): Delete.
2016-01-21 Stefan Monnier <monnier@iro.umontreal.ca>
* packages/gnome-c-style/gnome-c-tests.el: Add copyright blurb
2015-07-11 Stefan Monnier <monnier@iro.umontreal.ca>
* ztree/ztree-pkg.el: Remove since it's auto-generated
2015-06-18 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
1) Fixed bug with where the user unable to delete a file
or directory 2) Added hotkey 'H' in ztree-diff to toggle between
hide/show
of the ignored files (i.e. starting with .dot) 3) Ignored files do not
affect the directory status anymore. 4) Since the new hotkey is added,
the version number is increased.
2015-06-17 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
Fixed code submitted by mistake
2015-06-13 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
1) All functions now starts with ztree- prefix 2) All files now have
lexical-binding enabled
2015-06-13 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
Added added variable ztree-dir-move-focus; if set move the focus to
opened editor window when the user press Enter
2015-06-12 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
1) Removed redundant comments about compatibility with GNU Emacs 2)
Removed workaround for electric-indent-mode
2015-06-11 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
Replaced pkg file with autogenerated for ztree package.
2015-06-11 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Merge remote-tracking branch 'ztree/master'
Added missing ztree.el
2015-06-11 Alexey Veretennikov <alexey.veretennikov@gmail.com>
Added ztree package
This diff is collapsed.
......@@ -58,6 +58,18 @@ By default all files starting with dot (like `.gitignore`) are not shown and exc
One also could turn on unicode characters to draw the tree with instead of normal ASCII-characters. This is controlled by the `ztree-draw-unicode-lines` variable.
The variable `ztree-diff-consider-file-permissions` (which is `nil` by default) if set to `t` allows to compare file attributes as well, the files will be considered different if they have different mode.
The special variable `ztree-diff-additional-options`
introduced to provide an additional arguments
to the 'diff' tool.
For example one could specify
```
(setq ztree-diff-additional-options '("-w" "-i"))
```
to ignore case differences and whitespace differences.
### Screenshots
![ztreediff emacsx11](https://github.com/fourier/ztree/raw/screenshots/screenshots/emacs_diff_xterm.png "Emacs in xterm with ztree-diff")
......@@ -80,6 +92,7 @@ M-x ztree-dir
* To toggle open/closed state of the subtree of the current directory, hit the `x` key.
* To visit a file, press `Space` key.
* To open file in other window, use `RET` key.
* To open `Dired` with the directory the point is currently on, use the `d` key.
### Customizations
Set the `ztree-dir-move-focus` variable to `t` in order to move focus to the other window when the `RET` key is pressed; the default behavior is to keep focus in `ztree-dir` window.
......
ztree (1.0.5-4) UNRELEASED; urgency=medium
ztree (1.0.6-2) unstable; urgency=medium
* Team upload.
* Rebuild against dh-elpa 2.1.5.
Upload pushed to dgit-repos but not salsa.
See <https://lists.debian.org/debian-emacsen/2024/07/msg00077.html>.
-- Sean Whitton <spwhitton@spwhitton.name> Fri, 26 Jul 2024 11:47:44 +0900
ztree (1.0.6-1) unstable; urgency=medium
* New upstream version 1.0.6
* Refresh patches
* d/control: Declare Standards-Version 4.6.0 (no changes needed)
* d/copyright: Update copyright information
-- Lev Lamberov <dogsleg@debian.org> Wed, 18 Aug 2021 19:59:40 +0500
ztree (1.0.5-4) unstable; urgency=medium
[ David Krauser ]
* Update maintainer email address
-- David Krauser <david@krauser.org> Fri, 04 Oct 2019 14:56:43 -0400
[ Lev Lamberov ]
* Add upstream metadata
* Migrate to dh 13 without d/compat
* d/control: Add Rules-Requires-Root: no
* d/control: Clean Depends and Enhances
* d/control: Declare Standards-Version 4.5.1 (no changes needed)
* d/control: Drop Built-Using field
* d/copyright: Bump copyright years
* d/rules: Do not pass --parallel to dh
* d/watch: Migrate to version 4
-- Lev Lamberov <dogsleg@debian.org> Sat, 02 Jan 2021 15:17:59 +0500
ztree (1.0.5-3) unstable; urgency=medium
......
10
Source: ztree
Section: lisp
Priority: optional
Maintainer: Debian Emacsen Team <debian-emacsen@lists.debian.org>
Maintainer: Debian Emacsen team <debian-emacsen@lists.debian.org>
Uploaders: Lev Lamberov <dogsleg@debian.org>
Build-Depends: debhelper (>= 10),
Build-Depends: debhelper-compat (= 13),
dh-elpa
Standards-Version: 3.9.8
Standards-Version: 4.6.0
Rules-Requires-Root: no
Homepage: https://github.com/fourier/ztree
Vcs-Browser: https://salsa.debian.org/emacsen-team/ztree
Vcs-Git: https://salsa.debian.org/emacsen-team/ztree.git
......@@ -13,13 +14,9 @@ Vcs-Git: https://salsa.debian.org/emacsen-team/ztree.git
Package: elpa-ztree
Architecture: all
Depends: ${elpa:Depends},
${misc:Depends},
emacs
${misc:Depends}
Recommends: emacs (>= 46.0)
Enhances: emacs,
emacs24,
emacs25
Built-Using: ${misc:Built-Using}
Enhances: emacs
Description: text mode directory tree
ztree is a project dedicated to implementation of several text-tree
applications inside GNU Emacs. It consists of 2 subprojects: ztree-diff and
......
......@@ -4,11 +4,11 @@ Upstream-Contact: Alexey Veretennikov <alexey.veretennikov@gmail.com>
Source: https://github.com/fourier/ztree
Files: *
Copyright: (C) 2013-2016 Free Software Foundation, Inc.
Copyright: (C) 2013-2021 Free Software Foundation, Inc.
License: GPL-3+
Files: debian/*
Copyright: (C) 2016 Lev Lamberov <dogsleg@debian.org>
Copyright: (C) 2016-2021 Lev Lamberov <dogsleg@debian.org>
License: GPL-3+
License: GPL-3+
......
......@@ -6,9 +6,9 @@ from an external web site.
--- a/README.md
+++ b/README.md
@@ -58,15 +58,9 @@ By default all files starting with dot (
@@ -70,15 +70,9 @@ For example one could specify
to ignore case differences and whitespace differences.
One also could turn on unicode characters to draw the tree with instead of normal ASCII-characters. This is controlled by the `ztree-draw-unicode-lines` variable.
-### Screenshots
-
......@@ -23,7 +23,7 @@ from an external web site.
Call the `ztree-dir` interactive function:
@@ -84,12 +78,6 @@ M-x ztree-dir
@@ -97,12 +91,6 @@ M-x ztree-dir
### Customizations
Set the `ztree-dir-move-focus` variable to `t` in order to move focus to the other window when the `RET` key is pressed; the default behavior is to keep focus in `ztree-dir` window.
......@@ -36,7 +36,7 @@ from an external web site.
## Contributions
You can contribute to **ztree** in one of the following ways.
- Submit a bug report
@@ -105,4 +93,3 @@ For more information one can read [here]
@@ -118,4 +106,3 @@ For more information one can read [here]
As soon as the paperwork is done one can contribute to **ztree** with bigger pull requests.
Note what pull requests without paperwork done will not be accepted, so please notify the [maintainer](mailto:alexey.veretennikov@gmail.com) if everything is in place.
......
#!/usr/bin/make -f
%:
dh $@ --parallel --with elpa
dh $@ --with elpa
---
Bug-Database: https://github.com/fourier/ztree/issues
Bug-Submit: https://github.com/fourier/ztree/issues/new
Repository: https://github.com/fourier/ztree.git
Repository-Browse: https://github.com/fourier/ztree
......@@ -2,5 +2,5 @@
# an error. This is okay: we're using gbp to produce orig.tar files so we only
# need uscan to download.
version=3
version=4
https://elpa.gnu.org/packages/ztree.html ztree-(.+).tar
;;; ztree-diff-model.el --- diff model for directory trees -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
;;
;; Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
;;
......@@ -33,17 +33,21 @@
(require 'ztree-util)
(eval-when-compile (require 'cl-lib))
(defvar-local ztree-diff-model-ignore-fun nil
"Function which determines if the node should be excluded from comparison.")
(defvar ztree-diff-consider-file-permissions nil
"Mark files as different if their permissions are different")
(defvar ztree-diff-consider-file-size t
"Mark files as different if their size different")
(defvar-local ztree-diff-model-progress-fun nil
"Function which should be called whenever the progress indications is updated.")
(defvar ztree-diff-additional-options nil
"Command-line options for the diff program used as a diff backend. These options are added to default '-q' option.
Should be a list of strings.
Example:
(setq ztree-diff-options '(\"-w\" \"-i\"))")
(defvar-local ztree-diff-model-ignore-fun nil
"Function which determines if the node should be excluded from comparison.")
(defun ztree-diff-model-update-progress ()
"Update the progress."
(when ztree-diff-model-progress-fun
(funcall ztree-diff-model-progress-fun)))
;; Create a record ztree-diff-node with defined fields and getters/setters
;; here:
......@@ -146,11 +150,18 @@ Returns t if equal."
(let* ((file1-untrampified (ztree-untrampify-filename file1))
(file2-untrampified (ztree-untrampify-filename file2)))
(if (or
(/= (nth 7 (file-attributes file1))
(nth 7 (file-attributes file2)))
(/= 0 (process-file diff-command nil nil nil "-q"
file1-untrampified
file2-untrampified)))
(and ztree-diff-consider-file-size
(/= (nth 7 (file-attributes file1))
(nth 7 (file-attributes file2))))
(and ztree-diff-consider-file-permissions
(not (string-equal (nth 8 (file-attributes file1))
(nth 8 (file-attributes file2)))))
(/= 0
(apply #'process-file
diff-command nil nil nil
`("-q" ,@ztree-diff-additional-options
,file1-untrampified
,file2-untrampified))))
'diff
'same)))
......@@ -168,7 +179,7 @@ The node is a either a file or directory with both
left and right parts existing."
;; if a directory - recreate
(if (ztree-diff-node-is-directory node)
(ztree-diff-node-recreate node)
(ztree-diff-node-recreate-with-progress node)
;; if a file, change a status
(setf (ztree-diff-node-different node)
(if (or (ztree-diff-model-ignore-p node) ; if should be ignored
......@@ -275,9 +286,16 @@ if parent has ignored status - ignore"
(or (eql (ztree-diff-node-different parent) 'ignore)
(ztree-diff-model-ignore-p node)))))
(defun ztree-diff-node-recreate-with-progress (node)
"Initiate update of the NODE with a progress printout"
(let ((progress-reporter
(make-progress-reporter (concat "Comparing " (ztree-diff-node-left-path node) " and " (ztree-diff-node-right-path node) " ..."))))
(ztree-diff-node-recreate node progress-reporter)
(progress-reporter-done progress-reporter)))
(defun ztree-diff-node-recreate (node)
"Traverse 2 paths defined in the NODE updating its children and status."
(defun ztree-diff-node-recreate (node &optional reporter)
"Traverse 2 paths defined in the NODE updating its children and status.
When REPORTER provided update the progress."
(let* ((list1 (ztree-directory-files (ztree-diff-node-left-path node))) ;; left list of liles
(list2 (ztree-directory-files (ztree-diff-node-right-path node))) ;; right list of files
(should-ignore (ztree-diff-model-should-ignore node))
......@@ -285,7 +303,8 @@ if parent has ignored status - ignore"
(children-status (if should-ignore 'ignore 'new))
(children nil)) ;; list of children
;; update waiting status
(ztree-diff-model-update-progress)
(when reporter
(progress-reporter-update reporter))
;; update node status ignore status either inhereted from the
;; parent or the own
(when should-ignore
......@@ -363,7 +382,7 @@ if parent has ignored status - ignore"
(defun ztree-diff-model-update-node (node)
"Refresh the NODE."
(ztree-diff-node-recreate node))
(ztree-diff-node-recreate-with-progress node))
......@@ -375,12 +394,6 @@ with dot etc)."
(setf ztree-diff-model-ignore-fun ignore-p))
(defun ztree-diff-model-set-progress-fun (progress-fun)
"Setter for the buffer-local PROGRESS-FUN callback.
This callback is called to indicate the ongoing activity.
Callback is a function without arguments."
(setf ztree-diff-model-progress-fun progress-fun))
(provide 'ztree-diff-model)
;;; ztree-diff-model.el ends here
;;; ztree-diff.el --- Text mode diff for directory trees -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
;;
;; Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
;;
......@@ -28,6 +28,7 @@
;;; Commentary:
;;; Code:
(eval-when-compile (require 'cl-lib))
(require 'ztree-view)
(require 'ztree-diff-model)
......@@ -92,9 +93,16 @@ By default paths starting with dot (like .git) are ignored")
(defvar-local ztree-diff-show-filtered-files nil
"Show or not files from the filtered list.")
(defvar-local ztree-diff-wait-message nil
"Message showing while constructing the diff tree.")
(defvar-local ztree-diff-show-right-orphan-files t
"Show or not orphan files/directories on right side.")
(defvar-local ztree-diff-show-left-orphan-files t
"Show or not orphan files/directories on left side.")
(defvar ztree-diff-ediff-previous-window-configurations nil
"Window configurations prior to calling `ediff'.
A queue of window configurations, allowing
to restore last configuration even if there were a couple of ediff sessions")
;;;###autoload
(define-minor-mode ztreediff-mode
......@@ -186,10 +194,7 @@ By default paths starting with dot (like .git) are ignored")
(if (not parent)
(when ztree-diff-dirs-pair
(ztree-diff (car ztree-diff-dirs-pair) (cdr ztree-diff-dirs-pair)))
(ztree-diff-update-wait-message
(concat "Updating " (ztree-diff-node-short-name common) " ..."))
(ztree-diff-model-partial-rescan common)
(message "Done")
(ztree-refresh-buffer (line-number-at-pos)))))
......@@ -224,6 +229,35 @@ Argument NODE node containing paths to files to call a diff on."
(let ((node (car found)))
(ztree-diff-simple-diff node)))))
(defun ztree-diff-ediff-before-setup-hook-function ()
"Hook function for `ediff-before-setup-hook'.
See the Info node `(ediff) hooks'.
This hook function removes itself."
(push (current-window-configuration) ztree-diff-ediff-previous-window-configurations)
(ztree-save-current-position)
(remove-hook 'ediff-before-setup-hook #'ztree-diff-ediff-before-setup-hook-function))
(defun ztree-diff-ediff-quit-hook-function ()
"Hook function for `ediff-quit-hook'.
See the Info node `(ediff) hooks'.
This hook function removes itself."
(set-window-configuration (pop ztree-diff-ediff-previous-window-configurations))
(ztree-refresh-buffer)
(remove-hook 'ediff-quit-hook #'ztree-diff-ediff-quit-hook-function))
(defun ztree-diff-ediff (file-a file-b &optional startup-hooks)
"Ediff that cleans up after itself.
Ediff-related buffers are killed and the pre-Ediff window
configuration is restored."
(add-hook 'ediff-before-setup-hook #'ztree-diff-ediff-before-setup-hook-function)
(add-hook 'ediff-quit-hook #'ztree-diff-ediff-quit-hook-function t)
(ediff file-a file-b startup-hooks))
(defun ztree-diff-node-action (node hard)
"Perform action on NODE:
1 if both left and right sides present:
......@@ -232,6 +266,9 @@ Argument NODE node containing paths to files to call a diff on."
1.1.2 simple diff otherwiste
1.2 if they are the same - view left
2 if left or right present - view left or rigth"
;; save current position in case if the window
;; configuration will change
(ztree-save-current-position)
(let ((left (ztree-diff-node-left-path node))
(right (ztree-diff-node-right-path node))
;; FIXME: The GNU convention is to only use "path" for lists of
......@@ -243,7 +280,7 @@ Argument NODE node containing paths to files to call a diff on."
(if (eql (ztree-diff-node-different node) 'same)
(funcall open-f left)
(if hard
(ediff left right)
(ztree-diff-ediff left right)
(ztree-diff-simple-diff node))))
(left (funcall open-f left))
(right (funcall open-f right))
......@@ -309,11 +346,8 @@ COPY-TO-RIGHT specifies which side of the NODE to update."
(if copy-to-right
(setf (ztree-diff-node-right-path node) target-full-path)
(setf (ztree-diff-node-left-path node) target-full-path))
(ztree-diff-update-wait-message
(concat "Updating " (ztree-diff-node-short-name node) " ..."))
;; TODO: do not rescan the node. Use some logic like in delete
(ztree-diff-model-update-node node)
(message "Done.")
(ztree-diff-node-update-all-parents-diff node)
(ztree-refresh-buffer (line-number-at-pos))))))
......@@ -473,9 +507,13 @@ unless it is a parent node."
;; visible then
;; either it is a root. root have no parent
(or (not (ztree-diff-node-parent node)) ; parent is always visible
;; or the files are different or orphan
(or (eql diff 'new)
(eql diff 'diff))
;; or the files are different
(eql diff 'diff)
;; or it is orphaned, but show orphaned files for now
(and (eql diff 'new)
(if (ztree-diff-node-left-path node)
ztree-diff-show-left-orphan-files
ztree-diff-show-right-orphan-files))
;; or it is ignored but we show ignored for now
(and (eql diff 'ignore)
ztree-diff-show-filtered-files)
......@@ -483,28 +521,76 @@ unless it is a parent node."
(and (eql diff 'same)
ztree-diff-show-equal-files))))
(defun ztree-diff-toggle-show-equal-files ()
"Toggle visibility of the equal files."
(defmacro ztree-diff-define-toggle-show (what)
(let ((funcsymbol (intern (concat "ztree-diff-toggle-show-" what "-files")))
(variable (intern (concat "ztree-diff-show-" what "-files")))
(fundesc (concat "Toggle visibility of the " what " files/directories")))
`(defun ,funcsymbol ()
,fundesc
(interactive)
(setq ,variable (not ,variable))
(message (concat (if ,variable "Show " "Hide ") ,what " files"))
(ztree-refresh-buffer))))
(ztree-diff-define-toggle-show "equal")
(ztree-diff-define-toggle-show "filtered")
(ztree-diff-define-toggle-show "left-orphan")
(ztree-diff-define-toggle-show "right-orphan")
(defun ztree-diff-toggle-show-orphan-files ()
"Toggle visibility of left and right orphan files."
(interactive)
(setq ztree-diff-show-equal-files (not ztree-diff-show-equal-files))
(message (concat (if ztree-diff-show-equal-files "Show" "Hide") " equal files"))
(ztree-refresh-buffer))
(let ((show (not ztree-diff-show-left-orphan-files)))
(setq ztree-diff-show-left-orphan-files show)
(setq ztree-diff-show-right-orphan-files show)
(message (concat (if show "Show" "Hide") " orphan files"))
(ztree-refresh-buffer)))
(defun ztree-diff-toggle-show-filtered-files ()
"Toggle visibility of the filtered files."
(interactive)
(setq ztree-diff-show-filtered-files (not ztree-diff-show-filtered-files))
(message (concat (if ztree-diff-show-filtered-files "Show" "Hide") " filtered files"))
(ztree-refresh-buffer))
;;
;; Implementation of the ztree-protocol
;;
(cl-defmethod ztree-node-visible-p ((node ztree-diff-node))
"Return T if the NODE shall be visible."
(ztree-node-is-visible node))
(cl-defmethod ztree-node-short-name ((node ztree-diff-node))
"Return the short name for a node."
(ztree-diff-node-short-name-wrapper node nil))
(defun ztree-diff-update-wait-message (&optional msg)
"Update the wait message MSG with one more `.' progress indication."
(if msg
(setq ztree-diff-wait-message msg)
(when ztree-diff-wait-message
(setq ztree-diff-wait-message (concat ztree-diff-wait-message "."))))
(message ztree-diff-wait-message))
(cl-defmethod ztree-node-right-short-name ((node ztree-diff-node))
"Return the short name for a node."
(ztree-diff-node-short-name-wrapper node t))
(cl-defmethod ztree-node-expandable-p ((node ztree-diff-node))
"Return T if the node is expandable."
(ztree-diff-node-is-directory node))
(cl-defmethod ztree-node-equal ((node1 ztree-diff-node) (node2 ztree-diff-node))
"Equality function for NODE1 and NODE2.
Return T if nodes are equal"
(ztree-diff-node-equal node1 node2))
(cl-defmethod ztree-node-children ((node ztree-diff-node))
"Return a list of NODE children"
(ztree-diff-node-children node))
(cl-defmethod ztree-node-action ((node ztree-diff-node) hard)
"Perform an action when the Return is pressed on a NODE."
(ztree-diff-node-action node hard))
(cl-defmethod ztree-node-side ((node ztree-diff-node))
"Determine the side of the NODE."
(ztree-diff-node-side node))
(cl-defmethod ztree-node-face ((node ztree-diff-node))
"Return a face to write a NODE in"
(ztree-diff-node-face node))
;;
;; Entry point
;;
;;;###autoload
(defun ztree-diff (dir1 dir2)
......@@ -532,28 +618,14 @@ Argument DIR2 right directory."
;; after this command we are in a new buffer,
;; so all buffer-local vars are valid
(ztree-view buf-name
#'ztree-diff-insert-buffer-header
model
'ztree-node-is-visible
'ztree-diff-insert-buffer-header
'ztree-diff-node-short-name-wrapper
'ztree-diff-node-is-directory
'ztree-diff-node-equal
'ztree-diff-node-children
'ztree-diff-node-face
'ztree-diff-node-action
'ztree-diff-node-side)
(ztreediff-mode)
(ztree-diff-model-set-ignore-fun #'ztree-diff-node-ignore-p)
(ztree-diff-model-set-progress-fun #'ztree-diff-update-wait-message)
(setq ztree-diff-dirs-pair (cons dir1 dir2))
(ztree-diff-update-wait-message (concat "Comparing " dir1 " and " dir2 " ..."))
(ztree-diff-node-recreate model)
(message "Done.")
(ztree-refresh-buffer)))
(lambda ()
(ztree-diff-model-set-ignore-fun #'ztree-diff-node-ignore-p)
(setq ztree-diff-dirs-pair (cons dir1 dir2))
(ztree-diff-node-recreate-with-progress model)
(ztreediff-mode))
t)))
......
;;; ztree-dir.el --- Text mode directory tree -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
;;
;; Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
;;
......@@ -45,7 +45,8 @@
(require 'ztree-util)
(require 'ztree-view)
(require 'cl-lib)
(require 'ztree-protocol)
(eval-when-compile (require 'cl-lib))
;;
;; Constants
......@@ -97,7 +98,8 @@ One could add own filters in the following way:
`(
(,(kbd "H") . ztree-dir-toggle-show-filtered-files)
(,(kbd ">") . ztree-dir-narrow-to-dir)
(,(kbd "<") . ztree-dir-widen-to-parent)))
(,(kbd "<") . ztree-dir-widen-to-parent)
(,(kbd "d") . ztree-dir-open-dired-at-point)))
......@@ -154,6 +156,12 @@ Otherwise, the ztree window is used to find the file."
(directory-files path 'full)))
(defun ztree-dir-change-directory (node)
"Change the start node to NODE and update current directory."
(ztree-change-start-node node)
(setq default-directory node))
(defun ztree-dir-narrow-to-dir ()
"Interactive command to narrow the current directory buffer.
The buffer is narrowed to the directory under the cursor.
......@@ -163,9 +171,9 @@ If the cursor is on a file, the buffer is narrowed to the parent directory."
(node (ztree-find-node-in-line line))
(parent (ztree-get-parent-for-line line)))
(if (file-directory-p node)
(ztree-change-start-node node)
(ztree-dir-change-directory node)
(when parent
(ztree-change-start-node (ztree-find-node-in-line parent))))))
(ztree-dir-change-directory (ztree-find-node-in-line parent))))))
(defun ztree-dir-widen-to-parent ()
......@@ -177,8 +185,56 @@ up of the opened."
(let* ((node ztree-start-node)
(parent (file-name-directory (directory-file-name node))))
(when parent
(ztree-change-start-node parent))))
(ztree-dir-change-directory parent))))
(defun ztree-dir-open-dired-at-point ()
"If the point is on a directory, open DIRED with this directory.
Otherwise open DIRED with the parent directory"
(interactive)
(let* ((line (line-number-at-pos))
(node (ztree-find-node-in-line line))
(parent (ztree-get-parent-for-line line)))
(cond ((and node (file-directory-p node))
(dired node))
(parent
(dired (ztree-find-node-in-line parent))))))
;;
;; Implementation of the ztree-protocol
;;
(cl-defmethod ztree-node-visible-p ((file string))
"Return T if the NODE shall be visible."
(ztree-file-not-hidden file))
(cl-defmethod ztree-node-short-name ((file string))
"Return the short name for a node."
(ztree-file-short-name file))
(cl-defmethod ztree-node-expandable-p ((file string))
"Return T if the node is expandable."
(file-directory-p file))
(cl-defmethod ztree-node-equal ((file1 string) (file2 string))
"Equality function for NODE1 and NODE2.
Return T if nodes are equal"
(string-equal file1 file2))
(cl-defmethod ztree-node-children ((file string))
"Return a list of NODE children"
(ztree-dir-directory-files file))
(cl-defmethod ztree-node-action ((file string) hard)
"Perform an action when the Return is pressed on a NODE."
(ztree-find-file file hard))
;; for ztree-node-side, ztree-node-face, ztree-node-left-short-name
;; and ztree-node-right-short-name use default implementations
;;
;; Entry point
;;
;;;###autoload
(defun ztree-dir (path)
......@@ -187,16 +243,10 @@ up of the opened."
(when (and (file-exists-p path) (file-directory-p path))
(let ((buf-name (concat "*Directory " path " tree*")))
(ztree-view buf-name
#'ztree-insert-buffer-header
(expand-file-name (substitute-in-file-name path))
#'ztree-file-not-hidden
#'ztree-insert-buffer-header
#'ztree-file-short-name
#'file-directory-p
#'string-equal
#'ztree-dir-directory-files
nil ; face
#'ztree-find-file) ; action
(ztreedir-mode))))
#'ztreedir-mode
nil))))
......
;; Generated package description from ztree.el
(define-package "ztree" "1.0.5" "Text mode directory tree" '((cl-lib "0")) :url "https://github.com/fourier/ztree" :keywords '("files" "tools"))
;; Generated package description from ztree.el -*- no-byte-compile: t -*-
(define-package "ztree" "1.0.6" "Text mode directory tree" '((cl-lib "0")) :keywords '("files" "tools") :authors '(("Alexey Veretennikov" . "alexey.veretennikov@gmail.com")) :maintainer '("Alexey Veretennikov" . "alexey.veretennikov@gmail.com") :url "https://github.com/fourier/ztree")
;;; ztree-protocol.el --- generic protocol for ztree-view -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Free Software Foundation, Inc.
;;
;; Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
;;
;; Created: 2021-02-12
;;
;; Keywords: files tools
;; URL: https://github.com/fourier/ztree
;; Compatibility: GNU Emacs 24.x
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;; Generic protocol for ztree-view
;;; Code:
(eval-when-compile (require 'cl-lib))
;;; Node protocol
;;; Obligatory to implement
(cl-defgeneric ztree-node-visible-p (node)
"Return T if the NODE shall be visible.")
(cl-defgeneric ztree-node-short-name (node)
"Return the short name for a node.")
(cl-defgeneric ztree-node-expandable-p (node)
"Return T if the node is expandable.")
(cl-defgeneric ztree-node-equal (node1 node2)
"Equality function for NODE1 and NODE2.
Return T if nodes are equal")
(cl-defgeneric ztree-node-children (node)
"Return a list of NODE children")
;;; Optional to implement
(cl-defgeneric ztree-node-side (node)
"Determine the side of the NODE.")
(cl-defgeneric ztree-node-face (node)
"Return a face to write a NODE in")
(cl-defgeneric ztree-node-action (node)
"Perform an action when the Return is pressed on a NODE.")
(cl-defgeneric ztree-node-left-short-name (node)
"Return the left short name for a node in 2-sided tree.")
(cl-defgeneric ztree-node-right-short-name (node)
"Return the right short name for a node in 2-sided tree.")
;;; Default implentations of optional methods
(cl-defmethod ztree-node-side ((node t))
(ignore node)
:left)
(cl-defmethod ztree-node-face ((node t))
"Return a face to write a NODE in"
(ignore node))
(cl-defmethod ztree-node-action ((node t) hard)
"Perform an action when the Return is pressed on a NODE.
Argument HARD specifies if the Return was pressed (t) or
Space (nil)"
(ignore node)
(ignore hard))
(cl-defmethod ztree-node-left-short-name ((node t))
"Return the left short name for a node in 2-sided tree."
(ztree-node-short-name node))
(cl-defmethod ztree-node-right-short-name ((node t))
"Return the right short name for a node in 2-sided tree."
(ztree-node-short-name node))
(provide 'ztree-protocol)
;;; ztree-protocol.el ends here
;;; ztree-util.el --- Auxiliary utilities for the ztree package -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
;;
;; Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
;;
......@@ -28,6 +28,26 @@
;;; Commentary:
;;; Code:
(defmacro def-ztree-local-fun (name doc)
"Create a buffer-local variable NAME-FUN and a function NAME.
Both variables and a function will have a documentation DOC.
Function will FUNCALL the variable NAME-FUN.
Used to create callbacks.
Example:
(macroexpand-1 '(def-ztree-local-fun add \"Addition\"))
(progn
(defvar-local add-fun nil \"Addition\")
(defun add (&rest args) \"Addition\" (apply add-fun args)))"
(let ((var (intern (concat (symbol-name name) "-fun"))))
`(progn
(defvar-local ,var nil
,doc)
(defun ,name (&rest args)
,doc
(apply ,var args)))))
(defun ztree-find (where which)
"Find element of the list WHERE matching predicate WHICH."
(catch 'found
......@@ -87,12 +107,6 @@ Used since `car-safe' returns nil for atoms"
(string-equal file1-remote file2-remote)))
(defun ztree-scroll-to-line (line)
"Recommended way to set the cursor to specified LINE."
(goto-char (point-min))
(forward-line (1- line)))
(provide 'ztree-util)
;;; ztree-util.el ends here
This diff is collapsed.
;;; ztree.el --- Text mode directory tree -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
;;
;; Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
;; Created: 2013-11-11
;; Version: 1.0.5
;; Version: 1.0.6
;; Package-Requires: ((cl-lib "0"))
;; Keywords: files tools
;; URL: https://github.com/fourier/ztree
......