jcs-elpa/flx-rs

Automated straight setup?

jojojames opened this issue · 3 comments

Do you have a recipe to automatically set up the building/linking?

Doing something like this right now, but haven't really tested it too much...

(use-package flx-rs
  :ensure t
  :straight t
  ;; (flx-rs
  ;;  ;; :type git :host github :repo "jojojames/matcha"
  ;;  :pre-build (("cargo core") (message "$ cargo core"))
  ;;  :post-build
  ;;  (("ln -s ~/.emacs./straight/repos/flx-rs/bin ~/.emacs.d/straight/build/flx-rs/bin")
  ;;   (message "Linking flx-rs.")))
  :init

  ;; Manual steps:
  ;; Install Rust
  ;; $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  ;; Update rustup
  ;; $ rustup update
  ;; Build flx-rs.
  ;; $ cargo build ~/.emacs.d/straight/repos/flx-rs/core
  ;; Symlink to Straight BUILD directory.
  ;; $ ln -s ~/.emacs.d/straight/repos/flx-rs/bin ~/.emacs.d/straight/build/flx-rs/bin

  ;; This hasn't been tested.
  (unless (file-exists-p "~/.emacs.d/straight/build/flx-rs/bin")
    (unless (executable-find "cargo")
      (shell-command
       "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y")
      (shell-command "rustup update"))
    (shell-command "cd ~/.emacs.d/straight/repos/flx-rs/core; cargo build")
    (shell-command
     "ln -s ~/.emacs.d/straight/repos/flx-rs/bin ~/.emacs.d/straight/build/flx-rs/bin"))

  (flx-rs-load-dyn)
  ;; This is not necessary since `flx-all-completions' already checks for this
  ;; function. It'll still help other libraries that call `flx-score' though.
  ;; (advice-remove 'flx-score 'flx-rs-score)
  ;; (advice-add 'flx-score :override #'flx-rs-score)
  )

I have published this package under my own elpa, see https://github.com/jcs-emacs/jcs-elpa.

The recipe format should look like this.

Extra: You don't need to build binaries yourself since it has prebuilt binaries inside bin folder.

Awesome! I did not realize that, was building it myself the whole time.

Anyways, I've pushed my flx completion-style code to its own repo for the time being now. Hoping I can push maybe one day push it to the main flx repo, but I'll eventually push to melpa if there's no further discussion on the flx issue.

https://github.com/jojojames/flx-completion