PythonNut / quark-emacs

:rocket: An incredible wonderland of code
MIT License
137 stars 6 forks source link

Clarifying questions #153

Open joyguar opened 1 year ago

joyguar commented 1 year ago

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.