Skip to content

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

Notifications You must be signed in to change notification settings

64J0/emacs-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Personal .emacs Config

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: 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:

sudo apt install emacs
# uninstall with
# sudo apt remove emacs

Install Using Terminal

You can find the Emacs versions in this link.

# 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

Uninstall

# 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

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 link.

Also, there is this cool video from System Crafter regarding this package manager: YouTube 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:

emacs&

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 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:

(load-file "~/Desktop/codes/custom-emacs/my-cool-script.el")

Learning Emacs

According to 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:

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.

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

Articles

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:

Emacs Modes

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

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: (Book) Introduction to programming in Emacs Lisp.

After finishing this first book, I plan to read Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp.

There is also this reference for GNU Emacs extensions (written in 1997 btw): Writing GNU Emacs Extensions.

If you’d like to jump into exercises, check this 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.

About the project structure (along with some comments):