Emacs Helper Functions Christopher MaioranaUpdated on October 26, 2021 5 Minute Read Getting started in emacs can be overwhelming at first, but thereâs no need to get discouraged. With emacs helper functions ready to assist, you can sit back and learn at your own pace. How do I get help with emacs? What are the most important emacs helper functions? What does that key do? Show me the manual What is the information? In order to complete this tutorial, you must install emacs on your system. How To Initiate Emacs Helper Functions In order to access help in emacs, all you need to do is type C-h (Ctrl + H on your keyboard). C-h is an interactive function that will prompt you for more input. If you want to see a menu of all the options available, press ? and the help menu will pop up, and you can use your keyboard to select an option from the menu. If you already know which function you want to run, you can type it right away. No need to wait for the menu to prompt you. The Most Important Help Functions While your particular needs and systems may elevate certain helpful functions up or notch them down, there are few invaluable functions for which every emacs user must commit their memory: Function for Key Sequence If thereâs one thing I wish I was doing when I first started learning emacs, it would be calling documentation on functions as I was keying them in. Remember, while youâre using emacs and punching in various key commands, there are functions running in the background. Those functions are attached to the keystrokes youâre punching in. The helper functions can tell you exactly which functions are running with each key press. Letâs take standard example: the save function. In order to save your work in emacs, you can key in C-x C-s. But what function runs in the background in order to accomplish this task. To discover the function, type C-h k. Then, youâll be prompted for the key command. Type in C-x C-s and a window will pop up with the documentation on the function: C-x C-s runs the command save-buffer (found in global-map), which is an interactive compiled Lisp function in âfiles.elâ. It is bound to s-s, C-x C-s, <menu-bar> <file> <save-buffer>. (save-buffer &optional ARG) Probably introduced at or before Emacs version 26.1. Save current buffer in visited file if modified. Variations are described below. By default, makes the previous version into a backup file if previously requested or if this is the first save. Prefixed with one C-u, marks this version to become a backup when the next save is done. Prefixed with two C-uâs, makes the previous version into a backup file. Prefixed with three C-uâs, marks this version to become a backup when the next save is done, and makes the previous version into a backup file. With a numeric prefix argument of 0, never make the previous version into a backup file. Note that the various variables that control backups, such as âversion-controlâ, âbackup-enable-predicateâ, âvc-make-backup-filesâ, and âbackup-inhibitedâ, to name just the more popular ones, still control whether a backup will actually be produced, even when you invoke this command prefixed with two or three C-uâs. If a fileâs name is FOO, the names of its numbered backup versions are FOO.~i~ for various integers i. A non-numbered backup file is called FOO~. Numeric backups (rather than FOO~) will be made if value of âversion-controlâ is not the atom âneverâ and either there are already numeric versions of the file being backed up, or âversion-controlâ is non-nil. We donât want excessive versions piling up, so there are variables âkept-old-versionsâ, which tells Emacs how many oldest versions to keep, and âkept-new-versionsâ, which tells how many newest versions to keep. Defaults are 2 old versions and 2 new. âdired-kept-versionsâ controls diredâs clean-directory (.) command. If âdelete-old-versionsâ is nil, system will query user before trimming versions. Otherwise it does it silently. If âvc-make-backup-filesâ is nil, which is the default, no backup files are made for files managed by version control. (This is because the version control system itself records previous versions.) See the subroutine âbasic-save-bufferâ for more information. Thatâs a detailed documentation listing for one little function. Every function in Emacs, contributed by hundreds of volunteers over many years, are (for the most part) self-documenting, which means you can access documentation for virtually every function available in emacs, and there are thousands. As you advance further in your emacs judo, youâll learn how to chain various functions together to build custom functions to speed up your workflow. Show The Emacs Manual For This Command As you proceed on your emacs journey, you will spend a great deal of time running commands upon your text. The most important commands are already bound to certain keys on your keyboard. If there is a command youâre accustomed to running by rote, you may be curious to know the background information about what command. With the F key in the help menu you can instruct emacs to deliver the manual page containing extra information about that command. But first, youâll need the proper name for that command. For example, youâre aware that C-x C-s runs the command to save your buffer. But what is the formal name for that function? Use the key function âc Keysâ mentioned above to get the function name. Now, letâs put that all together. You will use C-h to call the interactive help function followed by F (thatâs a case-sensitive capital âFâ) followed by the command for which you are requesting documentation. The Information In emacs, documentation is everything. And everything is documented. Emacs ships with a lot of written material that you can refer to at any time while working in emacs. You can peruse all of this documentation using âInfoâ mode. Info mode, like other modes in emacs, comes with its own set of key commands for movement and processing. Hereâs some free advice. When starting with emacs, spend a great deal of time in info mode. You wonât regret it. Over many years of learning emacs, youâll always find something new and fascinating behind the scenes. Info mode describes every aspect of the program itself and includes loads of other documents describing various features and modes. In order to enter info mode, type C-h i. When you first arrive, I recommend reading the info manual to learn how to navigate info mode. It should be the first link âInfoâ in the main menu. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles Emacs Web Mode For Code Mastery Choosing Emacs vs. Vim Using Key Commands in Emacs Using Emacs Tramp For SSH (Emacs SSH) Emacs Auto Save and Auto Revert Modes For File Recovery CamelCase Code Helpers in Emacs Be Case Sensitive With Case Conversion in Emacs Emacs Keyboard Macros To Speed Up Your Workflow How To Install Emacs on Ubuntu 20 Cloud Server Save Keyboard Macros as Functions in Emacs