1

In PREFIXDIR/share/emacs/28.2/site-lisp/subdirs.el (or something like d:/Progs/emacs-28.2/share/emacs/28.2/site-lisp/subdirs.el on MS-Windows):

(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
    (normal-top-level-add-subdirs-to-load-path))

However, according to Summary: Sequence of Actions at Startup:

When Emacs is started up, it performs the following operations:

  1. It adds subdirectories to load-path, by running the file named subdirs.el in each directory in the list. Normally, this file adds the directory’s subdirectories to the list, and those are scanned in their turn. The files subdirs.el are normally generated automatically when Emacs is installed.

it seems that whether normal-top-level-add-subdirs-to-load-path is defined is an established fact that doesn't require runtime detection -- whether this function is defined when Emacs loads site-lisp/subdirs.el is predictable.

Even if normal-top-level-add-subdirs-to-load-path is somehow undefined, all subdirectories in site-lisp make no sense, same as site-lisp/subdirs.el.


I wonder why we need to use a runtime test here.

1 Answer 1

1

They wrote a Bash code in Makefile.in to generate subdirs.el automatically:

write_subdir=if [ -f "$${subdir}/subdirs.el" ]; \
        then true; \
        else \
          umask 022; \
          ${MKDIR_P} "$${subdir}"; \
          (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
           echo "    (normal-top-level-add-subdirs-to-load-path))") \
            > "$${subdir}/subdirs.el"; \
        fi

for both PREFIXDIR/share/emacs/28.2/site-lisp/ and PREFIXDIR/share/emacs/site-lisp/ (and perhaps another several directories).

However, PREFIXDIR/share/emacs/site-lisp/ is shared by arbitrary versions of Emacs, including those in which normal-top-level-add-subdirs-to-load-path is not available.

So as the manual suggests:

However, sometimes it happens that a function you use for customizing Emacs is not available on some platforms or in older Emacs versions. To deal with that situation, put the customization inside a conditional that tests whether the function or facility is available, like this:

(if (fboundp 'blink-cursor-mode)
    (blink-cursor-mode 0))

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.