ergoemacs / ergoemacs-mode

ergoemacs-mode
ergoemacs.github.io/
GNU General Public License v3.0
293 stars 35 forks source link

Kill buffer should ask to save changes #419

Closed marcuscf closed 7 years ago

marcuscf commented 8 years ago

I'm trying Ergoemacs mainly for CUA-shortcuts plus Ctrl+N, Ctrl+O and ESC.

I noticed that if you create a new buffer with Ctrl+N, type some text and close it with the toolbar kill buffer button (or with C-x k RET), Emacs doesn't ask to save it before closing, while it does ask if I close it with Ctrl+W. I don't think I will ever type C-x k RET by mistake, but the toolbar button seems an easy way to lose work, at least for beginners. Could this be fixed? I would provide a patch if I were more proficient with Emacs Lisp.

I'm using version 5.14.7.3, which I assume is fairly recent (not sure if it's the latest).

mattfidler commented 8 years ago

Thank you. I agree with you.

I have changed in in the latest unstable, which is available on melpa.

If you don't wish to upgrade, you could add the following line to your configuration:

(global-set-key [tool-bar kill-buffer] 'ergoemacs-close-current-buffer)
marcuscf commented 8 years ago

Thank you for your reply. Unfortunately I could not make it work by adding that line to my configuration file (I haven't tried updating to the unstable version yet).

I guess there's something that overrides that setting. I tried some variations (with local-set-key, define-key, etc.) but when they work, they only work interactively and not when put in .emacs file.

mattfidler commented 8 years ago

What version of emacs are you using?

marcuscf commented 8 years ago

Emacs 24.5.1 on Cygwin (i686-pc-cygwin, GTK+ Version 3.14.13)

mattfidler commented 8 years ago

I don't work with the stable version very often any longer.

You could try instead:

(define-key ergoemacs-keymap [tool-bar kill-buffer] 'ergoemacs-close-current-buffer)

Sometimes that works better.