0

Let's say I create a file called foo.txt in emacs. The time is 12:00. It's currently empty.

At 12:10, I use emacs to add text to the file. I save it. The new timestamp given with getfileinfo is

created: 06/11/2020 12:10:00
modified: 06/11/2020 12:10:00

Obviously this isn't correct, and the created time should be 12:00 and the modified time should be 12:10. How can this problem be solved? As mentioned in the title I'm using a mac, specifically Mojave version 10.14, and emacs version 26.3.

  • Buffers that mean to be files are only created as files when saved, until then they are just buffers, so that problem doesn't exist as you name it. You can save empty buffers or touch files before opening them if you want the file created at that time. – Muihlinn Jun 11 at 10:26
  • I found the solution at link. You just need to put (setq backup-by-copying t) in your .init.el or equivalent file. – James Gatz Jun 11 at 11:32
  • 1
    I think you forget to mention that you saved foo.txt at 12:00. I can reproduce it from Emacs -Q, and can't reproduce from my own init file where I choose to disable the backup feature via (setq make-backup-files nil). The official doc about this: (emacs) Backup Copying – xuchunyang Jun 11 at 11:45
  • I don't see how that will solve your problem creating files, which is what you were asking. It will help when you modify already existing files. I can be wrong, indeed. – Muihlinn Jun 11 at 11:48
1

Found the solution here.

You need (setq backup-by-copying t) in your emacs configuration file.

This only applies to OSX and Windows.

| improve this answer | |
  • You should add some additional information to the answer to make it more useful. Link-only answers are discouraged and, although this one is not quite since it actually includes the relevant variable setting, it is missing crucial information, in particular that it is only applicable to Windows and MacOS X. To be clear, although you made the context clear in the question, the answer needs to specify a context too. – NickD Jun 11 at 12:57
  • Thanks for the advice. – James Gatz Jun 11 at 14:30
  • Thanks for adding the info! – NickD Jun 11 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.