diff --git a/init.el b/init.el index a827b6f..e23193f 100644 --- a/init.el +++ b/init.el @@ -541,6 +541,10 @@ upgraded." ;; installed.) (require 'dash) +;; Fix for https://github.com/volrath/treepy.el/issues/9, necessary +;; for treepy-remove to work right. +(my:load-recipes 'treepy-remove-fix) + ;; Don't take up mode line space if encoding is unspecified or Unicode-ish. (unless (my:treepy-edit-mode-line-var diff --git a/recipes/treepy-remove-fix.el b/recipes/treepy-remove-fix.el new file mode 100644 index 0000000..cd64687 --- /dev/null +++ b/recipes/treepy-remove-fix.el @@ -0,0 +1,33 @@ +;; -*- lexical-binding: t; -*- + +;; Fix for https://github.com/volrath/treepy.el/issues/9. + +(require 'el-patch) + +(el-patch-feature treepy) + +(with-eval-after-load 'treepy + (el-patch-defun treepy-remove (loc) + "Remove the node at LOC. +Return the loc that would have preceded it in a depth-first +walk." + (treepy--with-loc loc (context pnodes ppath l r) + (if (not context) + (error "Remove at top") + (if (> (length l) 0) + (let ((nloc (treepy--with-meta (cons (car l) + (treepy--context-assoc context + ':l (cdr l) + ':changed? t)) + (treepy--meta loc))) + (el-patch-remove (child nil))) + (el-patch-remove + (while (setq child (and (treepy-branch-p nloc) (treepy-children nloc))) + (setq nloc (treepy-rightmost child)))) + nloc) + (treepy--with-meta + (cons (treepy-make-node loc (car pnodes) r) + (and ppath (treepy--context-assoc context ':changed? t))) + (treepy--meta loc)))))) + + (el-patch-validate 'treepy-remove 'defun t))