Skip to content

Instantly share code, notes, and snippets.

@jamescherti
Last active May 30, 2024 21:31
Show Gist options
  • Save jamescherti/095812fefed49894cde5e5945ce5d63a to your computer and use it in GitHub Desktop.
Save jamescherti/095812fefed49894cde5e5945ce5d63a to your computer and use it in GitHub Desktop.
;; Gits URL: https://gist.github.com/jamescherti/095812fefed49894cde5e5945ce5d63a
;; License: MIT
;; Author: James Cherti
;;
;; Description:
;; ------------
;; Make the built-in (save-some-buffers) function automatically save
;; buffers that are visiting existing files, without prompting the
;; user for confirmation.
(defun my-buffer-save-without-query-when-file-exists ()
"Set buffers visiting existing files to save without querying the user."
(let ((file-name (buffer-file-name)))
(when (and file-name (file-exists-p file-name))
(setq buffer-save-without-query t))))
(add-hook 'find-file-hook #'my-buffer-save-without-query-when-file-exists)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment