2

I started getting an error on loading theme files and tracked it down to the (load) function being called by (load-theme). I tried to isolate the problem with the following test function and am still puzzled:

(defun test-load ()
  (let ((file "/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-theme.el"))
    (file-exists-p file)
    (file-exists-p (concat (file-name-sans-extension file) ".elc"))
    (file-accessible-directory-p (file-name-directory file))
    (or (load file) (load (file-name-sans-extension file) nil t nil t))))

All of the predicate tests return t, but when I get to the load function, I get an error that says:

error: "Eager macro-expansion failure: (file-missing "Cannot open load file" "No such file or directory" "ef-themes")"

Notice that it claims that the directory containing the file does not exist, even though the file-accessible-directory-p predicate returns t.

I ran this with emacs -Q, then evaluated (test-load) with M-: so there is apparently nothing in my init file causing it.

Here is the debug trace:

Debugger entered--Lisp error: (error "Eager macro-expansion failure: (file-missing \"Cann...")
  signal(error ("Eager macro-expansion failure: (file-missing \"Cann..."))
  error("Eager macro-expansion failure: %S" (file-missing "Cannot open load file" "No such file or directory" "ef-themes"))
  internal-macroexpand-for-load((eval-and-compile (require 'ef-themes) (deftheme ef-bio "Legible dark theme with green, teal, blue, purple ...") (defconst ef-bio-palette '((bg-main "#111111") (fg-main "#cfdfd5") (bg-dim "#222522") (fg-dim "#808f80") (bg-alt "#303230") (fg-alt "#8fcfaf") (bg-active "#505250") (bg-inactive "#161916") (red "#ef6560") (red-warmer "#f47360") (red-cooler "#ff778f") (red-faint "#d56f72") (green "#3fb83f") (green-warmer "#7fc500") (green-cooler "#00c089") (green-faint "#7fc07f") (yellow "#d4aa02") (yellow-warmer "#e09a0f") (yellow-cooler "#cfc04f") (yellow-faint "#b7a07f") (blue "#37aff6") (blue-warmer "#78afff") (blue-cooler "#32cfef") (blue-faint "#6ab4cf") (magenta "#d38faf") (magenta-warmer "#e490df") (magenta-cooler "#af9fff") (magenta-faint "#caa5bf") (cyan "#6fc5ef") (cyan-warmer "#7fcfdf") (cyan-cooler "#5dc0aa") (cyan-faint "#7fb4cf") (bg-red-intense "#bd1f30") (bg-green-intense "#20a020") (bg-yellow-intense "#845020") (bg-blue-intense "#2f439f") (bg-magenta-intense "#b04fcf") (bg-cyan-intense "#027080") (bg-red-subtle "#6a002a") (bg-green-subtle "#00422a") (bg-yellow-subtle "#5a3000") (bg-blue-subtle "#242679") (bg-magenta-subtle "#50105a") (bg-cyan-subtle "#004065") (bg-added "#003b1f") (bg-added-faint "#002a10") (bg-added-refine "#03512f") (fg-added "#a0e0a0") (bg-changed "#363300") (bg-changed-faint "#2a1f00") ...) "The `ef-bio' palette.\nColor values have the form (...") (defcustom ef-bio-palette-overrides nil "Overrides for `ef-bio-palette'.\n\nMirror the elemen..." :group 'ef-themes :package-version '(ef-themes . "1.0.0") :type '(repeat (list symbol (choice symbol string))) :link '(info-link "(ef-themes) Palette overrides")) (ef-themes-theme ef-bio ef-bio-palette ef-bio-palette-overrides) (provide-theme 'ef-bio)) nil)
  eval-buffer(#<buffer  *load*> nil "/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-..." nil t)  ; Reading at buffer position 8080
  load-with-code-conversion("/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-..." "/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-..." nil nil)
  load("/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-...")
  (or (load file) (load (file-name-sans-extension file) nil t nil t))
  (let* ((file "/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-...") (file2 "/home/ded/.emacs.d/elpaca/builds/ef-themes/ef-bio-...")) (file-exists-p file) (file-exists-p (concat (file-name-sans-extension file) ".elc")) (file-accessible-directory-p (file-name-directory file)) (or (load file) (load (file-name-sans-extension file) nil t nil t)))
  test-load()
  eval((test-load) t)
  eval-expression((test-load) nil nil 127)
  funcall-interactively(eval-expression (test-load) nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

I am puzzled, anyone see something I'm missing?

Drew
  • 75,699
  • 9
  • 109
  • 225
Daniel Doherty
  • 418
  • 4
  • 12
  • "All of the predicate tests return t" -- you're completely ignoring their return values, so... are you certain of that? – phils Jul 17 '23 at 22:02
  • @phils, thanks for looking at this. Yes, they all returned true, which I verified through edebug stepping. But, I figured it out. An embarassing oversight on my part, detailed below. – Daniel Doherty Jul 17 '23 at 22:10
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Jul 17 '23 at 22:56

1 Answers1

2

OK. If anyone has a similar problem, I figured it out. The problem was not a failure to find the file that was the argument to the (load) function, the problem was that /that/ file was doing a (require) of another file in the same directory. This is part of a larger set of functions to allow me to browse and load themes installed with elpaca. What I decided to do was to add the build directory of any packages that end with the string "-themes", plural, to my load-path. That fixed the problem.

Here's a lesson for me: the act of formulating the question for stack exchange unearthed the problem. At the last minute I added the debug trace, but had not examined it closely until after I submitted the question. Had I done so, the problem would have been obvious. Here is what I did to fix it:

  (--each (f-directories elpaca-builds-directory
                (lambda (dir) (string-match-p "-themes$" (f-filename dir))))
    (add-to-list 'load-path it))

My init file includes the dash and f libraries earlier.

Daniel Doherty
  • 418
  • 4
  • 12