Skip to content

Instantly share code, notes, and snippets.

@schani
Created June 25, 2010 14:11
Show Gist options
  • Save schani/452895 to your computer and use it in GitHub Desktop.
Save schani/452895 to your computer and use it in GitHub Desktop.
(defun bertl-switch-to-buffer (name)
(interactive "BSwitch to buffer")
(let ((buffer (get-buffer name)))
(if buffer
(switch-to-buffer buffer)
(progn
(switch-to-buffer name)
(setq buffer-offer-save t)
(auto-save-mode t)))))
(defun bertl-kill-buffer-function ()
(let ((buffer (current-buffer)))
(when (and buffer-offer-save
(buffer-modified-p buffer)
(y-or-n-p (concat "Save buffer " (buffer-name buffer) "? ")))
(save-buffer)))
t)
(setq kill-buffer-query-functions (append '(bertl-kill-buffer-function) kill-buffer-query-functions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment