[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autoloads and subdirectories

From: Clément Pit--Claudel
Subject: Re: Autoloads and subdirectories
Date: Sat, 28 May 2016 14:47:37 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

On 2016-05-28 14:18, Stefan Monnier wrote:
>> be broken by future upstream fixes. One such solution is to statically
>> generate my autoloads (using code similar to the one you posted) and ship
>> these as part of my package, while adding an autoloaded form to a new file
>> in my content directory that just loads the additional autoloads file that
>> I ship. This isn't very pretty, though.
> The other option is to split your package into several packages.

Interesting, thanks Stefan! The context in which this comes up is ‘realgud’, a 
rewrite of gud that supports about 15 debuggers out of the box. I don't think 
it would be too great to split this into 15 packages.

I think I'll push an implementation of my suggestion above. I included a draft 
below; I'd be very happy to hear comments about it :) IOW, assuming I manually 
generate autoloads using the following snippet:

    (defun realgud-refresh-subdirectory-autoloads ()
      "Update subdirectory-autoloads.el.
    This is needed because the package.el infrastructure doesn't
    process autoloads in subdirectories; instead we create an
    additional autoloads file of our own, and we load it from an
    autoloaded form."
      (let ((generated-autoload-file
             (expand-file-name realgud-subdir-autoloads-name 
        (when (file-exists-p generated-autoload-file)
          (delete-file generated-autoload-file))
        (dolist (name (directory-files-recursively realgud-content-dir "" t))
          (when (file-directory-p name)
            (update-directory-autoloads name)))))

Then would it be enough to put the following in a file that lives in the 
package's root directory?

    (defconst realgud-subdir-autoloads-name "subdirectory-autoloads.el")

    (defconst realgud-content-dir
       (or (and load-in-progress load-file-name)
           (bound-and-true-p byte-compile-current-file)

    (with-demoted-errors "Error loading autoloads: %s"
      (load (expand-file-name realgud-subdir-autoloads-name 
realgud-content-dir) t t))

(btw, is there a more concise way of writing realgud-content-directory?)


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]