> This comment confused me > > ,---- > | (defun loaddefs-generate--make-prefixes (defs file) > | ;; Remove the defs that obey the rule that file foo.el (or > | ;; foo-mode.el) uses "foo-" as prefix. Then compute a small set of > | ;; prefixes that cover all the remaining definitions. > | (let* ((tree (let ((tree radix-tree-empty)) > | (dolist (def defs) > | (setq tree (radix-tree-insert tree def t))) > | tree)) > | (prefixes nil)) > `---- > > as I could not see anything being removed here. > > Digging through history I learned this comment was lifted from older > code shown below and removed in 1d4e90341782030cc7d8c29c639450b079587908, > where it was followed by commented code that would actually have done > that. Yup, the comment applied to some earlier version of the code, sorry. > And now for something completely different... (As in "here you might > want to *add* a comment" ;P ) > > loaddefs-generate--compute-prefixes ignores definitions with an > autoload cookie: > > ,---- > | (when (save-excursion > | (goto-char (match-beginning 0)) > | (or (bobp) > | (progn > | (forward-line -1) > | (not (looking-at ";;;###autoload"))))) > | (push name prefs)))))) > `---- > > Why?! The "symbol prefix" machinery is designed so as to try and give easier access to those things that Emacs wouldn't know about with it (i.e. symbols that exist "out there" in some installed packaged but aren't yet represented in `obarray`). Autoloaded functions are presumably already represented in `obarray` even if the file hasn't yet been loaded. Admittedly, this is not 100% sure, but that's the reason why the code thinks it can ignore them. As for "why bother", well it turns out that it's not completely uncommon for a package's autoloaded functions to fall outside of the prefix shared by all other definitions, so skipping them can help improve the prefix. Examples would be `run-foo` commands where all other functions use the `foo-` prefix, or even just the common `foo` entry point where all other definitions use the `foo-` prefix. > I might overlook something, but it seems that the old implementation > in pre-1d4e90341782030cc7d8c29c639450b079587908 autoloads.el didn't > do that. I'm pretty sure it did (based on my recollection of the timing: most of the experiments and design of the functionality happened before the move to `loaddefs-gen.el`), tho I haven't bothered to look at the code. BTW, I've played with a slightly different code, tho I haven't yet finalized it. See patch below. Stefan