Created
November 3, 2023 00:31
-
-
Save rytswd/1be918ecb64b91e351d9824034b8810b to your computer and use it in GitHub Desktop.
Emacs: Save without formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun rytswd/save-without-save-hook () | |
"This function saves the current buffer without invoking save hook. | |
This uses a bit of a hacky trick of using ~write-region~ to achieve this. | |
It may cause some unintended behaviours depending on the context." | |
(interactive) | |
(let ((filename (if buffer-file-name buffer-file-name | |
(read-string "File name to save as: ")))) | |
(write-region (point-min) (point-max) filename) | |
(revert-buffer :ignore-auto :noconfirm))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment