Let's say I have Emacs Lisp library ~/emacs/my-lib.el with contents:

(defun my-func()
  (message "Hello")) 

(provide 'my-lib)

I would now like to produce a file ~/emacs/my-lib-autoload.el with autoload statements for ~/emacs/my-lib.el. The documentation for update-file-autoloads says ( "C-h f update-file-autoloads" )

(update-file-autoloads FILE &optional SAVE-AFTER OUTFILE)

Update the autoloads for FILE. If prefix arg SAVE-AFTER is non-nil, save the buffer too.

If FILE binds generated-autoload-file' as a file-local variable, autoloads are written into that file. Otherwise, the autoloads file is determined by OUTFILE. If called interactively, prompt for OUTFILE; if called from Lisp with OUTFILE nil, use the existing value ofgenerated-autoload-file'.

So from this information I figured I should be able to supply a non-nil OUTFILE argument. However, trying to run (from scratch buffer) :

(update-file-autoloads "~/emacs/my-lib.el" t "~/emacs/my-lib-autoload.el")

Gives error wrong-type-argument stringp nil

The following two approaches work though:

  1. Setting generated-autoload-file as a global variable, for example adding (setq generated-autoload-file "~/emacs/my-lib-autoload.el") to my Emacs init file (~/.emacs)

  2. Adding generated-autoload-file as a local file variable at the end of file ~/emacs/my-lib.el

For example:

;; Local Variables: 
;; generated-autoload-file: "~/emacs/my-lib-autoload.el" 
;; End:


Why does not

(update-file-autoloads "~/emacs/my-lib.el" t "~/emacs/my-lib-autoload.el")

work when the variable generated-autoload-file is nil?

2 Answers 2


I'll just show you the function that I've been using for ages in my .emacs.d:

(defun update-all-autoloads ()
  (let ((generated-autoload-file (concat emacs.d "loaddefs.el")))
    (when (not (file-exists-p generated-autoload-file))
      (with-current-buffer (find-file-noselect generated-autoload-file)
        (insert ";;") ;; create the file with non-zero size to appease autoload
    (mapc #'update-directory-autoloads
          '("" "dir1" "dir2" "dir3"))))

Since this works so good, I've never had to deal with update-file-autoloads.


I am trying to get the local variables aspect of update-file-autoloads working, but have encountered difficulties. In particular, I have the following results.

Here is my local variables declaration at the bottom of my simple lisp file that contains the autoload cookie:

;; Local Variables:
;; generated-autoload-file: "~/my-autoloads.el"
;; End:

But this fails with all of these forms executed in lisp-interaction-mode in the my-lisp-file.el file:

(update-file-autoloads "my-lisp-file.el")
(update-file-autoloads "~/my-lisp-file.el")
(update-file-autoloads <as above> t)

The forms below all work, but they don't use the Local Variables method. An absolute pathname is always required for the output my-autoloads.el file. Either a relative or absolute pathname works for the input file.

(update-file-autoloads "~/my-lisp-file.el" t "~/my-autoloads.el")
(update-file-autoloads "my-lisp-file.el" t "~/my-autoloads.el")

(let ((generated-autoload-file "~/my-autoloads.el"))
  (update-file-autoloads "~/my-lisp-file.el"))
(let ((generated-autoload-file "~/my-autoloads.el"))
  (update-file-autoloads "my-lisp-file.el"))

In summary, I could not get the local variables method to work at all, using the syntax I showed earlier, with any of the command forms shown above. Typically I would receive an error like this when trying to make use of the Local Variables method.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)

Can anyone see anything wrong with my Local Variables syntax (esp since it looks exactly like the original poster's syntax, which apparently worked for him, and which follows the Emacs doc? Thanks

PS. I'm running Emacs 24.5.1 on OSX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.