wannabe programmer
wannabe programmer

Reputation: 127

Emacs ftp upload on save like in sublimetext?

I used sublemtext and I have made the switch to using emacs.

I love that you can completely never leave emacs while working. With that said there is a lot to learn. I am trying to find out a way to duplicate my workflow for pushing files from my local server to the remote for numerous projects. A lot of my clients servers are on shared hosting and I cant use ssh.

With sublimetext I had a sftp.json file within my project locally and it had the ftp details for the server. So anytime I am working in a local dir I can just save and it uploads.

One of the main reasons I like this vs just editing directly on the server is I use compass to watch projects and compile. So I can make a change and it compiles. I then push the compiled file up.

I am aware of ange-ftp being built in I believe. I have made a connection to my server, but its just directly editing obviously.

Could some of you advanced emacs folks help me achieve the same setup?

Upvotes: 2

Views: 816

Answers (1)

Tim S.
Tim S.

Reputation: 2257

I would likely make a after-save-hook in emacs with a function to upload the file to the remote location. You could define a login function perhaps using .netrc[.gpg] if you are concerned about security, and have your after-save-hook call that to upload the file.

Here is some info on Standard Emacs Hooks, and another page of the GNU manual about Saving Buffers.

One other consideration/thought is to restrict that functionality to a particular directory, like a project directory. For example, anything in /home/user/workspace/projecta/ would get uploaded to host1:/projecta, etc.

Upvotes: 1

Related Questions