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 username#DESKTOP-FN20BRU.13000:1597860074. So anybody can please explain me this working process of emacs?
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.
Related
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:
Once I save and close, the text is updated in Houdini, and I can continue working:
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.
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)
I have Jekyll blog and when I run jekyll serve, and I'm editing the post in GNU Emacs I got this output:
Regenerating: 2 file(s) changed at 2020-02-28 09:05:34
_posts/2018-10-20-pytania-rekrutacyjne-css.markdown
_posts/.#2018-10-20-pytania-rekrutacyjne-css.markdown
...done in 13.517243884 seconds.
is it possible to ignore files that starts with .#. I assume it would be twice as fast to generate the html page.
I've tried this:
exclude:
-
README.md
-
.\#*
-
_posts/.\#*
but this don't work, it regenerate when I save _config.yml (as .#_config.yml) the same as with posts.
I would like to ignore every Emacs file in my Jekyll project.
Files with a .# prefix are lockfiles. They prevent separate Emacs instances from editing the same file at the same time. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html. Personally, I set (setq create-lockfiles nil) because I rarely run more than one Emacs, and I have (global-auto-revert-mode 1). auto-revert-mode will watch for a file to be changed and automatically reload it (or tell you it has changed if there are unsaved changes).
Also take a look at https://github.com/emacscollective/no-littering to move autosave and backup files to a common place instead of next to whatever file you're editing.
Probably only the message is confusing. It says 2 files changed, which is correct. It does not say 2 files regenerated. My config does not even exclude .#-files. I get the same message, but no .#-file is generated. Check the _site folder. And check the time to regenerate the output file
touch _posts/2018-10-20-pytania-rekrutacyjne-css.markdown # still around 14 sec?
touch _posts/.#2018-10-20-pytania-rekrutacyjne-css.markdown # should be close to zero?
How do I directly see the content of an emacs autosave file, without implementing a file recovery operation?
That is, suppose I created a file with 'emacs foo', then emacs crashed, so I'm left with no file named 'foo' (since it never was saved) but with a file '#foo#'. When I type 'more #foo#', I get "Missing filename", as though the more command doesn't even see the #foo# part of the command.
I just want to see the text in #foo# so I can copy it out by hand without risking something going wrong in the file recovery process (eg #foo# getting overwritten by a new autosave operation).
(I'm using Terminal on OSX.)
Bash or another shell use '#' as comment character, try :
more "#foo#"
In Emacs, I'm trying to create a file on the fly (using with-temp-file), set some file local variables, write the local variables to the file and save it. After some modifications to the newly created file, I delete the file and kill the corresponding buffer. So far it's working.
Now after deleting the file, I do the same process (create file on the fly, open the buffer, etc). But this time when I try to do something on the newly created buffer using with-current-buffer I'm getting this weird error:
Selecting deleted buffer
buffer-live-p on the new buffer returns t.
What could have gone wrong?
I'm using a custom build of Emacs 24.3 on RHEL 6.
My default input method has always been configured this way:
(setq default-input-method "russian-computer")
Something broke, and all I get is this message (on top of the execution stack, if I'm interpreting it right) as soon as I press C-\:
activate-input-method: Can't activate input method `russian-computer'
It used to work without a hitch. There has been no intervention that I'm aware of; I'd like to get some clues.
Emacs loads the input-methods it knows from a directory called "leim" (Library of Emacs Input Methods). The location of the code to load should be something like
/usr/share/emacs/<version>/leim/leim-list.el
(For the exact location, search for an entry containing the word "leim" in your load-path variable by typing C-h v load-path.)
If you inspect that file, you should see an entry
(register-input-method
"russian-computer" "Russian" 'quail-use-package
"RU" "ЙЦУКЕН Russian computer layout"
"quail/cyrillic")
which refers to a subdirectory of the "leim" directory called "quail".
Make sure that both the file leim-list.el and the sub-directory quail exist on your system. The quail directory is distributed separately from the Emacs source code, so if you installed from source, make sure you included the leim-list package. See here (scroll to bottom):
http://ftp.gnu.org/pub/gnu/emacs/
If the leim directory is empty, you might consider re-installing emacs.