Skip to content

Instantly share code, notes, and snippets.

@rytswd
Created November 3, 2023 00:31
Show Gist options
  • Save rytswd/1be918ecb64b91e351d9824034b8810b to your computer and use it in GitHub Desktop.
Save rytswd/1be918ecb64b91e351d9824034b8810b to your computer and use it in GitHub Desktop.
Emacs: Save without formatting
(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