What Makes Emacs Different and Unique
Created On: 2016-07-31 Updated On: 2021-08-11
Emacs is Highly Dynamic
In emacs, every keystroke and command can be customized (redefined) when the editor is still running, including typing characters, pressing arrow keys. Usually in an editor, you would expect typing character and moving cursor via arrow keys to be basic and not customizable. Not in emacs.
In emacs, typing a character most likely runs
self-insert-command. As the
name implies, it just insert the character itself. However, this binding is
fully customizable just like your F6 key or other keys. There is nothing
special for it. And in deed, in some built-in modes, pressing a character no
self-insert-command any more. For example, in
electric-pair-mode, when you insert an open parenthesis, emacs automatically
insert a matching closing parenthesis. When cursor is at a matching closing
parenthesis, typing the closing parenthesis again will just move cursor after
it instead of inserting an additional unwanted one. In viper mode, typing
characters mimics their behavior in the VIM editor, which can do very
different things than inserting characters.
This is all possible because the dynamic feature of the lisp language. Some low level infrastructure of the editor is bootstrapped using C, then everything else is either implemented directly in emacs lisp or is exposed via emacs lisp.
Major modes, minor modes, font faces, keymaps, almost everything defined in
emacs can be redefined on the fly easily. There is even a built-in tetris game
M-x tetris). So you get the idea how dynamic it is.
Text Based System is Powerful
Emacs has many built-in commands for moving cursor and manipulating text. Text, although lacking in multimedia capabilities like HTML, is still a very useful and powerful representation for different things.
There are a few things that are considerably more powerful when run in a text based system like emacs.
For example, running shells. Usually people run dedicated terminal emulators
like rxvt-unicode or Konsole. Those are OK at running commands. But in emacs,
there is a shell mode, which makes the shell's input and output as plain text
in a emacs buffer. Scrolling, searching output, copying, pasting can't be
easier. You have the full power of emacs such as word/path based cursor
movement, input history, path expansion, e.g.
cd /u/loc/bi TAB expanding to
cd /usr/local/bin/. You can query replace substrings. Your abbreviations
will just work. You can run many shells and switch between them the same way
you switch between file buffers.
Another example is bulk file renaming, like removing a common prefix or
renaming all .JPG files to .jpg. In emacs's file manager dired, renaming
multiple files is as easy as editing the filename as text. You can do search &
downcase-word, rectangle editing. Any command that works on regular
text buffer will work there. And full undo history is available as well. When
you save the buffer, the files will get renamed. It's very convenient and
Viewing man page in emacs is also much more pleasant than in terminal. Since
the rendered result is just text, all emacs's search commands are
available. You can use
occur to find specific text or option, you can jump
to man page sections, you can jump to other referenced man pages by clicking
them, you can copy & paste or do cross buffer auto completion in shell
buffer. On regular man command, the rendered result is just piped to less,
which doesn't know about sections and links to other man pages at all.
Writing Email, git commit message, doing git rebase, chatting via IRC, they all have been easier in emacs because of the universal text interface.
Great Extensibility with Great Documentation
Emacs's built-in documentation covers the core editor's features and
programming interfaces very well. That includes the info doc for emacs and
describe-variable facility, which is
C-h f and
C-h v respectively, and the source code (.el.gz) which
is usually quite readable.
To change behavior of existing features, you just write and execute elisp code
inside emacs. When you want to persist a change across restarts, you put them
~/.emacs.d/init.el. To write new features, you can build on top of
existing modes and a large collection of existing functions easily.
Emacs has many useful features during its many years of development. New modes and extensions are also being created from different people in different areas. The most important change for me in recent 2 or 3 years is the huge growth of org-mode and the package system (elpa and melpa). Org-mode is for keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system. The package system allows searching, distributing, installing and removing emacs extensions more easily. It also encourages code reuse. Emerging programming languages usually have an emacs mode to support syntax highlighting and other features, because it is a powerful editor and it is easy to add a major or minor mode.
In comparison, other editors and IDEs usually either lack in extensibility or documentation or both. Emacs is the only editor that I knows that doesn't distinguish between built-in features and user defined features. They are written in the same way, and loaded in the same way. When you add or change something, there is no need to compile it somewhere else or restart emacs. User defined code looks and works just like built-in code. Actually this is a feature of the lisp language. You can think of emacs as an editor DSL on top of emacs lisp. It just makes writing editor and related things easier. Your running emacs instance is just a lisp image that is configured to accept keyboard/mouse events and can load more elisp code.
Emacs is a highly dynamic, easily extensible and well documented text based system with good predefined text editing facilities. There are also bad things on emacs, but I will leave it for another day.