17 votes
Accepted

How can I improve startup time despite many packages?

One of the design choices in package.el was to try and make things "simple". Part of this is that package-initialize searches for all the packages that are installed, then tries to figure out which ...
Stefan's user avatar
  • 26.4k
7 votes

How to generate and activate autoloads for local packages?

The correct solution (IMO) is to use a package manager which has explicit support for this use case. This would be straight.el, which I wrote for this purpose. You can read verbose documentation, ...
Resigned June 2023's user avatar
6 votes

How can I improve startup time despite many packages?

The problem you describe about package-initialize taking so much time to load is a well known problem. It is also one of the problems that some emacs frameworks try to solve by loading the autoloads ...
UndeadKernel's user avatar
5 votes
Accepted

loading tramp overrides tramp-remote-path customization back to default value

Short answer: Don't edit custom-set-variables form by hand. Tramp must be loaded for custom-set-variables to work. Either load tramp before custom-set-variables: (require 'tramp) (custom-set-...
Clément's user avatar
  • 3,995
5 votes
Accepted

Autoloading defcustoms: good practice or not?

This has been discussed more than once on [email protected]. Here is one such thread, from 2016. And here is something from Stefan, who dislikes such autoloading, from 2014. Likewise, Glenn, in ...
Drew's user avatar
  • 77.5k
4 votes
Accepted

How to lazy load init files to speedup Emacs startup?

Consider using John Wiegley's use-package if you really care about startup time that much. use-package provides built-in support for lazy/deferred loading. Better yet, don't constantly restart your ...
Tianxiang Xiong's user avatar
4 votes
Accepted

How to autoload a package without requiring in the init file?

You discovered most of the answer yourself. When you install clojure-mode, you also get a file clojure-mode-autoloads.el. That file besides adding the entries you mentioned to auto-mode-alist, also ...
Omar's user avatar
  • 4,812
4 votes
Accepted

How to make defcustoms available before their file has been loaded?

You can just add an autoload cookie before the defcustom: ;;;###autoload (defcustom diredp-dwim-any-frame-flag pop-up-frames "Non-nil means the target directory can be in a window in another ...
Drew's user avatar
  • 77.5k
3 votes

How should I test that autoloads work properly with package.el?

What can I use as the :init form to load the autoloads as package.el would? (with-demoted-errors "Error loading autoloads: %s" (load "~/path/to/PACKAGE/PACKAGE-autoloads" nil t)) Refer to the ...
Basil's user avatar
  • 12.4k
3 votes

Adding advice to an autoloaded function

Don't make the advice conditional, but only its effect: (defadvice something (before fix-something enable) (when enable-something-advice-p ;;; do stuff )) Tho of course I'd use advice-add ...
Stefan's user avatar
  • 26.4k
3 votes

How to generate and activate autoloads for local packages?

If you have replaced an already installed package with a different version, and all you are missing is the autoloads file, you can use package-generate-autoloads to generate it: (package-generate-...
Andreas Raster's user avatar
3 votes

loading tramp overrides tramp-remote-path customization back to default value

tramp.el must be loaded indeed when a Tramp user option shall be set. The proper way to do this is (custom-set-variables '(tramp-remote-path (quote (tramp-own-remote-path)) nil (tramp))) Maybe this ...
Michael Albinus's user avatar
3 votes

How to lazy load init files to speedup Emacs startup?

I'd recommend two things to speedup startup: Merge your many init files into a single large file. Look at the content of your init files and try to make sure that they don't require or load but ...
Stefan's user avatar
  • 26.4k
3 votes

How to know which function triggered an autoload of a library

Currently, autoloading a function is done all in C code with fairly few Lisp-visible effects (other than the loading itself). As you have discovered advising load may not catch it, for example. I ...
Stefan's user avatar
  • 26.4k
3 votes

Use-package doesn't find autoload

Maybe I am missing something, but the linked mdi.el file does not define the function mdi-insert. Its main entry-point is the autoloaded function mdi. Either way, if adding :demand t to the mdi use-...
Basil's user avatar
  • 12.4k
3 votes

cl-lib isn't loaded the first time an autoloaded function is used from it

It's an internal autoload of the cl-lib package, not a global autoload. cl- has no global autoloads. To use cl- functions, require cl-lib. To use cl- macros, eval-when-compile require cl-lib.
ocoh2's user avatar
  • 31
3 votes
Accepted

Confusing defcustom usage in info.el

Responding to your last comment, asking about the let*. Putting this into an answer so the doc-string can be clear. The let* sexp is simply evaluated when the defcustom is read (e.g. the file is ...
Drew's user avatar
  • 77.5k
3 votes
Accepted

Why is cl-loop autoloaded on byte-compilation?

byte-compile-file comes from bytecomp.el which (require 'cl-lib), thus cl-lib is always already loaded before any byte compilation. The info manual does also not contain any information about ...
xuchunyang's user avatar
  • 14.5k
3 votes

Why is cl-loop autoloaded on byte-compilation?

This is a bug (will be fixed in 27.1); https://debbugs.gnu.org/30635
throwaway_xa3I's user avatar
3 votes

How does Emacs see the generated autoloads files?

I am not sure how Emacs usually does this, but you should simply require the autoloads before calling (foo-hello), using (require 'foo-autoloads). Now instead of loading the full foo 'package' ...
dalanicolai's user avatar
  • 7,815
3 votes
Accepted

How does Emacs see the generated autoloads files?

There is no magic with files of autoload declarations -- just like any other *.el file, Emacs knows nothing about the contents of an *-autoloads.el file unless that file is loaded; so in order to make ...
phils's user avatar
  • 51.2k
3 votes
Accepted

Make the linter aware of autoloads for init files using package-quickstart

Original answer There is no need to handle package-quickstart specifically. What you want instead is for Flymake to inherit your running Emacs’ load path. Out of the box, Flymake uses the default ...
d125q's user avatar
  • 1,443
2 votes

loading tramp overrides tramp-remote-path customization back to default value

Fascinating. I can exactly reproduce what you're running in to if I try to use the customization interface. However! I can successfully change the value of tramp-remote-path by skipping the ...
Gastove's user avatar
  • 1,551
2 votes

How to generate and activate autoloads for local packages?

I do the following on Linux: I setup a local melpa repository by cloning melpa. I modify the recipes I want to point to my local packages. The following is local-melpa/recipies/ace-window (ace-...
eflanigan00's user avatar
2 votes

Is it possible to lazy-load language mode packages?

You can use autoload rather than require example with yaml-mode (autoload 'yaml-mode "yaml-mode" nil t) (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
djangoliv's user avatar
  • 3,199
2 votes
Accepted

How to autoload a non-elpa package such as help-fns+.el?

There are some alternatives. Do any of them after putting the library in a directory that's in your load-path. Unconditionally load the library. (require 'help-fns+) Autoload the library for ...
Drew's user avatar
  • 77.5k
2 votes

For convenience, how should I load a package whenever a specific other package loads?

Use autoload for specific commands etc. Use require if your library depends on another. That's the main question to ask yourself: does your library need the other library? If so, require it. You can ...
Drew's user avatar
  • 77.5k
2 votes

Who or what decides what gets put into `loaddefs.el`?

loaddefs.el is automatically generated at build time. See src/Makefile.in line 774 (in whatever version I happened to have checked out; it might be a different line in yours).
db48x's user avatar
  • 18.1k
2 votes
Accepted

How to programatically detect if a unbound symbol is part of an autoloaded file and what file that is?

You can use symbol-function to get the function associated with a symbol. If the function hasn’t been loaded yet, then this will be a list starting with the symbol autoload rather than an actual ...
db48x's user avatar
  • 18.1k
1 vote
Accepted

Adding advice to an autoloaded function

The solution to the problem was to put a conditional form around the function: (when (fboundp 'my-function-generating-compilation-errors) ....)
Realraptor's user avatar
  • 1,293

Only top scored, non community-wiki answers of a minimum length are eligible