2025-06-25 09:20:32 +02:00
2025-06-25 09:20:32 +02:00
2025-06-05 16:58:16 +02:00
2025-06-25 09:20:32 +02:00
2025-06-25 09:20:32 +02:00
2025-06-25 09:20:32 +02:00

How To Use

cp -r <USB_MOUNT> ~/.emacs.d
chown -R <YOUR_USER> ~/.emacs.d
# ln -sf <THIS_REPO> ~/.emacs.d

Introduction

"Original" EMACS:

  • 1976
  • David A. Moon & Guy L. Steele Jr.
  • Set of macros for the TECO editor (char based editor)

Gosling Emacs:

  • 1981
  • James Gosling (the Java® guy)

GNU Emacs:

  • 1984
  • Richard Stallman aka. Saint IGNUcius (saint in the Church of Emacs)

Latest Release: Emacs 30.1 Released: February, 2025

Emacs uses emacs-lisp:

  • lisp dialect
  • functional (not pure though)
  • specially developed to configure Emacs

Variables

(defvar my/var nil "My very own variable")
(setq my/var "Hey Emacs!")
(print my/var)
;; There are more... (setq-local, setq-default)
"
\"Hey Emacs!\"
"

Functions

(defun test ()
  "Docstring"
  (interactive)
  (print my/var))

(test)
(defun more (a b &optional c d &rest e)
  (interactive)
  ; 'a 'b 'c 'd '(...)
  (print (concat a b c d (mapconcat #'identity e ""))))

(more "1" "2" "3" "4" "5" "6" "7")
(more "1" "2" "3")
"
\"1234567\"

\"123\"
"
(defun print-name (&rest args)
  (interactive)
  (let ((first (plist-get args :first))
        (last (or (plist-get args :last) "?")))
    (princ last)
    (when first
      (princ ", ")
      (princ first))))

(print-name :first "Philip" :last "B1")
"B1, Philip"

Let Bindings

(defun another-test (a b)
  "Multiplies `A' times `B' and adds them afterwards"
  (interactive)
  (let* ((x a)
         (y (* x b)))
    (+ x y)))

(print (another-test 2 4))
"
10
"

Hooks

(defun my/fun () (message "Emacs is cool!"))
(add-hook 'after-save-hook #'my/fun)
;; (remove-hook 'after-save-hook 'my/fun)

Package Management & Configuration

Package Manager

; Standard is package.el
(straight-use-package 'nix-mode)
""

Configuration Macro

(straight-use-package 'use-package)

;; Macro that provides syntactic sugar
(use-package color-moccur
  ;; Creates autoloads for these commands
  ;; Defers loading of the module until command is used
  :commands (isearch-moccur isearch-all)
  ;; Keybindings
  :bind (("M-s O" . moccur)
         :map isearch-mode-map
         ("M-o" . isearch-moccur)
         ("M-O" . isearch-moccur-all))
  ;; Before package is loaded
  :init
  (setq isearch-lazy-highlight t)
  ;; After package is loaded
  :config
  (use-package moccur-edit))

Tour de Emacs Config

.emacs.d/ ├── early-init.el ├── init.el └── cnf/ ├── app └── lang

Tasks

Keybinding

  • Create a new keybinding for the emacs-lisp-mode that executes eval-last-sexp with the binding SPC x e while in normal mode
Possible Solution
(my-leader
  :keymaps 'emacs-lisp-mode-map
  :states 'normal
  "x" '(:ignore t :which-key "Eval")
  "x e" 'eval-last-sexp
  "x b" 'eval-buffer)

Package

  • Install a new package using straight, e.g. swiper (or something else)
Possible Solution
(straight-use-package 'swiper)
Description
No description provided
Readme 68 KiB
Languages
Emacs Lisp 98.2%
YASnippet 1.8%