Alexander-Miller / treemacs

GNU General Public License v3.0
2.05k stars 151 forks source link

Duplicate definition `treemacs-initialize` #982

Closed jcs090218 closed 10 months ago

jcs090218 commented 1 year ago

https://github.com/Alexander-Miller/treemacs/blob/861418d9d11b205930bd4555a40b430b9dde9dd4/src/elisp/treemacs-extensions.el#L540

and

https://github.com/Alexander-Miller/treemacs/blob/20765acd38e00faa46a72b9a2cf63a7b451c6850/src/elisp/treemacs-treelib.el#L1021

There is one macro and one function with the exact same name. Emacs is confused and reporting similar error,

lsp-metals-treeview.el:363:14: Error: Wrong number of arguments: (1 . 1), 0

Related issue: https://github.com/emacs-lsp/lsp-metals/issues/81

zw963 commented 1 year ago

any update?

Alexander-Miller commented 1 year ago

That is intentional. The treemacs-extensions module is obsolete and should no longer be used, its replacement is the treemacs-treelib module. It was still being loaded by treemacs itself, but that is a bug that has been fixed now.

The new api has unfortunately been different enough to require a hard break. On the other hand it's a lot easier to maintain and debug for me, and supports new features like asynchronous extensions.

If you're working with extensions I suggest looking at new new tutorial. If you have extensions that are now broken for your users you can tell them to treemacs use v2.11 which is the very last commit before the api rewrite.

Sorry about having to bother you with this whole migration, but the previous extensions api internals were all built on many, many macros which made it awful to debug problems or add new features like async support. The new system has been coming for a long time.

zw963 commented 1 year ago

Hi, i get following error after update to 984099b

Symbol's function definition is void: treemacs-define-expandable-node
zw963 commented 1 year ago

I don't know if i use any extensions, but, i guess not.

after (require 'treemacs-extensions), it works now, but i get same error message when i start emacs daemon as before.

Eager macro-expansion failure: (wrong-number-of-arguments ((cl-struct-treemacs-extension-tags t) (extension &rest --cl-rest--) "Initialise an external buffer for use with the given EXTENSION.

EXTENSION is the same symbol that was passed as a `:key' argument
to `treemacs-define-variadic-entry-node-type'.

WITH-EXPAND-DEPTH indicates the number of nodes that should be expanded *in
addition* to the default.  If a value is given that is not a number then
treemacs will assume that *all* possible nodes should be expanded.

AND-DO can be used to set up buffer-local variables after the buffer has
switched over to `treemacs-mode'.

(fn EXTENSION &key (WITH-EXPAND-DEPTH 0) AND-DO)" (let* ((with-expand-depth (car (cdr (or (plist-member --cl-rest-- ':with-expand-depth) '(nil 0))))) (and-do (car (cdr (plist-member --cl-rest-- ':and-do))))) (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car --cl-keys--) '(:with-expand-depth :and-do :allow-other-keys)) (setq --cl-keys-- (cdr (cdr --cl-keys--)))) ((car (cdr (memq ':allow-other-keys --cl-rest--))) (setq --cl-keys-- nil)) (t (error "Keyword argument %s not one of (:with-expand-depth :and-do)" (car --cl-keys--)))))) (cons 'progn (cons '(treemacs--disable-fringe-indicator) (cons '(treemacs-with-writable-buffer (erase-buffer)) (cons '(let ((treemacs-fringe-indicator-mode nil) (treemacs--in-this-buffer t)) (treemacs-mode)) (cons '(setq-local treemacs-space-between-root-nodes nil) (cons '(setq-local treemacs--in-this-buffer :extension) (cons and-do (cons (list 'treemacs--render-extension (cons 'let (cons (list (list 'instance (list 'treemacs--ext-symbol-to-instance (list 'quote extension)))) (cons (list 'treemacs-static-assert '(and instance (treemacs-extension->variadic\? instance)) "%s is not a variadic extension" extension) '(instance)))) (cons 'if (cons (list 'numberp with-expand-depth) (cons with-expand-depth '(999))))) '((goto-char 1) (treemacs--evade-image))))))))))))) 0)
Alexander-Miller commented 1 year ago

after (require 'treemacs-extensions), it works now

You shouldn't do that, that module is obsolete and will break things in newer treemacs versions if loaded.

By default no extension module should be loaded now, neither the old one, nor the new one. If you are still seeing extension related errors it's because some other package in your config - like lsp-treemacs - is loading them. You need to find that package and update it to a version that supports the new extension api. If there is no such version you need to stick with treemacs v2.11.

Eager macro-expansion failure: (wrong-number-of-arguments ((cl-struct-treemacs-extension-tags t) (extension &rest --cl-rest--) "Initialise an external buffer for use with the given EXTENSION.

This error looks like an issue with a small api change made in https://github.com/Alexander-Miller/treemacs/commit/20765acd38e00faa46a72b9a2cf63a7b451c6850, so a fix should be pretty easy.

zw963 commented 1 year ago

By default no extension module should be loaded now, neither the old one, nor the new one. If you are still seeing extension related errors it's because some other package in your config - like lsp-treemacs - is loading them. You need to find that package and update it to a version that supports the new extension api. If there is no such version you need to stick with treemacs v2.11.

Okay, i guess it caused by dap-mode, after i remove (require 'treemacs-extensions), get following error.

Symbol's function definition is void: treemacs-define-expandable-node

I disable the loading of dap-mode, all works no any error.

@jcs090218 , do you consider fix this issue for dap-mode side?

Alexander-Miller commented 1 year ago

treemacs-define-expandable-node

That is also a macro from the old module.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity.