Nervous Hero
Nervous Hero

Reputation: 145

How does emacs compile the file and edit it?

There is this feature in emacs. Whenever you compile your code (filename: hello.cpp) run the program and then you edit your code then emcas will store you previous unedited code in another file named hello.cpp~ . hello.cpp~ will always contain first code you compile and whenever you write you edit your code in emacs it will produce file name .#hello.cpp. It automatically remove .#hello.cpp when you save that code but hello.cpp~ will remain same. .#hello.cpp file contain info. such as [email protected]:1597860074. So anybody can please explain me this working process of emacs?

Upvotes: 1

Views: 86

Answers (1)

Déjà vu
Déjà vu

Reputation: 28850

Emacs does the following when you edit a file filename

  • #: when you modify the file (in memory), Emacs creates a # file (on disk) and keeps updating it with your changes, until you save the edited version. This draft, on disk, can be recovered in case Emacs or the computer crash before you had time to save your changes.

  • ~: as soon as you save the edited version, Emacs renames first your old version on disk (the one when you opened Emacs) adding a trailing ~ to the filename giving filename~ (it does this only the first time you save within the current session), then it overwrites filename with the modified version, and finally removes the # draft on disk.

Then, when you make further changes, another # file is created, etc.

Upvotes: 3

Related Questions