[use-package] 如何使用自己写的包,这个包该怎么写

看其他人写得use-package配置都是关于一些minor-mode
我不知道能不能加载其他一些.el文件
作死尝试了一下

(require 'math)
(use-package math-mode
  :mode "\\.math\\'"
  ;; :load-path "~/.emacs.d/packages/math.el"
  :init (message "hello world"))

我已经配置过load-path了,这是我的math.el

(setq math/highlights
      '(("Sin\\|Cos\\|Sum" . font-lock-function-name-face)
	("Pi\\|Infinity" . font-lock-constant-face)))
(define-derived-mode math-mode fundamental-mode "math"
  "major mode for editing math code."
  (setq font-lock-defaults '(math/highlights)))
(provide 'math)

打开一个.math文件,发现
File mode specification error: (error Autoloading file /home/steiner/.emacs.d/packages/math.el failed to define function math)
这是怎么回事?我的写法哪里有误吗?我该怎么写 :face_with_raised_eyebrow:

use-package 文件名,不要用模式名

好像没用啊

可以啊

(setq math/highlights
      '(("Sin\\|Cos\\|Sum" . font-lock-function-name-face)
		("Pi\\|Infinity" . font-lock-constant-face)))

;;;###autoload
(define-derived-mode math-mode fundamental-mode "math"
  "major mode for editing math code."
  (setq font-lock-defaults '(math/highlights)))
(use-package math
  :mode ("\\.math\\'" . math-mode)
  :load-path
  "~/Downloads"
  :init (message "hello world"))

我这边测试没问题

看来最重要的这一行我没写对,重开Emacs见效了
:mode ("\\.math\\'" . math-mode) 另外怎么清空这个设置啊,每次调试都好麻烦

auto-mode-alist 把你设置的remove掉,我只知道这一种方法