On Sat, May 28, 2016 at 12:25 AM, Clément Pit--Claudel <clement.pit@gmail.com> wrote:
Hi emacs-devel,

What is the proper way to organize the sources of a multi-file package into subdirectories, without breaking autoloads? As far as I can see `update-directory-autoloads` doesn't explore subdirectories recursively

You missed my message and solution for this 5 days back, so I have included the solution here.  Just replace this one function in package.el in the lisp/emacs-lisp/ subdirectory of your emacs installation.
No one had any comments on it surprisingly.  I have added the patch file here as well.  Let me know how it goes for you.


(defun package-generate-autoloads (name pkg-dir)
  (let* ((auto-name (format "%s-autoloads.el" name))
         ;;(ignore-name (concat name "-pkg.el"))
         (generated-autoload-file (expand-file-name auto-name pkg-dir))
         ;; Silence `autoload-generate-file-autoloads'.
         (noninteractive inhibit-message)
         (backup-inhibited t)
         (version-control 'never))
    (package-autoload-ensure-default-file generated-autoload-file)
    (apply #'update-directory-autoloads pkg-dir
  (delq nil (mapcar (lambda (f) (and (file-directory-p f)
     (not (file-symlink-p f))
     f))
    (directory-files pkg-dir t "[a-zA-Z].*" nil))))
    (let ((buf (find-buffer-visiting generated-autoload-file)))
      (when buf (kill-buffer buf)))
    auto-name))

-------
*** package-orig.el 2016-05-28 00:54:25.000000000 -0400
--- package.el 2016-05-28 00:54:25.000000000 -0400
***************
*** 916,928 ****
           (backup-inhibited t)
           (version-control 'never))
      (package-autoload-ensure-default-file generated-autoload-file)
!     (update-directory-autoloads pkg-dir)
      (let ((buf (find-buffer-visiting generated-autoload-file)))
        (when buf (kill-buffer buf)))
      auto-name))
  
  (defun package--make-autoloads-and-stuff (pkg-desc pkg-dir)
   "Generate autoloads, description file, etc.. for PKG-DESC installed at PKG-DIR."
    (package-generate-autoloads (package-desc-name pkg-desc) pkg-dir)
    (let ((desc-file (expand-file-name (package--description-file pkg-dir)
                                       pkg-dir)))
--- 911,927 ----
           (backup-inhibited t)
           (version-control 'never))
      (package-autoload-ensure-default-file generated-autoload-file)
!     (apply #'update-directory-autoloads pkg-dir
!   (delq nil (mapcar (lambda (f) (and (file-directory-p f)
!      (not (file-symlink-p f))
!      f))
!     (directory-files pkg-dir t "[a-zA-Z].*" nil))))
      (let ((buf (find-buffer-visiting generated-autoload-file)))
        (when buf (kill-buffer buf)))
      auto-name))
  
  (defun package--make-autoloads-and-stuff (pkg-desc pkg-dir)
   "Generate autoloads, description file, etc. for PKG-DESC installed at PKG-DIR."
    (package-generate-autoloads (package-desc-name pkg-desc) pkg-dir)
    (let ((desc-file (expand-file-name (package--description-file pkg-dir)
                                       pkg-dir)))
***************