0

I've copied a file to a path that's definitely listed in load-path symbol. But the file doesn't get loaded when running emacs with --debug-init flag.

How would you find out what causes it? It uses straight.el library via Doom emacs macro:

(package! htmlz-mode
  :recipe (:host github :repo "0xekez/htmlz-mode"))
Drew
  • 75,699
  • 9
  • 109
  • 225
  • I know nothing about Doom, but let me ask: does `package!` load the package or just install it? If it just installs it, does `(use-package! htmlz-mode)` load it? This is from a very cursory reading of [Installing packages](https://github.com/doomemacs/doomemacs/blob/master/docs/getting_started.org#installing-packages), so it may well be wrong - but it's something to try. – NickD May 23 '23 at 23:59
  • I believe that ```package!``` (and ```doom sync``` command) only install the packages and then they should get loaded either when their functions get invoked (if they are autoloaded) or ```require``` function is called... hmm now that you asked I think that the reason why I can't see the function loaded is because the author haven't neither add require nor autoload statements... the thing that really confuses me though is why there couldn't have been a simpler way to handle this. – Daniel Krajnik May 24 '23 at 00:22
  • I have tried adding ```(use-package! htmlz-mode)``` after ```(package! ...)```, but ```doom sync``` errored; ```There was an unexpected runtime error Message: Symbol's function definition is void Details: (use-package!)``` – Daniel Krajnik May 24 '23 at 00:23
  • It was a (very) long shot :-) – NickD May 24 '23 at 01:15

2 Answers2

0

C-u v load-history tells you exactly what gets loaded when. And you can often see/guess why (what happens) from that.

But in general, bisect your init file to find the culprit.

Or start with emacs -Q and try to load just that library manually: M-x load-library, or even M-x load-file. (If it has dependencies then load those first, of course.)

It sounds like you throwing a giant sack of stuff up in the air, and then trying to see which tiny bit of it is painted red. You have Doom, Straight, and who knows what else in the game. Start by getting rid of them -- narrow the search space.

Drew
  • 75,699
  • 9
  • 109
  • 225
  • 1
    thank you very much, you are right, there are multiple layers contributing to confusion and only after a few days of breaking them down I realized it's been a misconfigured package at fault (htmlz-mode). Thank you for mentioning emacs -Q option, if I knew it sooner that might have simplified the process a lot! – Daniel Krajnik May 23 '23 at 23:18
  • I've just checked 'load-history' variable, but unfortunately the package I'm trying to load simply wasn't there :( It's quite frustrating, given that you could just (load-file ./htmlz-mode.el) it's a single file that otherwise works perfectly. Wish there was a simpler way to share elisp code... – Daniel Krajnik May 23 '23 at 23:26
0

There are several problems with your installation:

  • It is not clear what you configured at the beginning, e.g, if you added or not the module web in your init.el file. That would be useful (and I would say mandatory for html design, see below).

  • The biggest problem is the package htmlz-mode, since it force to use the package.el, which is forbidden in doom-emacs. In that package there are two functions, (defun require-package()) and (defun html-init-dependencies) which asks for package.el, with unknown behavior in doom-emacs environment. (you may use doom-doctor to see if something is revealed). The purpose of those functions are to install the package websocket if it is not already installed and to init that package and the built-in browse-url package. What can you do in this case is (not tested, be patient):

    a) clone separately the htmlz-mode package in separate location, say e.g. ~/.doom.d/htmlz folder; Edit the file htmlz-mode.el and comment out the lines 21-35 and 97. (remove first what you already installed). Add web module in your init.el file.

    b) remove the posted code (package! htmlz-mode....) from your file (btw. where it is now? should be in the file package.el in ~/.doom.d)

    c) add the following code in file package.el:

    (package! websocket
       :recipe (:host github :repo "find it yourself please"))
    

    d) add in your config.el file the following:

    (after! web
       (use-package htmlz-mode
           :load path ".doom.d/htmlz"
           :init
           (require 'browse-url)
           (require 'websocket)))
    

    e) Close emacs and run the cli command doom sync.

If this will not work, there are alternatives: use vscode+LiveServerExtension. I have seen your posting in htmlz's github site, emacs takes long time to deal with.

Ian
  • 1,321
  • 10
  • 12
  • Thanks for looking into this with so much depth. You are right that htmlz-mode package wasn't configured correctly. Adding the ;;;autoloads header made it "register" (I'm not sure that's the right term) eventually and load. There were other issues as you mentioned related to the way it handled dependencies, but to make it work (given one already had the "web" module enabled) that one autoloads header did the trick. It took a long time and I wished emacs gave you some more warnings. Once set up it works really well though and seems on par with vscode+LiveServer for my needs so far. – Daniel Krajnik May 25 '23 at 16:49