treefactor
treefactor copied to clipboard
user-home-directory is not defined
Executing treefactor-throw and treefactor-org-dired-zinks gives the following error message:
if: Symbol’s value as variable is void: user-home-directory
Replacing user-home-directory from the following is a viable workaround:
https://github.com/cyberthal/treefactor/blob/75357757022a4399ab772ff0d92065bd114dabe9/treefactor.el#L784-L791 with
(defun treefactor-text-inserted-to-buffer-path-message ()
"Report filename that text was inserted to.
Reported path is relative to vd-root-dir or ~/."
(message "Inserted text into `%s'" (expand-file-name buffer-file-name (vc-root-dir))))
https://github.com/cyberthal/treefactor/blob/75357757022a4399ab772ff0d92065bd114dabe9/treefactor.el#L676-L681 with
(insert (concat "*** "
(file-relative-name (file-name-directory buffer-file-name) (root-dir))
"\n\n"))
This only sidesteps the issue (which is mostly cosmetic).
(vc-root-dir) returns nil if the file / folder has not been committed in VC. Hence all empty folders will return this error.
Replacing user-home-directory with Spacemacs' default, or, if it exists, the user-defined value, would be one way to get rid of this issue.
https://github.com/syl20bnr/spacemacs/blob/787820a7add302dd0930277b88e77b5214adef2c/core/core-load-paths.el#L66-L68
Tested on vanilla Emacs (aka default settings).
I assume these issues don't affect Spacemacs, which is where I use Treefactor.
To fix these and any other bugs under GNU Emacs, I am learning proper test-driven development. Don't want to introduce new bugs and break something else.
So it will take me some time. I intend to add a Cask file, use ecukes and buttercup, and automate stuff.
Until that happens, maybe vc-root-dir can be replaced by the following:
https://github.com/abo-abo/swiper/blob/master/counsel.el#L1263-L1268
(defun counsel--dominating-file (file &optional dir)
"Look up directory hierarchy for FILE, starting in DIR.
Like `locate-dominating-file', but DIR defaults to
`default-directory' and the return value is expanded."
(and (setq dir (locate-dominating-file (or dir default-directory) file))
(expand-file-name dir)))
(defun counsel--git-root ()
"Return root of current project or nil on failure.
Use the presence of a \".git\" file to determine the root."
(counsel--dominating-file ".git"))
Traverses upwards until it finds a .git folder.