emacs-lsp / dap-mode

Emacs :heart: Debug Adapter Protocol
https://emacs-lsp.github.io/dap-mode
GNU General Public License v3.0
1.29k stars 181 forks source link

Eager macro-expansion failure: (wrong-number-of-arguments (1 . 1) 0) when (require 'dap-ui) #120 #673

Open zw963 opened 1 year ago

zw963 commented 1 year ago

This is not a error, just a warning when start emacs daemon.

Thanks

yyoncho commented 1 year ago

Please test with M-x lsp-start-plain

jcs090218 commented 1 year ago

Looks similar to https://github.com/emacs-lsp/lsp-metals/issues/81. I think the issue is from the upstream treemacs.

I have reported the issue in https://github.com/Alexander-Miller/treemacs/issues/982.

zw963 commented 1 year ago

I can reproduce use following minimum:

(require 'dap-mouse)
(require 'dapui)

Both of them required to output this error, although, treemacs really in the load path, it many be load automatically.

zw963 commented 1 year ago

I can't reproduce it if (require 'treemacs) and (require 'lsp-treemacs).

jcs090218 commented 1 year ago

Do you have lsp-mentals installed? I think it get triggered only when you activated/executed.

zw963 commented 1 year ago

Do you have lsp-mentals installed? I think it get triggered only when you activated/executed.

No, i use newest master of lsp-mode and dap-mode, none of them exists lsp-mentals.

jcs090218 commented 1 year ago

I can't reproduce it if (require 'treemacs) and (require 'lsp-treemacs).

I don't think requiring it will cause the Eager macro-expansion failure error.

No, i use newest master of lsp-mode and dap-mode, none of them exists lsp-mentals.

The error should come from this line

https://github.com/emacs-lsp/dap-mode/blob/2cb49bb2ec22a7d6d4fd403bd4e2cc468f512501/dapui.el#L150

It's the same bug I have posted in the previous https://github.com/emacs-lsp/dap-mode/issues/673#issuecomment-1270377793.

bertulli commented 1 year ago

Please, forgive me if I missed something, but shouldn't the code of dapui-loaded-sources the one being fixed? For what I see, treemacs changed the interface to the treemacs-initialize function: can't dap-mode's code be modified to reflect this?

yyoncho commented 1 year ago

@bertulli yes, it should. I will comment it out for now.

bertulli commented 1 year ago

Thanks! Just a minor suggestion: it appears treemacs-initialize should be called with as argument the same :key given to treemacs-define-variadic-entry-node-type. Running a very noob-ish find-grep-dired in my ~/.emacs.d/ shows that treemacs-define-variadic-entry-node-type is only called in lsp-treemacs/lsp-treemacs-generic.el (tho maybe I have not installed every lsp-mode related package). So, a possible fix is to keep a variable with the list of :keys passed to that, and to invoke treemacs-initialize with that. For instance, something like

;; lsp-treemacs/lsp-treemacs-generic.el
(defvar treemacs-feature-list '()
  "List of `':key's given to `'treemacs-define-variadic-entry-node-type'.")

(treemacs-define-variadic-entry-node-type lsp-treemacs-generic-root
  :key 'lsp-treemacs-generic-root
  :children lsp-treemacs-tree
  :child-type 'lsp-treemacs-generic-node)

(add-to-list 'treemacs-feature-list 'lsp-treemacs-generic-root)

;; dap-mode/dapui.el
;;;###autoload
(defun dapui-loaded-sources ()
  (interactive)
  (let* ((buffer (get-buffer-create "*DAP Loaded Sources*"))
         (window (display-buffer-in-side-window buffer nil)))
    (select-window window)
    (set-window-dedicated-p window t)
    (mapc #'treemacs-initialize treemacs-feature-list)
    (setq-local treemacs-default-visit-action 'treemacs-RET-action)
    (treemacs-DAP-LOADED-SOURCES-extension)

    (add-hook 'dap-terminated-hook 'dapui-sources-refresh)
    (add-hook 'dap-session-changed-hook 'dapui-sources-refresh)
    (add-hook 'dap-loaded-sources-changed-hook 'dapui-sources-refresh)
    (add-hook 'kill-buffer-hook 'dapui--cleanup-sources-hook nil t)))

I am little more than a beginner, so please tak this salt-grained, but it seems to work on my machine (maybe?). Please also note that treemacs-DAP-LOADED-SOURCES-extension too seems not to be defined. Is it an error on my side?

yyoncho commented 1 year ago

I just commented the source of dapui.el. @bertulli it is not that simple, we should rework the extension code to use lsp-treemacs-generic it is structured in different way.

bertulli commented 1 year ago

Got it, thank you! 🙏