> Thanks. I installed the change on the emacs-29 branch, and I'm
> closing this bug.
I compiled a new Emacs based on emacs-29 branch, it works fine, thanks
for your patience. Hope it will be merged to master soon
😊
> It cannot be deleted as long as the Emacs session which uses it is up
> and running. Windows doesn't let us delete a DLL that is being used,
> that's why the patch renames it instead.
I get it, thanks for the explanation.
> This was considered, but we decided not to do that, for several good
> reasons. One reason is that Emacs itself changes the value, which is
> not appropriate with defcustoms.
Oh, it seems that I think too little.
---
> From: 牟 桐 <mou.tong@outlook.com>
> CC: "61289@debbugs.gnu.org" <61289@debbugs.gnu.org>
> Date: Sun, 5 Feb 2023 09:58:49 +0000
>
> Yes, after applying your patch, I believe this problem has been solved.
Thanks. I installed the change on the emacs-29 branch, and I'm
closing this bug.
> But I noticed the `libtree-sitter-xxx.dll.old` in the tree-sitter dir
> hadn't been delelted.
It cannot be deleted as long as the Emacs session which uses it is up
and running. Windows doesn't let us delete a DLL that is being used,
that's why the patch renames it instead.
The next time you install a new version of the same DLL, the .old file
will be deleted, if it still exists. Or you can delete it by hand.
> If I remove the `ignore-errors` function in your patch, which seems like
> this (sorry, I'm not a programmer and don't know how to use diff):
>
> - (copy-file lib-name (file-name-as-directory out-dir) t t)
> + (let* ((library-fname (expand-file-name lib-name out-dir))
> + (old-fname (concat library-fname ".old")))
> + ;; Rename the existing shared library, if any, then
> + ;; install the new one, and try deleting the old one.
> + ;; This is for Windows systems, where we cannot simply
> + ;; overwrite a DLL that is being used.
> + (if (file-exists-p library-fname)
> + (rename-file library-fname old-fname t))
> + (copy-file lib-name (file-name-as-directory out-dir) t t)
> + ;; Ignore errors, in case the old version is still used.
> + (delete-file old-fname))
>
> ^
> I deleted the outside `ignore-errors` to know why the `xxx.old` hadn’t been deleted.
>
> After applying the change, I got the same error as I mentioned before:
>
> ```
> ⛔ Warning (treesit): Error encountered when installing language grammar: (permission-denied Removing old name
Permission denied c:/Users/redacted/.emacs.d/tree-sitter/libtree-sitter-c.dll.old)
> ```
Of course: that's why the patch uses ignore-errors in the first
place. The DLL cannot be deleted as long as it is used.
> Btw, can we make the variable ` treesit-language-source-alist`
> customizable? (Use `defcustom` instead of `defvar`.) I'm using
> `use-package` to manage my config. When I'm configuring treesit, I'd
> like to use `:custom` instead of `:init` or `:config` since it can let
> me set variable's value without writing `setq`.
This was considered, but we decided not to do that, for several good
reasons. One reason is that Emacs itself changes the value, which is
not appropriate with defcustoms.