Files
emacs.d/config.org
2020-12-21 19:56:12 +01:00

12 KiB

Meine Emacs-Konfiguration

Benutzerangaben

Name und Emailadresse

  (setq user-full-name "Ariane Troche")
  (setq user-mail-address "ariane@familie-troche.de")

Start

Startfenster

Einige Einstellungen, die den Startbildschirm betreffen:

Splash Screen

Der übliche Emacs-Startbildschirm soll nicht angezeigt werden. Damit öffnet sich direkt der scratch-Buffer, welcher komplett leer sein soll.

  (setq inhibit-splash-screen t)
  (setq initial-scratch-message nil)

Scrollbar, Toolbar, Menubar

Scrollbar, Toolbar und Menubar werden ausgeblendet.

  (scroll-bar-mode -1)
  (tool-bar-mode -1)
  (menu-bar-mode -1)

Vollbildschirm

Das Fenster wird im Vollbild geöffnet.

 (setq initial-frame-alist '((fullscreen . maximized)))

Server

Damit beim Start von Emacs nicht immer ein neuer Prozess gestartet wird, wird Emacs hier schon als Server aufgesetzt. Using Emacs as a Server

  (server-start)

Backup und Autosave

Die Backup- und Autosave-Dateien stören eher, da ich sie noch nie gebraucht habe, sollen sie erst gar nicht angelegt werden.

(use-package no-littering
  :config (with-eval-after-load 'recentf
            (add-to-list 'recentf-exclude no-littering-var-directory)
     (add-to-list 'recentf-exclude no-littering-etc-directory))

   (setq auto-save-file-name-transforms  ; autosaved-file-name~
                `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))
                custom-file (no-littering-expand-etc-file-name "custom.el"))

   (if (file-exists-p custom-file)
     (load-file custom-file)))

Konfigurationsdatei

Konfigurationsdatei

Ich bastel sehr gerne an meiner Konfigurationsdatei herum. Mit <f1> kann ich sie ganz schnell öffnen und mit <f2> neu laden.

Key Funktion
F1 Öffne Konfigurationsdatei in anderem Fenster
F2 Konfiguration neu laden, ohne Emacs-Neustart
  ;; Pfade
  (setq my/file-init (expand-file-name "init.el" user-emacs-directory))
  (setq my/file-config (expand-file-name "config.org" user-emacs-directory))
  ;; Öffnen
  (defun my/find-config-file ()
    "Edit my init file in another window."
    (interactive)
    (find-file my/file-config))
  ;; Laden
  (defun my/reload-emacs-configuration ()
    "Reload init.el"
    (interactive)
    (load-file my/file-init))
  ;; Keys
  (global-set-key (kbd "<f1>") 'my/find-config-file)
  (global-set-key (kbd "<f2>") 'my/reload-emacs-configuration)

Neustart

Mit <F12> kann ich Emacs neu starten.

Key Funktion
F12 Emacs-Neustart
  (use-package restart-emacs
    :ensure t
    :bind ("<f12>" . 'restart-emacs))

Font

Font

;; for unicode
(when (display-graphic-p)
  (set-fontset-font "fontset-default" nil
                    (font-spec :size 20 :name "Symbola")))
;; for emoji
(set-fontset-font
  t
  '(#x1f300 . #x1fad0)
  (cond
    ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
    ((member "Noto Emoji" (font-family-list)) "Noto Emoji")
    ((member "Segoe UI Emoji" (font-family-list)) "Segoe UI Emoji")
    ((member "Symbola" (font-family-list)) "Symbola")
    ((member "Apple Color Emoji" (font-family-list)) "Apple Color Emoji")))

;; font to use
(defconst artr/default-font-family "Source Code Pro")
(defconst artr/default-font-size 100)
(defconst artr/default-icon-size 15)

(set-face-attribute 'default nil
                    :family artr/default-font-family
                    :height artr/default-font-size)

Schriftgröße anpassen

(defun artr/adjust-font-size (height)
 "Adjust font size by given height. If height is '0', reset font
size. This function also handles icons and modeline font sizes."
  (interactive "nHeight ('0' to reset): ")
    (let ((new-height (if (zerop height)
                       artr/default-font-size
  (+ height (face-attribute 'default :height)))))
      (set-face-attribute 'default nil :height new-height)
(set-face-attribute 'mode-line nil :height new-height)
(set-face-attribute 'mode-line-inactive nil :height new-height)
(message "Font size: %s" new-height)))

Schrift vergrößern

(defun artr/increase-font-size ()
 "Increase font size by 0.5 (5 in height)."
  (interactive)
    (artr/adjust-font-size 5))

Schrift verkleinern

(defun artr/decrease-font-size ()
 "Increase font size by 0.5 (5 in height)."
  (interactive)
    (artr/adjust-font-size -5))

Schriftgröße zurücksetzen

(defun artr/reset-font-size ()
 "Reset font size according to the `artr/default-font-size'."
  (interactive)
    (artr/adjust-font-size 0))

Keybindings

  (global-set-key (kbd "C--") 'artr/decrease-font-size)
  (global-set-key (kbd "C-*") 'artr/increase-font-size)
  (global-set-key (kbd "C-0") 'artr/reset-font-size)

Icons

Icons

  (use-package all-the-icons)

Magit

Magit ist ein git-Client für Emacs: Magit User Manual

(use-package magit
  :bind ("C-x g" . magit-status))

Fenster

teilen

Funktionen/Tastenkombination um neue Fenster zu erzeugen. Wenn ein neues Fenster erzeugt wird auch direkt dahin wechseln.

Key Funktion
C-1 Alle anderen Fenster schließen
C-2 Neues Fenster unterhalb
C-3 Neues Fenster daneben
(defun artr/split-window-below-and-switch ()
  "Split the window below, then switch to the new window."
  (interactive)
  (split-window-below)
  (other-window 1))

(defun artr/split-window-right-and-switch ()
  "Split the window right, then switch to the new window."
  (interactive)
  (split-window-right)
  (other-window 1))

(global-set-key (kbd "C-1") 'delete-other-windows)
(global-set-key (kbd "C-2") 'artr/split-window-below-and-switch)
(global-set-key (kbd "C-3") 'artr/split-window-right-and-switch)

wechseln

ace-window Bei mehr als 2 Fenstern in der Konfiguration werden die Fenster "durchnummeriert". So können Aktionen gezielt durchgeführt werden. Die möglichen Aktionen werden mit ? aufgelistet. Bei 2 Fenstern wird das Fenster einfach gewechselt.

Key Funktion
M-o ace-windows (? zeigt mögliche Aktionen)
M-O ace-swap-windows
(use-package ace-window
  :init (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
              aw-scope 'frame)
  :bind (("M-o" . ace-window)
         ("M-O" . ace-swap-window)))

anordnen

Key Funktion
C-c <left> vorherige Fensterkonfiguration
C-c <right> nächste Fensterkonfiguration
 (use-package winner
   :config (winner-mode))

eyebrowse Es können Fensterkonfigurationen angelegt und wiederhergestellt werden. Das Speichern der Konfigurationen passiert in sogenannten Slots, die von 0,… durchnummeriert werden. Mit C-c w 0 kann dann direkt die zugehörige Konfiguration wiederhergestellt werden.

Key Funktion
C-c w key-map
C-c w n neue Fensterkonfiguration
C-c w . Fensterkonfiguration wechseln
C-c w , Fensterkonfiguration benennen
 (use-package eyebrowse
   :bind (("C-c w ." . eyebrowse-switch-to-window-config)
          ("C-c w ," . eyebrowse-rename-window-config)
          ("C-c w DEL" . eyebrowse-close-window-config)
          ("C-c w k" . eyebrowse-close-window-config)
          ("C-c w n" . eyebrowse-create-window-config))
    :init (setq eyebrowse-keymap-prefix (kbd "C-c w")
                eyebrowse-wrap-around t
  eyebrowse-mode-line-style 'always
  eyebrowse-mode-line-separator "|")
          (eyebrowse-mode t))

bezeichnen

Die Fenster werden mit "Projektname | Dateiname" bezeichnet.

(setq-default frame-title-format 
                '((:eval
                  (let ((project-name (projectile-project-name)))
                    (unless (string= "-" project-name)
                      (format "%s| " project-name))))
                 "%b"))  ; project-name| file-name

Help

(use-package helpful
  :bind (([remap describe-function] . helpful-callable)
         ([remap describe-variable] . helpful-variable)
  ([remap describe-key] . helpful-key)
  :map emacs-lisp-mode-map
    ("C-c C-d" . helpful-at-point)))

Modeline

Doom-Modeline.

(use-package doom-modeline
  :custom (doom-modeline-icon t)
          (doom-modeline-minor-modes t)
   (doom-modeline-unicode-fallback t)
   (doom-modeline-mu4e nil)
   (doom-modeline-buffer-encoding nil)
  :init
  :hook (after-init . doom-modeline-mode))

(use-package minions
  :hook (doom-modeline-mode . minions-mode))

(use-package anzu
  :after isearch
  :config (global-anzu-mode))

Helm

A Package in a league of its own: Helm

Helm ist eine Schnittstelle, mit der man in einer Auswahl von Kandidaten suchen und filtern kann. Diese Schnittstelle kann in verschiedensten Anwendungen eingesetzt werden, wie z.B. Dateien, Buffer, Funktionen, Variablen und noch vieles mehr. Es gibt viele Erweiterungen für Helm.

Key Aktion
M-x Funktionsaufruf
C-c h helm-mini mit Buffer, Recent-Files und Bookmarks
C-h a Tastenkombinationen
C-x C-f Datei
C-x b Buffer
C-x f Recent-Files
C-x c b Bookmarks
C-x c SPC Mark-Rings
M-y Kill-Ring
C-x c o Suche in Datei mit Occur
C-x c s Suche in Datei mit Swoop
  (use-package helm
    :demand
    :bind ("M-x" . helm-M-x)
          ("C-h a" . helm-apropos)
          ("C-c h" . helm-mini)
          ("C-x C-f" . helm-find-files)
          ("C-x f" . helm-recentf)
          ("C-x b" . helm-buffers-list)
          ("C-x c b" . helm-filtered-bookmarks)
          ("C-x c o" . helm-occur)
          ("C-x c s" . helm-swoop)
          ("C-x c SPC" . helm-all-mark-rings)
          ("M-y" . helm-show-kill-ring)
    :preface (require 'helm-config)
    :config (helm-mode 1))