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

WhatMoldsCanIUse? does not report molds with failed dependencies #23

Closed
alanz opened this issue Dec 2, 2021 · 4 comments · Fixed by #26
Closed

WhatMoldsCanIUse? does not report molds with failed dependencies #23

alanz opened this issue Dec 2, 2021 · 4 comments · Fixed by #26

Comments

@alanz
Copy link
Contributor

alanz commented Dec 2, 2021

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
Copy link
Contributor Author

alanz commented Dec 2, 2021

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
Copy link
Contributor Author

alanz commented Dec 4, 2021

And I think this is relevant

@alanz
Copy link
Contributor Author

alanz commented Dec 5, 2021

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
Copy link
Owner

ag91 commented Dec 5, 2021

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)))

ag91 added a commit that referenced this issue Dec 6, 2021
now it can find missing dependencies even if they are nested in a
:given :fn predicate

#23
@ag91 ag91 closed this as completed in #26 Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants