rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.1k stars 176 forks source link

Remove autoload might break the `straight-use-package-mode` #527

Closed ccqpein closed 3 months ago

ccqpein commented 4 months ago

I found the latest rust-mode cannot load successfully by my use-package (turned on the straight.el use-package integrated).

After some investigating, I found the PR #526 remove the ;;;###autoload of rust-mode. It causes straight-use-package cannot find the rust-mode function. (I guess it doesn't load the rust-mode.el when it initing?)

After more playing around, there are several behaviors were revealed.

  1. if I (load "~/.emacs.d/straight/repos/rust-mode/rust-mode.el") in *scratch* buffer. I can call M-x rust-mode. But M-x straight-use-package cannot find the rust-mode
  2. if I (autoload 'rust-mode "rust-mode" nil t) in *scratch* buffer. It does the same thing as 1..
  3. If I load rust-mode.el in use-package :init step. It works fine. Furthermore, if I (setq rust-mode-treesitter-derive t) before in :init before loading, it will in treesitter mode as master branch code is designed to do.

I haven't raised up the solution of this issue. I guess it is the autoload is necessary for straight.el. I am going to report this to them.

ccqpein commented 4 months ago

Also raised the question to straight.el repo. link

jroimartin commented 4 months ago

Related: #528

condy0919 commented 4 months ago
;; in rust-mode.el ...

;;;###autoload
(autoload 'rust-mode "rust-mode.el" nil t)

It will generate an (autoload 'rust-mode "rust-mode.el" nil t) in rust-mode-autoloads.el, but it looks like odd as of an autoload is autoloaded.

psibi commented 3 months ago

@ccqpein Can you check if this PR by @jroimartin fixes it for you: https://github.com/rust-lang/rust-mode/pull/530 ?

ccqpein commented 3 months ago

@psibi I just try and it fixes the rust-mode. Now my rust file can load the rust-mode (from rust-prog-mode.el). However, the straight-use-package still cannot find the rust-mode by M-x straight-use-package.

I might find sometime to study how the straight.el handle straight-use-package

ccqpein commented 3 months ago

Figure out it works. Thanks for @jroimartin 's PR