ag91 / moldable-emacs

Adapting Emacs for moldable development
GNU General Public License v3.0
105 stars 8 forks source link

WhatMoldsCanIUse? does not report molds with failed dependencies #23

Closed alanz closed 2 years ago

alanz commented 2 years ago

I do not have org-ql installed.

If I open an org-mode file, and activate WhatMoldsCanIUse? it does not add a section noting the missing dependencies.

Perhaps there should be a test for this, with a test mold having an impossible dependency to keep it from regressing.

alanz commented 2 years ago

Funny. I put some messaging in, and found evaluating the lambda contents to display it causes it to give a result. Without the (progn (message..) clause I do not get any missing dep molds reported.

(defun me-usable-molds-requiring-deps ()
  "Find molds that require dependencies to run."
  (--remove
   (let ((mold it)
         (given-cond (me-get-in it '(:given :fn))))
     (ignore-errors
       (and
        (> (length given-cond) 1)
        (eq (car given-cond) 'and)
        (progn (message "me-usable-molds-requiring-deps:got and:filtered=%s" (eval (cons 'and (--remove
                                              (or
                                               (and
                                                (seqp it)
                                                (-contains? it 'executable-find))
                                               (and
                                                (seqp it)
                                                (-contains? it 'me-require)))
                                              (cdr given-cond))))) t)
        (me-with-mold-let mold
                          (lambda ()
                            (eval (cons 'and (--remove
                                              (or
                                               (and
                                                (seqp it)
                                                (-contains? it 'executable-find))
                                               (and
                                                (seqp it)
                                                (-contains? it 'me-require)))
                                              (cdr given-cond)))))))))
   me-available-molds))
alanz commented 2 years ago

And I think this is relevant

alanz commented 2 years ago

I think we need to do a deep traversal of the :given clause. e.g.

 :given (:fn (and
              url
              (me-require 'json)
              (executable-find "lighthouse") ;; npm i -g lighthouse
              (or (executable-find "chromium")
                  (executable-find "chrome")
                  (file-exists-p "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"))))

will not currently find the executable-find clauses under the or.

ag91 commented 2 years ago

You are correct! That is still at a basic implementation. I need to add some basic traversal functions eventually, although this also does the trick:

(let ((example (-flatten '(and
                           url
                           (me-require 'json)
                           (executable-find "lighthouse") ;; npm i -g lighthouse
                           (or (executable-find "chromium")
                               (executable-find "chrome")
                               (file-exists-p "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"))))))
  (--> example
       (--find-indices (eq it 'executable-find) it)
       (--map (nth (+ 1 it) example) it)))