Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do each of these stand for after the "Save file?" prompt: (y, n, !, ., q, C-r, d or C-h)

Tags:

emacs

The question is pretty self-explanatory. When I close emacs and some changes are unsaved, I'm asked if I want to save the file and given this list of options. I assume "y" and "n" are "yes" and "no", but what are the other options?

like image 855
zjmiller Avatar asked Apr 02 '11 00:04

zjmiller


People also ask

What is the command to save a file?

Use the keyboard shortcut Ctrl+S. Go to File > Save on the Menu bar. Click the Save icon on the Standard toolbar. Using the Save command will overwrite the last saved version of the file.

What is the command to save a file in Emacs?

To save the file you are editing, type C-x C-s or select Save Buffer from the Files menu. Emacs writes the file. To let you know that the file was saved correctly, it puts the message Wrote filename in the minibuffer.

How do I write to a file in Emacs?

To insert text into a buffer, place the cursor where you want to start inserting text, and start typing away. If you want to insert the contents of another file into the current buffer, place the cursor at the desired insertion point, and type Control-X-I. Emacs will ask you for the name of the file you wish to insert.

What is a buffer in Emacs?

Buffers in Emacs editing are objects that have distinct names and hold text that can be edited. Buffers appear to Lisp programs as a special data type. You can think of the contents of a buffer as a string that you can extend; insertions and deletions may occur in any part of the buffer.


1 Answers

Type ? and you'll get a buffer showing:

Type SPC or `y' to save the current buffer;
DEL or `n' to skip the current buffer;
RET or `q' to give up on the save (skip all remaining buffers);
C-g to quit (cancel the whole command);
! to save all remaining buffers;
C-r to view this buffer;
d to view changes in this buffer;
or . (period) to save the current buffer and exit.

If you want to add/change actions that happen during the save-some-buffers function, then you can modify the variable save-some-buffers-action-alist. Perhaps if you wanted to add a binding to save the changes and kill the buffer via the key k. You could do this:

(add-to-list 'save-some-buffers-action-alist
             `(?k ,(lambda (buf) (save-buffer buf) (kill-buffer buf))
                  ,(purecopy "save changes and kill the buffer")))

If you look at the documentation for save-some-buffers, it will direct you to save-some-buffers-action-alist - which further directs you to map-y-or-n-p - which actually does have documentation on the format of that variable.

like image 55
Trey Jackson Avatar answered Oct 22 '22 15:10

Trey Jackson