Best emacs modes

The lisp init codes must be inserted in your ~/.emacs.

Enable melpa

I will need some community package.

;; package
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)

Pretty emacs (both in melpa)

My favourite emacs theme is in melpa: leuven-theme. For vim powerline bar, I use spaceline (a spin-off of spacemacs without the vim keys settings)

M-x list-packages

Then click to:
- install leuven-theme
- install spaceline

;; spaceline config
(require 'spaceline-config)
(spaceline-emacs-theme)

org-mode settings

For your journal and gtd

(global-set-key "\C-cc" 'org-capture)
(setq org-directory "~/org")
(setq org-capture-templates
      '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
         "* TODO %?\n  %i\n  %a" :prepend t)
        ("j" "Journal" entry (file+datetree "~/org/journal.org")
         "* %?\nEntered on %U\n  %i\n  %a")))

Minted for code formating

pdf production by org-mode export

Minted is a latex package using pigmentize for rendering code. As it needs to run external program in the latex compilation, some settings are necessary pdf production.

(setq org-latex-listings 'minted)
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-minted-options
       '(("frame" "lines")
;;      ("fontsize" "\\scriptsize")
         ("linenos" "")))

;; at least two compilations for the toc
(setq org-latex-pdf-process
’(“pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f”
PDFLATEX=\”pdflatex -shell-escape -interaction nonstopmode -output-directory %o\" texi2dvi -p %f")

;; “pdflatex —shell-escape -interaction nonstopmode -output-directory %o %f” ;; “pdflatex —shell-escape -interaction nonstopmode -output-directory %o %f”) )

I prefer to use latex-make with custom pdflatex options

I export in latex and compile with latex-make. My Makefile is thus

PDFLATEX_OPTIONS=-shell-escape
include LaTeX.mk

It is possible to combine org-mode export and pdflatex compilation.

My makefile look like:

PDFLATEX_OPTIONS= -shell-escape
LU_MASTER= mydocument
include LaTeX.mk
mydocument.tex: mydocument.org
	emacs --visit=$< --batch -f org-latex-export-to-latex --kill	

Grammar correcion with languagetool

LangagueTool must be installed (in /usr/local/ if not available in your distribution)

(require 'langtool)
(setq langtool-language-tool-jar "/PATH/TO/languagetool-commandline.jar"
      langtool-mother-tongue "fr"
      langtool-disabled-rules '("WHITESPACE_RULE"
                                "EN_UNPAIRED_BRACKETS"
                                "COMMA_PARENTHESIS_WHITESPACE"
                                "EN_QUOTES"))

My favorite standard packages

- auctex (latex)
- ede (programmation in C/C++)
- semantic (programmation in C/C++)
- ido
- recentf
- auto-complete
- magit
- helm
- pdf-view

and of course

(setq c-default-style "linux")

Why this page anyway ?

I am very happy when my students use vim. But some of my students write programs with under-powered text editors (The names of some of them end with “edit”). I want to write why I am annoyed by this situation.

You are mising some subtle help you do not even know about

search and replace

Let us look at the search and replace. Nothing can surprise you there. Really ?
Let us change some “toto” string with “tata” string (toto → tata).

toto toto toto Toto toto TOTO toto

Using the standard search-and-replace, you got in emacs

tata tata tata Tata tata TATA tata

Search-and-replace keeps the upper-lower case by defaut !.

Semantic format and decoration

Emacs (vim too), knows your programming langage syntax. Thus it is able to indent the code correctly, even when displacing a bloc, even when adding a new loop or a branch.

You have thus an immediate feedback on mis-inserting anything (comma, parenthesis, square or curly bracket). You gain time at writing, and compiling, and debuging.

Emacs: open mind text editor

I am an emacs user for years. In fact, I start my unix journey by using vi in the terminal application of some aging Atari 520ST of my university. The terminal were connected to some SQL databases on UNIX servers elsewhere on the campus. Then I used emacs, Xemacs, axe, textedit and never stop to try among the time plenty of great editors like qtcreator, code block, eclipse, netbeans, atom…

After some time, I always turn back to emacs. I never really understand why before Arnaud Legrand demonstrates org-mode usage in a team seminar.

Emacs power is not the up-to-date fancy graphics of SublimeText, neither the large set of helpers in Java programming of Eclipse. It is the great support of numerous languages.

How many programming languages are useful ?

In my humble opinion, all of them: programming language, like human language, formats the way of thinking. Using different languages allows variability in the way to express the solution of a problem. One of them is better for one problem. None of them is better for all problems. And, of course, there are numerous “better” utility functions with different results.

My daily languages are:

But I also need on a monthly/yearly basis:

I would like to learn more some languages:

I learned and I would like to forget some others:

Few editors will really help you in all of them. Vim is the other one
I practice.

Org-mode: literate programming

org-mode allows to use all the emacs support for all the languages in
the same document. It is the literate programming of Knuth with two
major additions:
1. document translation/export in various format
2. auto-execution of code and insertion of the results in the document

Use emacs as you use other editors !

- To open a file: in the menu File, click on Open file…
- To save file: in the menu File, click on Save
- To quit: in the meu File, click on Quit

With time, you learn more and more stuff. Emacs will help you to use efficiently all those knowledge in all your langages.