milouse / flycheck-grammalecte

Fork of flycheck-grammalecte to support Grammalecte v0.6.4+ (Mirror)
https://git.umaneti.net/flycheck-grammalecte/about/
GNU General Public License v3.0
10 stars 3 forks source link

[Improvement] Download grammalect automatically #22

Open Cletip opened 2 years ago

Cletip commented 2 years ago

Small code share to keep up to date and download grammalecte automatically (normally it works for me)

(use-package flycheck
    :config
    (global-flycheck-mode t) ;;activate flycheck-mode to work the dowload
    )

  (use-package flycheck-grammalecte
    :after flycheck
;; the configuration go here

    (flycheck-grammalecte-setup)

;; try and install
    (unless (fboundp 'grammalecte--version)
      (grammalecte-download-grammalecte))

;; update
    (let ((local-version (grammalecte--version))
          (upstream-version (grammalecte--upstream-version)))
      (when (stringp upstream-version)
        (if (stringp local-version)
            ;; It seems we have a local version of grammalecte.
            ;; Compare it with upstream
            (when (and (string-version-lessp local-version upstream-version)
                       (or grammalecte-download-without-asking
                           (yes-or-no-p
                            "[Grammalecte] Grammalecte is out of date.  Download it NOW?")))
              (grammalecte-download-grammalecte upstream-version))
          ;; It seems there is no currently downloaded Grammalecte
          ;; package. Force install it, as nothing will work without it.
          (grammalecte-download-grammalecte upstream-version))))
)

Test and give me a feedback ^^

milouse commented 2 years ago

Hi, and thank you very much for your contribution. I'll work on it next week when I'll come back from my hollidays. If you don't mind, could you send it to me again as a patch or a merge request?

milouse commented 2 years ago

Wow, I just came back to this, and in fact I think you miss something: the grammalecte-download-grammalecte function already take care of updating grammalecte if needed.

However you are right that once it is installed, I never call it again in the flycheck setup function (the reason behind it was to avoid yes or no question poping out of the blue from time to time). Thus it is a manual process.

I’ll check what I can do to improve that.

Cletip commented 2 years ago

No problem. I invite you to go and see "the other way out" that I opened (you just didn't answer it I think)