emacs as an external editor for other applications (Houdini, Joplin)

377 Views Asked by At

I am trying to use emacs as an editor with other applications which allow people to open text in an editor (Sublime in this case), save it, and see it updated in the application. For example, in Houdini, a 3D software, I can type code in an external editor (in this case, Sublime), modify, save... and see it update in the application (Houdini). When I use emacs, it doesn't work. As an example, here I am adding a line of text using Sublime in Houdini:

editing text externally using Sublime, step 1

Once I save and close, the text is updated in Houdini, and I can continue working:

text entered and saved in Sublime, step 2, success!

Try as I might, I can't get this to work in emacs. I am sure the file has the same name, and when I save, it confirms the right file path. What am I missing? I have run into the same problem with an application called Joplin: Sublime works, emacs does not.

1

There are 1 best solutions below

0
legoscia On

A wild guess: Emacs has different behaviour when saving files than Sublime, and Houdini gets confused by that.

When you save a file in Emacs, Emacs creates a backup of the previous contents of the file, suffixing the file name with a tilde. By default it does this by renaming the existing file to the backup name, and then writing the contents to the real filename, thereby creating a new file.

(You can observe this by running ls -i before and after: the backup file will have the inode number that the main file had previously. Note that Emacs doesn't make backups after the first save during the same editor session, so you might need to restart Emacs or kill the buffer with C-x k to see this.)

I suspect that Houdini keeps the file open while Emacs is editing it, and so when you save the file from Emacs, the file that Houdini has open is actually the backup file.

You can configure Emacs to make backups by copying instead of renaming by setting the variable backup-by-copying to t. Add this to your ~/.emacs file (creating it if it doesn't exist):

(setq backup-by-copying t)