Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarifying questions #153

Open
joyguar opened this issue Jan 17, 2023 · 0 comments
Open

Clarifying questions #153

joyguar opened this issue Jan 17, 2023 · 0 comments
Labels

Comments

@joyguar
Copy link

joyguar commented Jan 17, 2023

I've been referencing this repo during the construction of my own config. Thank you for the code, it's very helpful!

I have a couple clarifying questions I hope you could answer so I understand the thought process behind a couple design choices.

First is this macro:

(defmacro my/require-config-module (feature)
  `(if (fboundp 'my/require-config-module-maybe-byte-compile)
       (my/require-config-module-maybe-byte-compile ,feature)
     (require ,feature)))

It's not immediately obvious to me why this is a macro and not just an average function. Couldn't this be rewritten like so:

(defun my/require-config-module (feature)
  (if (fboundp 'my/require-config-module-maybe-byte-compile)
       (my/require-config-module-maybe-byte-compile feature)
     (require feature)))

and achieve the same thing? Also, what is the utility of this function to begin with? You define my/require-config-module-maybe-byte-compile in init.el within your if... block and I don't see a context when it would be called where my/require-config-module-maybe-byte-compile isn't bound. It seems like you could have just used my/require-config-module-maybe-byte-compile directly.

Now, a question about

(defun my/require-config-module-maybe-byte-compile (feature)
  (let* ((gc-cons-threshold 800000)
         (modules-dir (locate-user-emacs-file "modules/"))
         (basename (symbol-name feature))
         (source (expand-file-name (concat basename ".el") modules-dir))
         (dest (expand-file-name (concat basename ".elc") modules-dir)))
    (when (or (not (file-exists-p dest))
              (file-newer-than-file-p source dest))
      (message "Byte-compiling %s..." basename)
      (if (if (and nil (require 'async nil t))
              (async-get
               (async-start
                `(lambda ()
                   (add-to-list 'load-path
                                (locate-user-emacs-file "modules/"))
                   (setq load-prefer-newer t)
                   (require 'config-core)
                   (require 'config-package)
                   (byte-compile-file ,source))))
            (require feature)
            (byte-compile-file source))
          (message "Byte-compiling %s...done" basename)
        (message "Byte-compiling %s...failed" basename))))
  (require feature))

Why do you (require feature) the feature before (byte-compile-file source)? Supposing that the feature was successfully byte compiled, you later require the feature at the end again, which seems like an extra use of require. Why not just byte-compile the file, omitting the require statement prior, and then depend on the (require feature) statement at the end?

Thanks again, I hope it's not too much trouble. I am just trying to understand why you've done things certain ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants