The Top 15 GNU Emacs Interview Questions for Developers

This FAQ is maintained as a part of GNU Emacs. If you find any errors, or have any suggestions, please use M-x report-emacs-bug to report them.

This is the version of the FAQ distributed with Emacs 29. 2, and mainly describes that version. Some information about older versions is still there, but information about very old releases that are now only interesting for historical reasons has been taken out. If you’re interested, you can look at either the FAQ that came with older versions of Emacs or the history of this document in the Emacs source repository.

This FAQ is not updated very frequently. When you have a question about Emacs, the Emacs manual is often the best starting point.

Copyright © 2001–2024 Free Software Foundation, Inc. Copyright © 1994–2000 Reuven M. Lerner Copyright © 1992–1993 Steven Byrnes Copyright © 1990–1992 Joseph Brian Wells.

This chapter describes notation used in the GNU Emacs FAQ, as well as in the Emacs documentation. If this is your first time reading the FAQ or if you don’t understand some of the notation or terms used in it, this section can help.

GNU Emacs is one of the most popular and powerful text editors used by developers today. As an extensible customizable, and portable editor Emacs provides a lot of advantages for programmers.

If you have an interview coming up for a developer role where Emacs proficiency is required, you’ll want to brush up on your Emacs knowledge. Here are 15 common Emacs interview questions you may encounter:

1. What is GNU Emacs and what are some of its key features?

GNU Emacs is a free, open source text editor that runs on many operating systems. Some of its key features include

  • Extensibility – Emacs can be extended and customized using the Lisp programming language, This allows developers to add new features and functionality to meet their needs,

  • Customizability – Users can customize Emacs by modifying settings, key bindings, color themes and more to create their ideal editing environment.

  • Portability – It runs on many operating systems including Linux, Windows, and macOS. This consistency is helpful for developers working across different machines.

  • Programmer-friendly – It offers many features useful for programmers including syntax highlighting, code folding, integrated debugging, and the ability to compile, execute and test code from within the editor.

2. How is Emacs different from other text editors like vi?

The key difference between Emacs and other text editors like vi is that Emacs is far more extensible and customizable due to its implementation in Lisp. Emacs’ scriptability allows it to be modified and enhanced in ways that would be difficult or impossible in other editors.

Emacs also provides more out-of-the-box functionality for programmers including built-in debugging, project management, and many programming language modes. Vi is more lightweight and faster, but less full-featured.

3. What are buffers, windows, and frames in Emacs?

  • Buffers hold the text being edited in Emacs. You can have multiple buffers open at once.

  • Windows provide different views of buffers. You can have multiple windows open on the same buffer to view different parts of it.

  • Frames are like windows but exist as separate entities under windowing systems like X or macOS. Frames are visually and functionally separate while windows split the same visual space.

4. How can you open and save files in Emacs?

The main commands for opening and saving files in Emacs are:

  • C-x C-f – Open a file into a buffer to edit it.

  • C-x C-s – Save the current buffer to its file on disk.

  • C-x s – Save all modified buffers to their files.

5. What are some commonly used Emacs navigation and editing commands?

Here are some basic navigation commands in Emacs:

  • C-f – Move forward one character
  • C-b – Move backward one character
  • M-f – Move forward one word
  • M-b – Move backward one word

And some basic editing commands:

  • C-d – Delete next character
  • DEL – Delete previous character
  • M-d – Delete next word
  • M-DEL – Delete previous word
  • C-k – Delete line from cursor

6. How can you undo changes and navigate between changes in Emacs?

The C-/ command undoes the last change made to a buffer. You can repeat it to continue undoing changes, allowing “infinite undo”.

C-g C-/ will redo a change that was undone, reversing the undo command.

7. What is the mark and region in Emacs? How are they used?

The mark and region allow you to select a portion of text for operations like copying, cutting, and deletion.

To set the mark, use C-SPC at one end of the desired region. Then move to the other end and perform a command like M-w to copy the selected text. The area between point and mark is called the region.

8. How can you use the Emacs help system?

Emacs has extensive documentation and help built-in, accessible via C-h commands:

  • C-h ? – Show all help commands
  • C-h k – Describe function of keybinding
  • C-h f – Describe Emacs function
  • C-h a – Search commands by name
  • C-h i – Enter Emacs info documentation browser

9. What are some useful customization options in Emacs?

Some frequently customized options include:

  • Key bindings – Change key bindings using global-set-key
  • Color theme – Customize colors and font faces
  • Packages – Add new functionality by installing packages
  • Preferences – Customize preferences like fonts, tab width, etc.
  • Startup – Control files, modes, and scripts to load on startup

10. How can you evaluate Elisp code interactively in Emacs?

You can evaluate Elisp code interactively in Emacs with the M-: command.

Type M-: to open the minibuffer, then type your Elisp code and press enter to evaluate it.

For example, (+ 2 3) would insert the result 5 into your buffer.

11. What are some commonly used modes in Emacs?

Some commonly used modes include:

  • Text modes like Markdown and LaTeX for writing documents
  • Programming language modes like python-mode and go-mode
  • Shell mode for interacting with the system shell
  • Org mode for notes, tasks, and project planning
  • Dired mode for file management
  • Info mode for browsing documentation

12. How do major and minor modes work in Emacs?

Major modes adapt Emacs for editing particular types of files like code, text, or HTML docs. Only one major mode is active at a time.

Minor modes provide supplemental functionality that can be toggled on and off as needed, like visual line wrapping or syntax highlighting. Multiple minor modes can be active simultaneously along with a major mode.

13. What is the difference between a command, key binding, and function in Emacs?

  • Commands are actions invoked by users, like copy or save.
  • Key bindings associate commands with keystrokes.
  • Functions are the underlying Elisp code that implements the commands.

So a function defines the behavior, which is bound to keys as a command that users can invoke.

14. How can you write an Elisp function to extend Emacs?

Here is one way to define a simple Elisp function:

elisp

(defun my-hello-world ()   "Prints Hello World"  (interactive)  (message "Hello World!"))

To use it, call M-x my-hello-world. The (interactive) marks it as user-callable.

15. How does the init file work? What might you configure in it?

The init file .emacs or .emacs.d/init.el runs on Emacs startup to configure settings and preferences.

Some common configurations include:

  • Setting themes and UI preferences
  • Rebinding keys
  • Installing packages
  • Setting up programming modes
  • Adding personal code snippets and functions

It allows you to customize Emacs automatically on startup.

Summary

Emacs is a deep editor with many built-in features. Preparing thoughtful answers to questions like these will show your comfort and experience with this powerful tool. Both theoretical knowledge and practical configuration tips are important.

Some time spent hands-on practicing Emacs skills you may need to demonstrate during coding interviews can help boost your confidence. With its flexibility and customization, Emacs is a great editor to add to your developer toolkit.

11 Dired says, ‘no file on this line’ when I try to do something.

Dired uses a regular expression to find the beginning of a file name. In a long Unix-style directory listing (‘ls -l’), the file name starts after the date. The regexp has thus been written to look for the date. By default, it should be able to understand dates and times in any language. However, if your directory listing is formatted in a way that makes it hard for Dired to understand,

There are two approaches to solving this. The first one involves setting things up so that ‘ls -l’ outputs a more standard format. See your OS manual for more information.

The second approach involves changing the regular expression used by dired, directory-listing-before-filename-regexp.

37 How do I disable backup files?

You probably don’t want to do this, since backups are useful, especially when something goes wrong.

Add the following to your init file (see How do I set up an init file correctly?) to load dired-x and stop seeing backup files and other “uninteresting” files in Dired:

With dired-x loaded, C-x M-o toggles omitting in each dired buffer. You can make omitting the default for new dired buffers by putting the following in your init file:

Don’t want to see backup files every time you type “ls” in the Unix shell? Try GNU ls with the “-B” option. GNU ls is part of the GNU Fileutils package, available from https://ftp. gnu. org and its mirrors (see Where can I get other up-to-date GNU stuff?).

To disable or change the way backups are made, see Backup Names in The GNU Emacs Manual.

You can control where Emacs puts backup files by customizing the variable backup-directory-alist. Based on the value of this variable, backups of files whose names match certain patterns should be stored in certain directories. A typical use is to add the element (“. ” . dir) to force Emacs to put all backup files in the directory dir.

Interview with a GNU/Linux user – Partition 1

FAQ

What is Emacs used for?

Emacs is a text editor designed for POSIX operating systems and available on Linux, BSD, macOS, Windows, and more. Users love Emacs because it features efficient commands for common but complex actions and for the plugins and configuration hacks that have developed around it for nearly 40 years.

What is the difference between Emacs and Vim?

The main difference between Emacs and Vim is that Emacs is an extensible, customizable text editor with a long history. At the same time, Vim is a highly configurable text editor based on the Vi editor. Emacs includes syntax highlighting, a large library of extensions, and a powerful command-line interface.

Is Emacs still good?

Still useful after all these years. Emacs is utilized as one of the primary text editors available for global use across our remote build servers.

What is Emacs best for?

Emacs is a programming language interpreter disguised as a text editor. The language it interprets is called Emacs Lisp. The best feature of Emacs is its extensibility. If you can’t find a package that does exactly what you want, you can write one yourself!

What is GNU Emacs?

You are reading about GNU Emacs, the GNU incarnation of the advanced, self-documenting, customizable, extensible editor Emacs. (The ‘ G ’ in GNU (GNU’s Not Unix) is not silent.) We call Emacs advanced because it can do much more than simple insertion and deletion of text.

How do I use emacs?

Use GNU Emacs Use GNU Emacs The Plain Text Computing Environment Using Emacs is kind of like making a piece of art. You start with a big blockand you slowly chip away, bringing it closer and closer to what you want.

Who wrote GNU Emacs?

GNU Emacs was written by Richard Stallman, the main author of the original TECO Emacs. For an editor to be called “emacs” the main requirement is that it be fully extensible with a real programming language, not just a macro language. For GNU Emacs, this language is Lisp.

Does EMACs have a Documentation Reader?

Info: The Emacs Documentation Reader Emacs has a built-in documentation reader called Info. It dates from1985 and actually predates GNU Emacs (it was present in ITS TECOEmacs) and was one of the earliest freely available hypertextsystems,predating the World Wide Web by about fourteen years years.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *