Emacs Exiting and Help
100%

Advanced Text-Fu · Lesson 13

Emacs Exiting and Help

Learn how to exit Emacs safely, cancel pending commands, inspect help topics, and undo changes.

Emacs provides contextual help for keys, functions, variables, and active modes. It also protects modified file-visiting buffers during exit, giving you a chance to save or decline each write.

Exiting Emacs

Use C-x C-c, which runs save-buffers-kill-terminal, to request that the Emacs session or terminal connection close:

C-x C-c

Emacs checks relevant modified file-visiting buffers and asks whether to save them. Read each buffer name and answer deliberately. It may also ask about active processes. Cancel the exit if you need to inspect work before deciding.

In an emacsclient workflow or an Emacs server, the exact frame and server behavior can differ, but modified-buffer prompts still deserve careful attention.

Which key sequence requests a normal Emacs exit and checks modified buffers?

Opening the Help Dispatcher

The standard help prefix is C-h. Use C-h C-h, which runs help for help, to display guidance on available help commands:

C-h C-h

The second key chooses the type of help you need.

Which key sequence explains how to use the Emacs help system?

Describing Keys and Editor State

Useful help commands include:

  • C-h k KEY: Describe what a key sequence runs.
  • C-h f FUNCTION: Describe an Emacs Lisp function.
  • C-h v VARIABLE: Describe an Emacs Lisp variable.
  • C-h m: Describe the current major and minor modes.
  • C-h t: Open the interactive tutorial.

For example, type C-h k C-x C-s to see documentation for the save-buffer binding.

You want to learn what C-x C-s does. Which help prefix should you enter before that key sequence?

Cancelling a Pending Command

Use C-g, bound to keyboard-quit, when you are stuck in a prompt, partially entered key sequence, incremental search, or other command you want to cancel:

C-g

It does not undo buffer changes that have already happened and does not exit Emacs. It stops the current interaction and returns control to ordinary editing when possible.

Which key normally cancels the current Emacs prompt or pending command?

Undoing Buffer Changes

Use C-/, C-_, or C-x u to invoke undo in common Emacs configurations:

C-/

Repeated undo commands walk backward through recent buffer changes. Cursor movement alone is not normally a buffer change. Emacs versions and configurations can offer undo-redo and more advanced history tools; use C-h k on your actual undo and redo bindings to verify local behavior.

Which key sequence is a standard binding for undoing a recent Emacs buffer change?

Practice by opening *scratch*, making a disposable change, using undo, asking C-h k about an unfamiliar key, and cancelling a minibuffer prompt with C-g before exiting normally.

Lesson complete

You finished Emacs Exiting and Help

You can now recover help and leave Emacs without ignoring unsaved work.

  • Exit through the modified-buffer checks with C-x C-c.

  • Open help for help with C-h C-h.

  • Describe keys, functions, variables, or active modes.

  • Cancel a pending command with C-g.

  • Undo recent buffer changes with a verified local binding.

Keep your learning progress

Create a free account to save this lesson and continue learning on any device.

Create a free account
Back to Advanced Text-Fu