[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ztree c5a1190 15/23: Issue #61: Error on unaccessible d
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ztree c5a1190 15/23: Issue #61: Error on unaccessible directory contents |
Date: |
Thu, 17 Dec 2020 23:17:05 -0500 (EST) |
branch: externals/ztree
commit c5a119038fe3023f27bac47104c0baec954e5b8e
Author: Alexey Veretennikov <alexey.veretennikov@gmail.com>
Commit: Alexey Veretennikov <alexey.veretennikov@gmail.com>
Issue #61: Error on unaccessible directory contents
When ztree-show-number-of-children is on, ztree-dir calculates
the amount of children in each subdirectory of the current
directory to present the number of elements in square braces
[].
If the directory is inaccessible due to lack of rights it lead
to error.
Now the error is ignored and "N/A" text shown instead of number
of elements in a directory.
---
ztree-view.el | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/ztree-view.el b/ztree-view.el
index 26493ee..c24ab24 100644
--- a/ztree-view.el
+++ b/ztree-view.el
@@ -567,25 +567,29 @@ Argument PATH start node."
;; with the offset of the text and relevant side information
(line-properties (gethash line ztree-line-tree-properties))
(expandable (funcall ztree-node-is-expandable-fun node))
- (short-name (funcall ztree-node-short-name-fun node)))
+ (short-name (funcall ztree-node-short-name-fun node))
+ (count-children-left
+ (when (and expandable ztree-show-number-of-children)
+ (ignore-errors
+ (length (cl-remove-if (lambda (n)
+ (and ztree-node-side-fun
+ (eql
+ (funcall ztree-node-side-fun n)
+ 'right)))
+ (funcall ztree-node-contents-fun node))))))
+ (count-children-right
+ (when (and expandable ztree-show-number-of-children)
+ (ignore-errors
+ (length (cl-remove-if (lambda (n)
+ (and ztree-node-side-fun
+ (eql
+ (funcall ztree-node-side-fun n)
+ 'left)))
+ (funcall ztree-node-contents-fun
node)))))))
(if ztree-node-side-fun ; 2-sided tree
(let ((right-short-name (funcall ztree-node-short-name-fun node t))
(side (funcall ztree-node-side-fun node))
- (width (window-width))
- (count-children-left
- (when ztree-show-number-of-children
- (length (cl-remove-if (lambda (n)
- (eql
- (funcall ztree-node-side-fun n)
- 'right))
- (funcall ztree-node-contents-fun
node)))))
- (count-children-right
- (when ztree-show-number-of-children
- (length (cl-remove-if (lambda (n)
- (eql
- (funcall ztree-node-side-fun n)
- 'left))
- (funcall ztree-node-contents-fun node))))))
+ (width (window-width)))
(when (eq side 'left) (setq right-short-name ""))
(when (eq side 'right) (setq short-name ""))
(setq line-properties
@@ -608,8 +612,7 @@ Argument PATH start node."
(ztree-insert-single-entry short-name
depth
expandable
expanded
0 (when
expandable
- (length
-
(funcall ztree-node-contents-fun node)))))))
+
count-children-left)))))
(puthash line node ztree-line-to-node-table)
;; save the properties for the line - side and text offset
(puthash line line-properties ztree-line-tree-properties)
@@ -626,6 +629,8 @@ Writes a string with given DEPTH, prefixed with [ ] if
EXPANDABLE
and [-] or [+] depending on if it is EXPANDED from the specified OFFSET.
If `ztree-show-number-of-children' is set to t the COUNT-CHILDREN
argument is used to present number of entries in the expandable item.
+COUNT-CHILDREN might be null if the contents of expandable node are
+not accessible.
Optional argument FACE face to write text with.
Returns the position where the text starts."
(let ((result 0)
@@ -659,7 +664,8 @@ Returns the position where the text starts."
(insert (propertize short-name 'font-lock-face entry-face))
;; optionally add number of children in braces
(when (and ztree-show-number-of-children expandable)
- (let ((count-str (format " [%d]" count-children)))
+ (let ((count-str (format " [%s]"
+ (if count-children (number-to-string
count-children) "N/A"))))
(insert (propertize count-str 'font-lock-face
ztreep-node-count-children-face)))))
result))
- [elpa] externals/ztree 0e0a39d 09/23: Issue #56: Preserve line/column position on refresh, (continued)
- [elpa] externals/ztree 0e0a39d 09/23: Issue #56: Preserve line/column position on refresh, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 67a1d90 11/23: Issue #56: Dont preserve a cursor position on widen/narrow operations, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 369fd05 10/23: Issue #50: Show file permission differences, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 00d3318 12/23: Issue #59: Position curson on the beginning of the text, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 3273e1f 13/23: Issue #60: ztree-dir change Emacs default directory, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree a3e0442 14/23: Issue #59: Place cursor at the beginning of the text, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 2f62ba7 18/23: Issue #62: Cleared warnings, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 4879576 19/23: Issue #39: restore cursor position and window configuration, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree c54425a 21/23: Updated README for issue #65., Stefan Monnier, 2020/12/17
- [elpa] externals/ztree d078daf 08/23: Issue #54: Added (optional) number of directory entries, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree c5a1190 15/23: Issue #61: Error on unaccessible directory contents,
Stefan Monnier <=
- [elpa] externals/ztree 0a5b25f 23/23: Merge pull request #68 from webzak/fix_ws_ignore, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 1ebb00c 07/23: Issue #52: Added 'd' hotkey for the ztree-dir to open dired., Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 30dbda7 16/23: Issue #62, #63, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 50412fa 20/23: Issue #65: added ztree-diff-additional-options variable, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 901c3e3 22/23: support -w for different file size, Stefan Monnier, 2020/12/17
- [elpa] externals/ztree 17f8f32 17/23: Update to issue #62, Stefan Monnier, 2020/12/17