Chapter 8. Configure emacs
-
Set up config
Remove default configuration, if any, that gets in the way of
~/.emacs.d/init.el
.rm ~/.emacs.d
Make sure the right directory exists.mkdir -p ~/.emacs.d
Get the standard config
cp ~/Dropbox/Basic/new_machine/linux/emacs/.emacs.d.init.el.current ~/.emacs.d/init.el
Note
~/.emacs.d/init.el
source;;; init.el --- Initialization file for Emacs ;;; Commentary: ;;; sanmarco version ;; Emacs Startup File --- initialization for Emacs ;; Settings froma https://aronbedra.com/emacs.d/ ;; Settings from https://www.sandeepnambiar.com/my-minimal-emacs-setup/ ;;; Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Packaging ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'package) (setq package-enable-at-startup nil) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")) (package-initialize) (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package) (eval-when-compile (require 'use-package))) ;; Start benchmarking as early as possible (use-package benchmark-init :config ;; To disable collection of benchmark data after init is done. (add-hook 'after-init-hook 'benchmark-init/deactivate)) (add-hook 'after-init-hook (lambda () (message "loaded in %s" (emacs-init-time)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Custom ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:family "Quadraat Sans Mono OT" :foundry "unknown" :slant normal :weight normal :height 200 :width normal)))) '(flycheck-inline-error ((t (:inherit compilation-error :inverse-video t :family "IBM Plex Mono")))) '(flycheck-inline-info ((t (:inherit compilation-info :inverse-video t :family "IBM Plex Mono")))) '(flycheck-inline-warning ((t (:inherit compilation-warning :inverse-video t :family "IBM Plex Mono")))) '(powerline-active1 ((t (:background "tan" :foreground "gray29"))))) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(auto-save-file-name-transforms `((".*" ,temporary-file-directory t))) '(backup-by-copying t) '(backup-directory-alist '(("." . "~/.emacs.d/backup"))) '(column-number-mode t) '(company-idle-delay 2) '(completions-format 'one-column) '(create-lockfiles nil) '(custom-safe-themes '("830877f4aab227556548dc0a28bf395d0abe0e3a0ab95455731c9ea5ab5fe4e1" "285d1bf306091644fb49993341e0ad8bafe57130d9981b680c1dbd974475c5c7" "57a29645c35ae5ce1660d5987d3da5869b048477a7801ce7ab57bfb25ce12d3e" "51ec7bfa54adf5fff5d466248ea6431097f5a18224788d0bd7eb1257a4f7b773" "4c56af497ddf0e30f65a7232a8ee21b3d62a8c332c6b268c81e9ea99b11da0d3" "fee7287586b17efbfda432f05539b58e86e059e78006ce9237b8732fde991b4c" "c433c87bd4b64b8ba9890e8ed64597ea0f8eb0396f4c9a9e01bd20a04d15d358" "2809bcb77ad21312897b541134981282dc455ccd7c14d74cc333b6e549b824f3" default)) '(delete-old-versions t) '(echo-keystrokes 0.1) '(flycheck-check-syntax-automatically '(save idle-change idle-buffer-switch new-line mode-enabled)) '(flycheck-disabled-checkers '(python-pylint)) '(flycheck-display-errors-delay 0.3) '(flycheck-display-errors-function 'flycheck-display-error-messages-unless-error-list) '(flycheck-flake8rc "~/.config/.flake8") '(flycheck-idle-change-delay 0.2) '(flycheck-indication-mode 'left-fringe) '(flycheck-navigation-minimum-level 'error) '(flycheck-pylintrc "~/.config/.pylintrc" nil nil "set standard") '(flycheck-python-mypy-config '("mypy.ini" "setup.cfg" "~/.config/mypy/config")) '(flycheck-relevant-error-other-file-minimum-level 'error) '(flycheck-relevant-error-other-file-show nil) '(frame-title-format '((:eval (if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b"))) t) '(fset 'yes-or-no-p t) '(gc-cons-threshold 50000000) '(git-gutter:modified-sign "Δ") '(git-gutter:verbosity 0) '(global-auto-revert-mode t) '(global-display-line-numbers-mode 1) '(global-hl-line-mode 1) '(indent-tabs-mode nil) '(inhibit-startup-screen t) '(kept-new-versions 20) '(kept-old-versions 5) '(large-file-warning-threshold 100000000) '(line-number-mode 1) '(menu-bar-mode nil) '(next-error-message-highlight 'keep) '(nxml-slash-auto-complete-flag t) '(package-selected-packages '(jinja2-mode scad-mode benchmark-init undo-tree diffview ac-slime anaconda-mode auto-complete blacken company-jedi crux dap-mode dash expand-region flycheck flycheck-pos-tip free-keys helm hideshow-org importmagic json-mode markdown-mode py-isort python-pytest pythonic smart-mode-line smex solarized-theme use-package which-key yasnippet yasnippet-snippets)) '(prefer-coding-system 'utf-8) '(python-check-command "mypy") '(read-extended-command-predicate 'command-completion-default-include-p) '(scroll-bar-mode nil) '(set-default-coding-systems 'utf-8) '(set-keyboard-coding-system 'utf-8) '(set-terminal-coding-system 'utf-8) '(show-paren-mode t) '(size-indication-mode t) '(solarized-distinct-fringe-background t) '(solarized-emphasize-indicators nil) '(solarized-high-contrast-mode-line t) '(tab-width 4) '(tool-bar-mode nil) '(undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo-tree/"))) '(use-package-always-ensure t) '(version-control t)) (add-hook 'after-change-major-mode-hook (lambda() (electric-indent-mode -1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Packages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (use-package blacken) (use-package company :ensure t :diminish company-mode :config (add-hook 'after-init-hook 'global-company-mode)) (use-package company :ensure t :diminish company-mode :config (add-hook 'after-init-hook 'global-company-mode)) (use-package crux :ensure t :bind ("C-k" . crux-smart-kill-line) ("C-c n" . crux-cleanup-buffer-or-region) ("C-c f" . crux-recentf-find-file) ("C-a" . crux-move-beginning-of-line)) ;; ;; https://tychoish.com/post/better-company/ ;; (setq company-backends '(company-capf ;; company-keywords ;; company-jedi)) ;; (setq company-tooltip-limit 20) ;; (setq company-show-quick-access t) ;; (setq company-idle-delay 0) ;; (setq company-echo-delay 0) (use-package exec-path-from-shell :config (exec-path-from-shell-initialize)) (use-package expand-region :ensure t :bind ("M-m" . er/expand-region)) (use-package flycheck :ensure t :init (global-flycheck-mode)) (use-package flycheck-color-mode-line) (use-package flycheck-inline) (with-eval-after-load 'flycheck (add-hook 'flycheck-mode-hook #'flycheck-inline-mode) (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode) (flycheck-pos-tip-mode)) (use-package git-gutter :config (global-git-gutter-mode 't)) (use-package graphviz-dot-mode) (use-package hideshow) (use-package magit :bind (("C-M-g" . magit-status))) ;; (use-package nxml-mode) (use-package powerline) (powerline-default-theme) (use-package pyvenv :ensure t :config (pyvenv-mode 1)) (use-package rainbow-delimiters :config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)) (use-package rainbow-mode :config (setq rainbow-x-colors nil) (add-hook 'prog-mode-hook 'rainbow-mode)) (use-package recentf :config (recentf-mode 1)) (use-package sgml-mode) (use-package smart-mode-line :ensure t :config ;; (setq sml/theme 'powerline) (add-hook 'after-init-hook 'sml/setup)) (use-package smex :bind ("M-x" . smex) ("M-X" . smex-major-mode-commands)) (use-package smart-mode-line :ensure t :config ;; (setq sml/theme 'powerline) (add-hook 'after-init-hook 'sml/setup)) (use-package solarized-theme :config (load-theme 'solarized-gruvbox-dark t)) (use-package undo-tree :defer 5 :config (global-undo-tree-mode 1)) (use-package which-key :config (which-key-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Python ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-hook 'python-mode-hook (lambda () ;; explicitly load company for the occasion when the deferred ;; loading with use-package hasn't kicked in yet (company-mode) ) ) (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Flycheck ;; from https://medium.com/@enzuru/helpful-emacs-python-mode-hooks-especially-for-type-hinting ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (flycheck-define-checker python-mypy "" :command ("mypy" "--ignore-missing-imports" "--python-version" "3.8" source-original) :error-patterns ((error line-start (file-name) ":" line ": error:" (message) line-end)) :modes python-mode :after (add-to-list 'flycheck-checkers 'python-mypy) (remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; nXML/Docbook ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (eval-after-load 'rng-loc ;; '(add-to-list 'rng-schema-locating-files "~/.schema/schemas.xml")) ;; (add-to-list 'hs-special-modes-alist ;; '(nxml-mode ;; "<!--\\|<[^/>]*[^/]>" ;; "-->\\|</[^/>]*[^/]>" ;; "<!--" ;; sgml-skip-tag-forward ;; nil) ;; ) ;; (add-hook 'nxml-mode-hook 'hs-minor-mode) ;; ;; optional key bindings, easier than hs defaults ;; (define-key nxml-mode-map (kbd "C-c h") 'hs-toggle-hiding) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; HTML/CSS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar c-basic-offset) (add-hook 'css-mode-hook (lambda () (setq c-basic-offset 2) (setq indent-tabs-mode nil))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Global Keyboard Mappings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'org) ; Required to prevent flycheck error with org-mode keybindings (require 'bind-key) (bind-keys* ("C--" . company-complete) ; Ctrl+hyphen ("C-;" . comment-or-uncomment-region) ; tried moving flycheck bindings to use-package but didn't work ("C-<next>" . flycheck-next-error) ; Ctrl+<page-down> ("C-<prior>" . flycheck-previous-error) ; Ctrl+<page-up> ("C-<return>" . completion-at-point) ("C-`" . keyboard-escape-quit) ("C-c a" . org-agenda) ("C-c c" . org-capture) ("C-c l" . org-store-link) ("C-c C-n" . next-error) ("C-f" . toggle-frame-fullscreen) ("C-g" . goto-line) ("C-h" . replace-string) ("C-v" . yank) ; Stop scrolling-up by muscle memory ("C-z" . undo) ; Stop minimizing by accident ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Finish up ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'server) (if (not (server-running-p)) (server-start)); (provide '.emacs) (provide 'init) ;;; init.el ends here
-
Cleanup
Start emacs. See which packages fail to load, and manually install them.
M-x package-install