可以let-boundgenerated-autoload-load-name指定生成autoload时候的名字
(let ((generated-autoload-load-name (file-name-sans-extension (file-name-nondirectory f))))
(autoload-generate-file-autoloads f (current-buffer)))
才发现楼主已经提过了… 瞎了瞎了 
分享下自己的
(defun cm/find-subdir-recursively (dir)
"Find all subdirectories in DIR.
Dot-directories and directories contain `.nosearch' will be skipped."
(thread-last (directory-files dir nil)
(cl-remove-if (lambda (f)
(string-prefix-p "." f)))
(mapcar (lambda (d) (expand-file-name d dir)))
(cl-remove-if-not #'file-directory-p)
(cl-remove-if (lambda (d)
(file-exists-p (expand-file-name ".nosearch"
d))))))
(defun cm/find-el-file-recursively (dir)
"Find all `.el' files in DIR and its subdirectories."
(let ((elfiles (directory-files dir t "\\.el\\'"))
(subdir (cm/find-subdir-recursively dir)))
(nconc elfiles
(mapcan #'cm/find-el-file-recursively subdir))))
(defun cm/generate-autoloads (&optional dir target)
"Generate autoload files recursively for all package in DIR to file TARGET.
If DIR is omitted, use `cm/site-lisp-directory' as DIR, if target is ommitted
use `cm/autoloads-file' as TARGET."
(interactive)
(require 'autoload)
(let* ((target (or target cm/autoloads-file))
(dir (or dir cm/site-lisp-directory))
(generated-autoload-file target))
(with-temp-file target
(dolist (f (cm/find-el-file-recursively dir))
(let ((generated-autoload-load-name (file-name-sans-extension f)))
(autoload-generate-file-autoloads f (current-buffer))))
(insert (string-join `(,(char-to-string ?\C-l)
";; Local Varibles:"
";; version-control: never"
";; no-byte-compile: t"
";; no-update-autoloads: t"
";; coding: utf-8"
";; End:"
,(format ";;; %s ends here"
(file-name-nondirectory target)))
"\n")))
(load target :no-error :no-message)))
忽略点文件夹是因为没有必要,还能加快搜索速度。
忽略含有.nosearch文件的文件夹。是因为flycheck的test里面藏了一些有语法错误的elisp文件,然后人家用.nosearch文件防止被搜索。直接用directory-files-recursively的话可不会管那么多,然后你的autoload生成函数去扫描这些malformed的文件的时候就跪了。