📜 ⬆️ ⬇️

Emacs starter kit

Emacs Large and complex program. This definition suits him like nothing else. Emax was created a long time ago in the laboratory of artificial intelligence MIT, it carries the genes of a very peculiar culture of Lisp hackers of bygone days. Since then, he has repeatedly corresponded, improved, supplemented and acquired over thousands of extensions over decades. Emax, if it was once a powerful text editor, has now become a kind of universal program, you can do absolutely anything in it, if it at least slightly affects the task of displaying or editing text, and even more. People who know universality play into the hands, because with one program you can do a thousand different things, without making efforts to retrain to different interfaces. People who first launched Emax like this versatility and unusual interface are scary at first. To learn how to use emax, to understand his idea and to penetrate it is a difficult, time consuming and long task (as they say, a gentle learning curve).

Parting words to novice users of this kind are unlikely to inspire them with enthusiasm, rather the opposite, but ... the road will be mastered and the main thing is to start here — often emax becomes something like a toy.


1.1 Setup


Setting up an emax is a kind of arts and crafts, it is both a blessing and a curse of the user. In contrast
from vi , the main charm of which, in my opinion, is that everything in it “out of the box” is perfectly tuned — take it and use it, max in
its out of the box condition is far from as good and comfortable as it could be. From the very first launch, an epic begins — an emacser sharpens the editor for himself, puts extensions, gets his configuration files, looks at code bits from others, collects his own settings all over the network — bit by bit, a decent code base accumulates over time. And everything would be fine, but the process of fine-tuning to a more or less usable state is very long — it can take months and even years (in fact, the emax setting never stops).


1.2 Find


All the time that I used emax I did just that: collecting a config in pieces from thousands of different places — forums (mostly ENT ), habr , emax-wiki , articles, repositories with advanced user settings (mainly Alex Ott ), etc. As a result, the config has grown and turned into a terrible mess. In general, everything was bad until I came across a wonderful screencast Meet Emacs from Peepcode . In the screencast, the author is not zealous with the basic setting, and immediately after installing the emax, copies the emacs-starter-kit repository to its .emacs.d directory. At first, I was skeptical of this approach, but after trying the starter kit once, removing it, and trying it the second time, I got into it: it turned out to be enough just to use emax without thinking about its major improvements. All I have left is to install the extensions I need through the package manager of the emax and the operating system, and add the font and keyboard settings for the netbook and the desktop computer.
')

2 Emacs Starter Kit


The original Emacs Starter Kit (now the “central repository” of it on github.com ) is Phil Hagelberg aka Technomancy’s personal config, which he collected during his many years of using emax. Now the kit is hundreds of forks of the repository and thousands of people following it on the githaba.

The Starter Kit is designed for easy extensibility by user settings and for easy portability of a single configuration between user machines — so owners of several computers should like it.

Work requires GNU Emacs version 22 or higher. With fork like XEmacs will not work.


2.1 Installation


Installing the Emacs Starter Kit is simple: clone the repository from the github into the .emacs.d directory (after saving your old settings and deleting .emacs ):

  git clone http://github.com/technomancy/emacs-starter-kit.git ~ / .emacs.d

Voila Launch Emacs.

To run the emx with the kit, look at — clone the repository into some other directory and start the emx with the command:

  emacs -q -l ~ / emacs-starter-kit / init.el


2.2 Device


There are several main files in the .emacs.d kit directory:

  .emacs.d /
   ...
   elpa /
   init.el
   starter-kit-bindings.el
   starter-kit-defuns.el
   starter-kit-elpa.el
   ...
   ... and custom
   ...
   haru.el
   haru /
     color-theme.el
     info.el
     irc.el
     jabber.el
   haru-desktop.el
   harubook.jolicloud-domain.el

The most important file is init.el , the download starts from it. It disables the GUI, loads the ELPA package manager, and, when it is first started, it installs several useful packages from the network (of course, you can also automatically install your favorite packages).

The following files are loaded starter-kit-*.el — they contain various additional functions, settings for key combinations and modes for some dynamic languages ​​— in general, everything that makes e-mail more convenient than the default.

User files are last loaded:


2.3 features


2.3.1 Emacs Lisp Package Archive


Package Manager for Emax. Already, in more than a hundred popular extensions, it automatically maintains dependencies between them. Elementary to use: Mx package-list-packages , i — mark to install, x — install. Packages are installed in the ~/.emacs.d/elpa .

ELPA

To automatically install the necessary packages when you first start emaks, you need to edit the starter-kit-packages variable in the starter-kit-elpa.el . For example, I have nothing without Clojure , and I actively use the service gist.github.com :

  (defvar starter-kit-packages (list 'idle-highlight' ruby-mode
   'clojure-mode' clojure-test-mode 'swank-clojure' slime 'slime-repl
   'inf-ruby' css-mode 'yaml-mode' magit 'gist))

The Starter Kit has been developing for a very long time, and from elpa-to-submit/ it happens that the code of some packages is deleted, but this is nothing — the remote code flows into ELPA. If there is a problem with the next update (I mean pull / merge with the “central” repository), remove everything from the ~/.emacs.d/elpa and run Mx starter-kit-elpa-install .


2.3.2 IDO


The ido mode is wherever needed — when switching buffers, opening and saving files and so on, in the minibuffer it greatly facilitates the choice of options.

ido-find-file

Another terribly convenient feature — imenu, allows you to jump to the definition of a symbol in the source, called by Cx i or Cx Tab

ido-imenu


2.3.3 iBuffer


More functional replacement for standard switch buffers.

ibuffer


2.3.4 Side Strip


Strip on the side, showing the end of the buffer. Very comfortable.


2.3.5 Editing under sudo


I don’t know if I’m the only one, but before I had to run vi under sudo specifically for editing system files. The kit has a function Mx sudo-edit.


2.3.6 Lambda


Lambda in lispokoda are displayed in Greek letters λ. Only yesterday a replacement of fn by ƒ was added in the Clojure sources.

fn-in-clojure


2.3.7 Improvements in dynamic language modes


Many different amenities for users of dynamic languages: JavaScript, Emacs Lisp, Clojure, Common Lisp, Ruby, Perl. I mostly use lisps, so I’ll bring some improvements in lisp modes.

First of all it is, of course, paredit-mode — structural editing mode of the Lispod. Simply put, it arranges, rearranges, and deletes parentheses, taking into account the semantics of the code. It is possible that it will not be possible to master it right away, because this mode is made in the best traditions of emax with a good dozen furious combinations, but after prolonged use and habituation it will not be easy without it.

Displays the arguments of the Emacs Lisp functions in the minibuffer.

show-elisp-args


2.3.8 Disabled GUI


No scrollbar, no toolbar, no menu, no dialog boxes. All this is not there, for the economy of movement is our all. Graphic controls require a mouse, and in order to reach the mouse you need to take your hand off the keyboard, in the case of the menu you have to spend a lot of time searching for the desired item. From the fact that these controls are disabled — they won’t be removed from the user — the functionality of the disabled elements is duplicated in the interface. During editing, if a menu is used, then it is a menu of current modes, and they are available in the modeline bar. The scrollbar is beautifully replaced by standard keys for moving around the buffer and mouse wheel. A toolbar is simply not needed — it is easier to perform any action through keybinding.


2.3.9 Shortcut Keys


Honestly, the keyboard shortcuts in the Emacs Starter Kit I don’t really like, especially since they are not very different from the standard ones. So I will give some of my combinations (which can be found in the file starter-kit-bindings.el in my starter-kit-bindings.el on the github: http://github.com/zahardzhan/emacs-starter-kit ).

First, however, it is worth remembering that Emacs is the oldest living software that is widely used today, and original keybinding software is not designed for modern PC / Apple / ... keyboards, but for the keyboard of the dead 20 years ago (for example, in the manual by Zmacs for Ti Explorer 1985 you can find the same combinations that are used now). Recall and take action, otherwise the unlucky emaxer runs the risk of becoming a victim of the “little finger emax” syndrome — due to the active use of the Control key, which on modern keyboards is terrible as it is inconvenient to press several hundred times an hour. There are many ways to keep your hands healthy:


So, I will tell about some of my combinations:

Cm
Alternative to the Enter key. The combination is especially useful as an ending in a chain in which all keys are pressed together with Control 'to keep it from going and reach for Enter , for example, I switch between buffers without even pressing Control : C-Tab Cs Cs Cs Cm . This combination is also useful as a replacement for Mx : Cx Cm , if it takes a long time to reach the viola.

Cw
In almost all terminal emulators, this key deletes the word to the left of the cursor, but it does nothing good in the emax. I zabindil on her deleting the word back and cutting out the region, if it is selected — it is very convenient, Backspace is practically not needed. To all, Mw copies the selected region.

Cg
Forget about Esc . If something went wrong — this is the universal cancel key.

Cq
Replacing C- / . Cancel editing. Thus, a series of combinations, which in the standard window systems is located below — Cz, Cx, Cc , I move up — Cq , Cw, Mw . (If someone tells me how to combine this key with Cg — I will be very grateful).

C-tab
Usually I keep a lot of buffers and often switch between them. Press Cx b with two hands to do this, an incredible extravagance.

S-Tab, CS-Tab
Switch to the next / previous window. Quick and convenient. Thus, three keys, located closely one-over-another, are used to switch between buffers.

Cx ck
Killing a buffer is much easier without releasing the Control key — so you can kill several buffers at once faster.

Cs, Cr
These keys are tied to the search for regexp forward and backward. I remember one of the Macintosh authors, Jeff Raskin, put a similar search into the basis of the computer interface for working with the text Cannon Cat. This is of course not Cannon Cat, but nothing, either.
These keys are used not only for searching in the buffer, but also for moving to the next / previous element in the minibuffer in ido mode — for switching between buffers or for searching and opening a file. And in the selection of the region.

S-space
Very smart autocompletion. Sometimes it’s enough just five times to press this combination and the program will wonderfully write itself.

M-Space
Switch between languages. Two easily accessible, closely spaced keys are the best option.

F3, F4, F4
Start of macro recording, end of macro recording, macro call.

In general, if you use Emax, I highly recommend putting on the Emacs Starter Kit — you can even use Emax with it :)

The literary version of the program Emacs Starter Kit, see my blog .

Source: https://habr.com/ru/post/94256/


All Articles