Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/64j0/emacs-config

This repository is used to store my personal emacs configuration file.
https://github.com/64j0/emacs-config

emacs lisp

Last synced: 2 days ago
JSON representation

This repository is used to store my personal emacs configuration file.

Awesome Lists containing this project

README

        

#+TITLE: My Personal .emacs Config
#+AUTHOR: Vinícius Gajo Marques Oliveira
#+DATE: [2022-08-01 seg]

According to the official docs, ~Emacs~ is an extensible, customizable,
free/libre text editor - and more. *Much more!*

At its core is an interpreter for *Emacs Lisp*, a dialect of the Lisp
programming language with extensions to support text editing.

Reference: [[https://www.gnu.org/software/emacs/][Emacs website]].

* Installation

** Debian: Install using ~apt~

~apt~ is the package manager available for Ubuntu Linux (Debian based OS). To
install Emacs using this package manager is pretty straigh forward:

#+BEGIN_SRC bash :tangle no
sudo apt install emacs
# uninstall with
# sudo apt remove emacs
#+END_SRC

** Install Using Terminal

You can find the Emacs versions in this [[https://www.gnu.org/software/emacs/][link]].

#+BEGIN_SRC bash :tangle no
# download emacs version 29.4
export EMACS_VERSION="29.4"
wget https://ftp.gnu.org/pub/gnu/emacs/emacs-${EMACS_VERSION}.tar.gz

# extract the content
tar xvzf emacs-${EMACS_VERSION}.tar.gz
cd emacs-${EMACS_VERSION}/
./configure
make
sudo make install
#+END_SRC

*** Uninstall

+ Reference: [[https://askubuntu.com/questions/377245/how-to-completely-remove-my-emacs][link]].

#+BEGIN_SRC bash :tangle no
# download emacs version 28.2
export EMACS_VERSION="28.2"
wget https://ftp.gnu.org/pub/gnu/emacs/emacs-${EMACS_VERSION}.tar.gz

# extract the content
tar xvzf emacs-${EMACS_VERSION}.tar.gz
cd emacs-${EMACS_VERSION}/
./configure
sudo make uninstall
#+END_SRC

* Package Management

In order to have a more reliable packages configuration, instead of using
~package.el~, I decided to use ~straight.el~: "next-generation, purely
functional package manager for the Emacs hacker".

One can find the project repository in this [[https://github.com/radian-software/straight.el][link]].

Also, there is this cool video from System Crafter regarding this package
manager: YouTube [[https://www.youtube.com/watch?v=UmbVeqphGlc&ab_channel=SystemCrafters][link]].

* Launching Emacs

In my experience I noticed that the Emacs $PATH is different based on how you
launch it. ~This is something I still want to research more to understand.~

But, as a rule of thumb, to avoid major problems, always launch your Emacs
program from a terminal:

#+BEGIN_SRC bash
emacs&
#+END_SRC

How I noticed this?

My LSP in general was very bad. Most of things did not work properly, although I
had the necessary stuff installed. Then, I went to the [[https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/][troubleshooting page in
LSP docs]] and tested my $PATH using ~M-: (getenv "PATH")~.

Later I compared with the value of ~echo $PATH~ from a terminal window, and for
my surprise they were different. Emacs $PATH was lacking several configurations.

** Load Custom Scripts

One can leverage the composibility powers of Emacs to create their own custom
ELisp configuration and decide to load it in the start up process of Emacs. In
order to do it, you can use this function:

#+BEGIN_SRC elisp
(load-file "~/Desktop/codes/custom-emacs/my-cool-script.el")
#+END_SRC

* Learning Emacs

According to [[http://tilde.town/~ramin_hal9001/articles/2022-04-27_best-way-to-learn-emacs.html][this post]], the best way to learn Emacs consists in two things:

1. Read blog posts about how other people use Emacs.
2. Learning how to read the manual.

Notice that this order is actually controversial.

** Emacs distributions

For newcomers, it is usually easier to start using a pre-built configuration
instead of creating one by yourself.

Consider taking a look at those distributions to start your Emacs journey:

+ https://prelude.emacsredux.com/en/latest/
+ https://www.spacemacs.org/
+ https://github.com/rdallasgray/graphene
+ https://github.com/doomemacs/doomemacs

** Some Blogs

Later in this ~README.org~ I cite other cool articles and references. Here I'll
just store the non-exhaustive links mentioned by Ramin in his article.

+ [[https://www.masteringemacs.org/all-articles][Mickey Peterson - Mastering Emacs]]
+ [[https://sachachua.com/blog/][Sacha Chua - Blog]]
+ [[https://systemcrafters.net/][David Willson - System Crafters]]
+ [[https://cestlaz.github.io/stories/emacs/][Mike Zamansky - Blog]]
+ [[https://irreal.org/blog/?tag=emacs][The Irreal Blog]]
+ [[https://protesilaos.com/][Protesilaos Stavrou - Blog]]
+ [[https://karthinks.com/tags/emacs/][Karthik Chikmagalur - Blog]]

** Emacs Manual - Cheatsheet

+ ~C-h i~ - *open the Info-mode* app, which lists a "menu" of all installed
manuals.
+ ~C-h r~ - *read manual*, jumps straight to the Emacs manual table of contents.
+ ~q~ - *quit*, hides the manual and goes back to where you were before reading
the manual.
+ ~C-h v~ - display documentation of variable.
+ ~C-h f~ - display documentation of function.

Those are the points I think are worth knowing, at least in the beginning.

** Other Cool Emacs Links

+ [[https://orgmode.org/worg/org-contrib/org-drill.html#:~:text=Running%20the%20drill%20session][org-drill]] reference for running the drill session. This part of the docs is
very good since it explains what each number means and how to run the session
passing the scope to read our drills.
- Before publishing an org-drill deck we should use ~org-drill-strip-all-data~
to remove personal scheduling data.
- This is currently my favorite tool along with ~org-mode~.
+ [[https://lucidmanager.org/productivity/emacs-bibtex-mode/][Emacs and BibTeX]]
+ [[https://leanpub.com/lisphackers/read][(Book) Lisp Hackers]]
+ [[https://github.com/MatthewZMD/.emacs.d][MatthewZMD/.emacs.d]]
+ [[https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/guide-en.org][redguardtoo/mastering-emacs-in-one-year-guide]]
+ [[https://planet.emacslife.com/][Planet Emacslife]]
+ [[https://emacs-lsp.github.io/lsp-mode/][LSP Mode - Language Server Protocol support for Emacs]]
+ [[https://github.com/daviwil/emacs-from-scratch][daviwil - Emacs From Scratch]]
+ [[https://www.oreilly.com/library/view/writing-gnu-emacs/9781449395056/][(Book) Writing GNU Emacs Extensions]]
+ [[https://www.labri.fr/perso/nrougier/GTD/index.html][Nicolas P. Rougier - Get Things Done with Emacs]]

**** Articles

+ [[https://www.aidanscannell.com/post/org-mode-resume/][Creating a CV/Resume in Org-Mode using LaTeX Templates]]
+ [[https://www.fugue.co/blog/2015-11-11-guide-to-emacs.html][Fugue - A CEO's guite to Emacs]]
+ [[https://www.fugue.co/blog/2018-08-09-two-years-with-emacs-as-a-cto.html][Fugue - Two Years With Emacs as a CEO (and now CTO)]]
+ [[https://a-nickels-worth.blogspot.com/2007/11/effective-emacs.html][A Nickel's Worth - Effective .emacs]]
+ [[https://coredumped.dev/2022/05/19/a-vision-of-a-multi-threaded-emacs/][Core Dumped - A vision of multi-threaded Emacs]]
+ [[http://tilde.town/~ramin_hal9001/emacs-for-professionals/index.html][Emacs for Professionals]]
+ [[http://steve-yegge.blogspot.com/2008/01/emergency-elisp.html][Stevey's Blog Rants - Emergency Elisp]]
+ [[http://www.paulgraham.com/wealth.html][Paul Graham - How to Make Wealth]]
+ [[http://www.paulgraham.com/taste.html][Paul Graham - Taste for Makers]]
+ [[http://www.paulgraham.com/avg.html][Paul Graham - Beating the Averages]]
+ [[http://www.paulgraham.com/icad.html][Paul Graham - Revenge of the Nerds]]
+ [[https://tuhdo.github.io/c-ide.html][C/C++ Development Environment for Emacs]]

** Update packages

First, you need to run ~M-x list-packages~, then hit capital "u" (~U~), and
finally "x" to execute the update.

There are packages created automatically to do this update for us automatically
(~auto-package-update~, for example), but in my case I don't want to use it,
since I want to have more control over this process.

I found this trick watching this video from System Crafters:

+ [[https://www.youtube.com/watch?v=dtjq68F2dXw&ab_channel=SystemCrafters][Keeping Your Emacs Packages Up To Date - Emacs From Scratch #11]]

** Emacs Modes

#+BEGIN_QUOTE
Each kind of editor is an Emacs mode, a chunk of Lisp code that combines Emacs's
primitive types and operations in some new way. Each mode is therefore an
extension of Emacs, which means that when you strip away all those modes — when
you remove the extensions and you're left with just the core of Emacs — you
don't have any editors at all; you have the raw materials for making
editors. You have an editor-builder.

What can you build with an editor-builder? Editors, of course, but what's an
editor? An editor is a program for viewing and altering a representation of data
of some kind. By "representation" I mean a set of rules for showing the data's
structure and content, and for indicating naturally how interactions with the
data are supposed to proceed. When editing a text file, the rules are pretty
simple: each printable byte gets displayed in sequence, with newline characters
causing line breaks; and a cursor indicates where in the byte sequence the next
user-invoked operation will occur. When editing a directory, the metaphor is a
little less straightforward—data in the directory file must first be translated
into a human-readable form—but the resulting interactions still seem natural.

--- (Book) Writing GNU Emacs Extensions
#+END_QUOTE

* Learning Elisp - Emacs Lisp

Since Emacs could be configured using Elisp it is totally useful to learn this
programming language in order to create new functionalities or even get more
familiar with this tool.

In order to learn this I'm currently using this reference: [[https://www.gnu.org/software/emacs/manual/eintr.html][(Book) Introduction
to programming in Emacs Lisp]].

After finishing this first book, I plan to read [[https://github.com/norvig/paip-lisp][Paradigms of Artificial
Intelligence Programming: Case Studies in Common Lisp]].

There is also this reference for GNU Emacs extensions (written in 1997 btw):
[[https://www.amazon.com/Writing-GNU-Emacs-Extensions-Glickstein/dp/1565922611][Writing GNU Emacs Extensions]].

If you'd like to jump into exercises, check this [[https://exercism.org/tracks/emacs-lisp][Exercism track]].

** Emacs Lisp Code Tips

In this section I'm going to add some links for useful resources that can help
you in this journey.

+ [[https://github.com/bbatsov/emacs-lisp-style-guide][Emacs Lisp code style guide]]
+ My submissions in the Exercism Emacs Lisp track: [[https://github.com/64J0/Exercism-Emacs-Lisp][link]]

About the project structure (along with some comments):

+ [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Simple-Packages.html][Simple Packages]]
+ [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Headers.html][Conventional Headers for Emacs libraries]]