Strange link in local dir for file being edited in emacs [duplicate] - emacs

This question already has answers here:
Why does emacs create temporary symbolic links for modified files?
(2 answers)
Closed 6 years ago.
Whenever I edit a file in emacs, I get a link in the current directory that looks like
lrwxrwxrwx 1 mpersico users 65 Feb 15 12:04 .#theFile -> mpersico#myhostname.nnnnn:nnnnnnnnnn
where the 'n's are 0-9. The first five n's are the pid of the emacs process. The file only appears while there are unsaved edits. Typing one key in the buffer creates the file. Saving the buffer removes the file.
Any idea what that file is and if it can be moved somewhere else? It's causing spurious errors in my rsync snapshotting setup.
TIA

It's an interlock: it's created when a buffer is modified in order to allow emacs to warn you when somebody else has modified it. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html#Interlocking . I don't think you can move it to some other directory without compromising emacs's ability to detect such conflicts. OTOH, you can disable it (see the link above) and emacs will ignore the conflict all together.

Related

purpose of ~/.emacs.d/auto-save-list/

A directory titled auto-save-list appeared in my .emacs.d folder. In my init.el file, I did not explicitly mention I want this folder to be made. What is the purpose of this folder? I noticed it seems to always be empty: files being auto-saved (starting with #) appear wherever the original file being edited is, not in the auto-save-list directory.
If you search the manual or its index for auto-save-list you will find:
Emacs records information about interrupted sessions in files named
‘.saves-PID-HOSTNAME’ in the directory ‘~/.emacs.d/auto-save-list/’.
This directory is determined by the variable
‘auto-save-list-file-prefix’. If you set ‘auto-save-list-file-prefix’
to ‘nil’, sessions are not recorded for recovery.
– C-hig (emacs)Recover RET
I did not explicitly mention I want this folder to be made.
Emacs and elisp libraries in general write to ~/.emacs.d/ when they need to save data. That's one of the purposes of this directory -- to provide a common place for such files to be written to; and this typically happens without asking explicit permission (although it's also pretty common for you to be able to customize the filename in question if you so wish).
phils already answered the specific question, but to answer the more general question of what to do about miscellaneous files automatically created by Emacs, check out the no-littering package.
Auto save files (the ones with '#') are not handled by no-littering, but the readme gives a work around for those if you wish.

Emacs: trying to write something after saving provokes message "file changed on disk. Really edit the buffer?"

Emacs 24 in Ubuntu 14.
I have file opened only in emacs, and it gives me this constantly, after each saving. that is annoying.
This is strange, because earlier everything worked fine. I can hardly guess what could I break during this time. I'am total newbie in Ubuntu, using it according to instructions found in internet.
Now I'm using emacs 23, everything is fine. I guess, I need auto-syncronization of opened buffer with saved file right after saving. Anyway, how can I fix it?
It sounds like some other program on your computer is reading the file when it changes, and possibly even introducing changes (perhaps just to the modification time, rather than to the contents). It's hard to say off-hand just what that would be.
A workaround try M-x global-auto-revert-mode. It will only auto-revert if you have no local modification since the last saving. This is generally a nice mode to turn on if you use multiple editors, and I keep it enabled all the time.
Other ideas:
Check if any other process currently has the file open using fuser /path/to/filename.txt (note: it only shows open file descriptors, not processes that hold the file content in memory and write it later)
Do you use any non-standard filesystem? (check with df -h /path/to/filename.txt and mount)
Is your system time stable? (Manually check date, scan the output of dmesg for obvious errors concerning timekeeping, and look for errors related to NTP in the logfiles in /var/log/.

Rubymine creating text files by default [duplicate]

This question already has answers here:
Pycharm utils.py not getting syntax highlight
(6 answers)
Closed 3 years ago.
I am attempting to create a .rb file within Ruby, using these steps:
1. Create New File
2. Name new file "a"
3. Associate file to .rb filetype
This creates a file named "a" that works fine; however, when I rename this file to a.rb it immediately converts the file to a text file. Why is that?
I have been creating files this entire time by creating a new file and naming it "a.rb" from the start, and it automatically associates it to a ruby file. Now it just associates that naming to a text file and I have to leave off the .rb and manually assign the filetype later. What changed?
FOR MAC USERS you can find the settings you need to fix this here:
RubyMine | Preferences | Editor | File Types
The above answer is correct – removing a.rb does solve the problem – and I realize that this question is two years old now… But having come across this problem today and not having been able to find a solution for the longest time, hopefully this will help someone else too. Default Settings under File does NOT have this tab in the current version of RubyMine on Macs, and it took me forever to find the tab where File Types is.

Files created by Matlab cannot be deleted [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do you handle resources in MATLAB in an exception safe manner? (like “try … finally”)
How can I close files that are left open after an error?
I create some files and directories via fopen and mkdir, and I close any open streams with the appropriate fclose command when I finish writing to the files. Nevertheless, when I abort a computation with Ctrl+C these directories/files remain in memory somehow and I am unable to delete them. Not even subsequent close all calls can free them, I have to exit Matlab to free these files. Any idea how I can counter this behaviour (other than 'stop using abort')?
System is: Win7 64bit, Matlab R2011b.
Simple solution: fclose('all')

How to write .emacs from Emacs when I've deleted .emacs

I have Emacs open but accidentally I've deleted the .emacs file it read when it started. This represents about 15 years of tweaking. (I know, I know, backups.)
Is there a way to get Emacs to write out the .emacs file I've deleted?
I wouldn't normally ask such a lame question on SO but I know I only have a day or so before this Emacs session ends.
As ayckoster suggests, you might try a file recovery or forensics tool like The Sleuth Kit. Or, and this may seem crazy, if you're on a Unix-like system, you could search through the raw disk device (on the Mac I'm currently on, that would be /dev/rdisk1). Seriously, several times I've been too lazy to break out a full-blown recovery tool but instead used something like sudo less -f /dev/rdisk1, searched for a string I knew was in the file (global-set-key, anyone?), and succeeded in recovering the file's original content.
If you have Emacs' backup feature turned on, you should have a copy of your next-to-last .emacs file in ~/.emacs~. If so, just rename that one to ".emacs" and you will have the .emacs file with all but your latest changes. Even if you don't currently have backups enabled, you might still have a substantial chunk of your .emacs file in the last backup on file. You should also look at the value of the variable "backup-directory-alist" - it specifies location(s) for backup files to be stored if the default (same directory as modified file) isn't used.
Otherwise, how good is your memory... ;-)
EDIT: Since you don't have a backup of your .emacs file but you have a running Emacs instance that was started with that .emacs file, another thing you can do is to save all the custom settings that would have been defined in your .emacs file. To do this, do something like:
(setq custom-file "/my/home/directory/.emacs-custom.el")
(custom-save-all)
Then, you could create a new .emacs file and add the following lines to it:
(setq custom-file "/my/home/directory/.emacs-custom.el")
(load custom-file)
That will at least restore some of the custom variable settings that were in your .emacs file.
Emacs evaluates your .emacs file and afterwards it is closed. So basically you cannot get your .emacs back.
A solution might be to use a file recovery application. The odds of your .emacs being on your hard drive are quite good.
As most such programs cannot deduce the file name or directory name of the deleted file you have to know the content of your .emacs.
Then you can restore all currently deleted files in some folder and recursively search for the contents of your .emacs.
This process might take very long. You have to decide if its worth your effort.
I don't know of any way to get Emacs to provide the original .emacs file, but you can certainly interrogate the loaded function and variable symbols, and obtain their values.
This would be rather a lot of work, but I think in theory you should be able to obtain a good chunk of this data in some form or other, if you succeeded in filtering it all down to what you knew was yours.
For evaluated functions, (symbol-function 'SYMBOL) will return a (less-readable) definition of the supplied function. You could then use (fset 'SYMBOL VALUE), where VALUE is the result of the call to symbol-function, to define that function in a new .emacs file. That would give you an approach for recovering your defined functions.
http://www.gnu.org/s/emacs/manual/html_node/elisp/Function-Cells.html
http://www.gnu.org/s/emacs/manual/html_node/elisp/Symbol-Components.html
You might also look at:
How to print all the defined variables in emacs?
This is a very incomplete starter, but given time constraints I'm posting and marking it community wiki, if anyone wants to run with it.
A how-to for dumping the state of the application in a reliably restorable fashion would be a great start, if the current session is definitely going to be killed (or even if it's not, actually, to guard against crashing or other mishap).
You could potentially re-tag this with some more general data-recovery type tags, to expand the audience.