Emacs - 6 Productivity Tricks

Earlier, I wrote about using Emacs as a C ++ IDE and other technical equipment . However, I did not pay much attention to the fact that I use Emacs and to work with a lot of other things. Honestly, I could not use this editor to the full if it were not for the features that I will share here. I will also talk about the settings that I used in my environment to run all this out of the box (literally, copying .emacs).

To get started


tl; dr: Those who are especially impatient can skip this section and go straight to Helm settings.
I have Emacs - 26.1 installed, compiled from source. You do not need it. All packages will be installed from the Emacs package manager. Run:

M-x list-packages

You will see a list of available packages in MELPA . Don’t worry if you haven’t heard of this, it’s something like a repository of all add-on packages, as in the Debian repository in Debian / Ubuntu distributions. Thus, we have a long list of available packages, as in the GIF:



If you select a package, a new screen will appear with a short description. Usually it contains instructions for a quick start. You can just press i , then x to install the package. You can do the same with the packages below.

Helm


If you still do not know what it is - drop everything and pay attention to it. Most likely, it's worth it. I don’t think that any explanations will be required, a description from the official website is enough :
“Helm is an Emacs framework, incremental search and autocompletion for file names, buffer names, and other actions that require selecting an item from a list of possible options”

Demo




(require 'helm)

(setq-default helm-M-x-fuzzy-match t)
(global-set-key "\C-x\C-m" 'helm-M-x)
(global-set-key "\C-c\C-m" 'helm-M-x)
(define-key evil-ex-map "x" 'helm-M-x)

(define-key evil-ex-map "b " 'helm-mini)
(define-key evil-ex-map "e" 'helm-find-files)

Evil mode


EVIL stands for Extensible VI Layer for Emacs. This is obviously a big controversial topic, moving away from the purist user scenario for using Emacs. Honestly, there is no such scenario. In my opinion, the power of Emacs comes primarily from being able to turn it into anything. I grew up when there was nothing but vi, it was used by me quite a bit, but I did a good job.

“Approved by your orthopedist”


Using the Emacs, I regularly skipped the command keys, and all because of the fact that I'm typing terribly slow, at least in comparison with the real masters , with whom I met .

Activate Evil Mode:

(require 'evil)
(evil-mode 1)

;;;; define shortcuts for powerful commands
;;;; these can be invoked vim-style 
;;;; Esc-:<single_key_from_below>
(define-key evil-ex-map "b " 'helm-mini)
(define-key evil-ex-map "e" 'helm-find-files)
(define-key evil-ex-map "g" 'helm-projectile-grep)
(define-key evil-ex-map "f" 'helm-projectile-find-file)

;;;; I wept with joy about this in:
;;;; http://www.mycpu.org/emacs-24-magit-magic/
(define-key evil-ex-map "m" 'magit-blame)

Helm-projectile


I don’t understand why people still don’t run down the street, clutching their heads and maddened with joy - this is what I experience using the Helm-Projectile. Github

Demo




(require 'helm-projectile)
(define-key evil-ex-map "g" 'helm-projectile-grep)
(define-key evil-ex-map "f" 'helm-projectile-find-file)

Doom-themes


Here we will focus on aesthetics, and this is a subjective thing. So if you are happy with everything anyway, scroll down, but if you are impressed with the images above, then this information is for you.
Doom Themes helped me make the editor look more modern. From time to time, colors made me sad (a moment of psychoanalysis), so I started looking for the “same theme” for Emacs. I used zenburn for a long time , but then I realized that I really like the contrast font, but a little less flashy and sharp. Check out Doom Themes, especially doom-molokai , which is very similar to the modern Atom IDE . The minimum required configuration is presented below. I use its modified version that I stole from the Internet.

(require 'doom-themes)

(require 'indent-guide)
(indent-guide-global-mode)
(set-face-background 'indent-guide-face "dimgray")

;; Global settings (defaults)
(setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
      doom-themes-enable-italic t) ; if nil, italics is universally disabled

;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each
;; theme may have their own settings.
(load-theme 'doom-molokai t)

;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)

;; Enable custom neotree theme
(doom-themes-neotree-config)  ; all-the-icons fonts must be installed!

(require 'doom-modeline)
(doom-modeline-mode 1)

Rtags


Let me remind you that I already wrote a couple of posts about rtags: here and there .

Reading Emacs Mail with MU4E


Deserves a separate post, as it requires a non-trivial configuration. At least in my case. The lack of email clients for Emacs really upset me at the time (Gnus, sorry). Apparently, I was not alone in this, and someone else, fortunately, more smart and experienced than I, filled this gap. mu4e, along with offlineimap, became for me a solution for writing letters in the editor, which pleases me to this day.

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


All Articles