I sometimes would like to make changes to my emacs files but without changing the date of the modified file. For instance, I would like to write up a brief evaluation of a lecture I might have given. Ideally, I would not like to change the file's date under these circumstances. Is there any way to do this? I run emacs on Windows 7. I have noted too that changing a file's name also changes its date. It would be nice to change the name but without effecting the date.
-
Are you talking about the date you see in Windows Explorer? It's not possible to change the contents of a file and not have its modified date updated. Also, renaming a file should not change the date. How are you renaming the file?– nannyCommented Jun 29, 2015 at 14:23
-
You are right. I am not sure why I drew that inference about renaming.– rariCommented Jun 29, 2015 at 14:42
Add a comment
|
1 Answer
I don't think you can avoid changing the timestamp when saving, but you could write a function that resets it back to the original pre-save timestamp:
(defun save-buffer-preserving-modtime ()
"Call `save-buffer', but keep the visited file's modtime the same."
(interactive)
(let ((original-time (visited-file-modtime)))
(save-buffer)
(set-file-times buffer-file-name original-time)
(set-visited-file-modtime original-time)))