Function: treemacs--delete-at-flattened-path
treemacs--delete-at-flattened-path is a byte-compiled function defined
in treemacs-rendering.el.
Signature
(treemacs--delete-at-flattened-path BTN DELETED-PATH DOM-NODE)
Documentation
Handle a delete for a flattened path BTN for given DELETED-PATH.
Remove DOM-NODE from the dom if the entire line was deleted.
Btn: Button DELETED-PATH: File Path DOM-NODE: Dom Node
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-rendering.el
(defun treemacs--delete-at-flattened-path (btn deleted-path dom-node)
"Handle a delete for a flattened path BTN for given DELETED-PATH.
Remove DOM-NODE from the dom if the entire line was deleted.
Btn: Button
DELETED-PATH: File Path
DOM-NODE: Dom Node"
(let* ((key (treemacs-button-get btn :key))
(coll-status (treemacs-button-get btn :collapsed))
(curr-collapse-steps (cdr coll-status)))
(if (string= deleted-path key)
(progn
;; remove full dom entry if entire line was deleted
(treemacs--delete-line)
(treemacs-dom-node->remove-from-dom! dom-node))
;; otherwise change the current line and update its properties
(let* ((path (treemacs-button-get btn :path))
(new-path (treemacs--parent deleted-path))
(delete-offset (- (length path) (length new-path)))
(new-label (substring new-path (length key)))
(old-coll-count (car coll-status))
(new-coll-count (length (treemacs-split-path new-label))))
(treemacs-button-put btn :path new-path)
(end-of-line)
;; delete just enough to get rid of the deleted dirs
(delete-region (- (point) delete-offset) (point))
;; then remove the deleted directories from the dom
(-let [removed-collapse-keys (last curr-collapse-steps (- old-coll-count new-coll-count))]
(treemacs-dom-node->remove-collapse-keys! dom-node removed-collapse-keys)
(-each removed-collapse-keys #'treemacs--stop-watching))
;; and update inline collpase info
(if (= 0 new-coll-count)
(treemacs-button-put btn :collapsed nil)
(treemacs-button-put
btn :collapsed
(cons new-coll-count (-take (1+ new-coll-count) curr-collapse-steps))))))))