whatacold / ppcompile

🏓ping-pong compile, an Emacs package for coding locally but compiling remotely

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using ppcompile without expect?

sebastiansturm opened this issue · comments

first of all, thanks for ppcompile! Appeared just in time for the Corona lockdown. When trying it out, I ran into a few minor issues though:

(i) I'm using doom-emacs which downloads packages to one directory, and stows away the results of byte compilation elsewhere. Which led to with-password.exp not being in the place where ppcompile expected it to be; for doom users who want to use password-based authentication (I don't) that will be an issue
(ii) copying with-password.exp into the build directory, ppcompile synced and started the compile command (as far as I can tell), but then aborted with a timeout. Does the expect timeout count against the compilation time, too? (I guess not since that would be a bit unusable, but I figured I'd better bring this up just in case)
(iii) I slightly patched my copy of ppcompile.el so I can use it without expect, though judging by the GitHub documentation that shouldn't be necessary. Do you plan to add a config variable or some other mechanism to opt out of using expect entirely?
(iv) minor feature request: I'd love to be able to specify a custom command that is then automatically executed within the rsync dst directory, akin to Emacs's builtin compile feature accepting arbitrary compile commands. Though that should be pretty trivial to add, so alternatively I could open a PR that does this

thanks again for this very useful package!

(i) I'm using doom-emacs which downloads packages to one directory, and stows away the results of byte compilation elsewhere. Which led to with-password.exp not being in the place where ppcompile expected it to be; for doom users who want to use password-based authentication (I don't) that will be an issue

I wasn't aware of this behavior with DOOM, it sounds like we'd better use defcustom instead of defconst for this.

(ii) copying with-password.exp into the build directory, ppcompile synced and started the compile command (as far as I can tell), but then aborted with a timeout. Does the expect timeout count against the compilation time, too? (I guess not since that would be a bit unusable, but I figured I'd better bring this up just in case)

I guess it doesn't count, because sometimes the compilation took more than 10s for me.

(iii) I slightly patched my copy of ppcompile.el so I can use it without expect, though judging by the GitHub documentation that shouldn't be necessary. Do you plan to add a config variable or some other mechanism to opt out of using expect entirely?

That sounds reasonable, you can try to remove "expect" and the script from the actual command in elisp, it should be ok for public-key authentication.

Currently, expect is also used for public-key authentication connections, which is unnecessary though. The README should be updated accordingly.

(iv) minor feature request: I'd love to be able to specify a custom command that is then automatically executed within the rsync dst directory, akin to Emacs's builtin compile feature accepting arbitrary compile commands. Though that should be pretty trivial to add, so alternatively I could open a PR that does this

PR welcome, though I'm not 100% sure what you want exactly. For me, I prefer to configure it in .dir-locals.el.

Currently, expect is also used for public-key authentication connections, which is unnecessary though. The README should be updated accordingly.

(iv) minor feature request: I'd love to be able to specify a custom command that is then automatically executed within the rsync dst directory, akin to Emacs's builtin compile feature accepting arbitrary compile commands. Though that should be pretty trivial to add, so alternatively I could open a PR that does this

PR welcome, though I'm not 100% sure what you want exactly. For me, I prefer to configure it in .dir-locals.el.

I often want to selectively compile the parts of a project I have just changed (it's made up of several processes that communicate with one another but can be compiled separately), or sometimes run a compilation with different compile flags, that's why a single directory-wide default doesn't quite cut it. Will do a small PR later, thanks

Hi,

I just commited a few on master to improve the issues you addressed:

  1. Use defcustom instead of defconst for the expect script, so that users have a chance to make it right.
  2. Don't call expect if expect itself or the script is not available, just use public key authentication.

I'd love to be able to specify a custom command that is then automatically executed within the rsync dst directory, akin to Emacs's builtin compile feature accepting arbitrary compile commands.

I think I get your concerns, and I am going to make a patch for it.

Now it also respects the compilation-read-command variable, please check it out and see how it works for you.

Cheers!

nice, the expect-less compilation is exactly what I need! About the custom compile command I'm not so sure because it seems to me ppcompile executes it verbatim (i.e., without wrapping it inside ssh user@host ...)? On a related note, I don't see regular ppcompile changing the current directory to ppcompile-rsync-dst-dir, although most projects probably need to have their compile command executed within the project directory? Personally, the most convenient user interface I can think of would ask for a custom compile command, then (after rsyncing) execute that via SSH, within the remote directory we just synced to.

For my own custom-command helper function, I'm currently doing this:

         (let*
             ((cmd (read-from-minibuffer "Compile command:"))
              (basename (f-base (projectile-project-root)))
              (ppcompile-remote-compile-command
               (format "'cd %s/%s && %s'" ppcompile-rsync-dst-dir basename cmd)))
           (unless (string-blank-p cmd) (ppcompile)))))

that way, compilation automatically follows ppcompile-rsync-dst-dir (though a proper version of the above snippet would be written differently so it doesn't break if the remote directory path contains spaces).
Not sure if I'm misusing or misunderstanding the regular ppcompile command; anyway, with your new commits, the above snippet does exactly what I want so thanks for implementing that!

About the custom compile command I'm not so sure because it seems to me ppcompile executes it verbatim (i.e., without wrapping it inside ssh user@host ...)?

What's the pong command in *Message* buffer if you toggled debugging? I found and fixed a tiny issue about it a few hours ago, in case you haven't pull yet.

On a related note, I don't see regular ppcompile changing the current directory to ppcompile-rsync-dst-dir, although most projects probably need to have their compile command executed within the project directory? Personally, the most convenient user interface I can think of would ask for a custom compile command, then (after rsyncing) execute that via SSH, within the remote directory we just synced to.

For my own custom-command helper function, I'm currently doing this:

         (let*
             ((cmd (read-from-minibuffer "Compile command:"))
              (basename (f-base (projectile-project-root)))
              (ppcompile-remote-compile-command
               (format "'cd %s/%s && %s'" ppcompile-rsync-dst-dir basename cmd)))
           (unless (string-blank-p cmd) (ppcompile)))))

that way, compilation automatically follows ppcompile-rsync-dst-dir (though a proper version of the above snippet would be written differently so it doesn't break if the remote directory path contains spaces).

Hmm, this interface sounds better, as it's more like the M-x compile experience, thanks! We should do this.

Currently, you can M-n to get the initial remote command when it prompts you, and fine-tune it afterward. The initial command is something like ssh ... make -C /remote/path/, where the head part can be omitted to achieve a better experience.

Hmm, this interface sounds better, as it's more like the M-x compile experience, thanks! We should do this.

This has been implemented in cdc6971 , check it out and tell me what you think :)

The variable ppcompile-remote-compile-command's meaning changes, which contains only the compile command like make -k -C ., users don't need to care about the whole ssh cd details now.

yes! This is just what I need. Thanks a lot!

Cheers, thanks for the idea.

I'm gonna close this issue now.