commit a9c4b0e6a9509bd9f513fbc32915b5a80e78ec76
parent b44893511cff3e6197b00047e0d4e4b5c4a2ab4d
Author: Alex Balgavy <alex@balgavy.eu>
Date: Fri, 16 Apr 2021 11:06:04 +0200
emacs: improve config
Diffstat:
5 files changed, 212 insertions(+), 198 deletions(-)
diff --git a/dot.map b/dot.map
@@ -61,8 +61,8 @@ Xresources: ~/.Xresources
# Config: Emacs
emacs:
-- emacs.d/config.org: ~/.emacs.d/config.org
-- emacs: ~/.emacs
+- config.org: ~/.emacs.d/config.org
+- init.el: ~/.emacs.d/init.el
# Config: shell
shell:
diff --git a/emacs/config.org b/emacs/config.org
@@ -0,0 +1,192 @@
+* Garbage collection
+ Garbage-collect on focus-out, Emacs /should/ feel snappier.
+
+ #+begin_src emacs-lisp
+ (add-hook 'focus-out-hook #'garbage-collect)
+ #+end_src
+
+* Package management
+** Repositories (MELPA & Org)
+ #+begin_src emacs-lisp
+ (require 'package)
+ (add-to-list 'package-archives
+ '("melpa" . "https://melpa.org/packages/"))
+ (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/"))
+ (package-refresh-contents)
+ (package-initialize)
+ #+end_src
+
+** use-package
+ #+begin_src emacs-lisp
+ (unless (package-installed-p 'use-package)
+ (package-install 'use-package))
+ (eval-when-compile (require 'use-package))
+ #+end_src
+
+ Always auto-install packages:
+
+ #+begin_src emacs-lisp
+ (require 'use-package-ensure)
+ (setq use-package-always-ensure t)
+ #+end_src
+
+* Packages
+** exec-path-from-shell (macOS)
+
+ In macOS, the path is not set correctly in the GUI app. This fixes it.
+ #+begin_src emacs-lisp
+ (when (memq window-system '(mac ns x))
+ (use-package exec-path-from-shell
+ :config
+ (exec-path-from-shell-initialize)))
+ #+end_src
+
+** emacs-which-key
+ Minor mode for Emacs that displays the key bindings following your currently entered incomplete command (a prefix) in a popup.
+
+ #+BEGIN_SRC emacs-lisp
+ (use-package which-key
+ :config
+ (which-key-mode))
+ #+end_src
+
+** helm
+ Better incremental completion and selection narrowing.
+ Generally makes for nicer interactivity.
+
+ #+begin_src emacs-lisp
+ (use-package helm
+ :defer nil
+ :custom
+ (helm-M-x-always-save-history t)
+ (helm-display-function 'pop-to-buffer)
+ (savehist-additional-variables '(extended-command-history))
+ (history-delete-duplicates t)
+ :custom-face
+ (helm-non-file-buffer ((t (:inherit font-lock-comment-face))))
+ (helm-ff-file-extension ((t (:inherit default))))
+ (helm-buffer-file ((t (:inherit default))))
+ :bind
+ (("M-x" . helm-M-x)
+ ("C-x C-f" . helm-find-files)
+ ("C-x C-b" . helm-buffers-list)
+ ("C-x b" . helm-buffers-list)
+ ("C-x C-r" . helm-recentf)
+ ("C-x C-i" . helm-imenu)
+ ("M-y" . helm-show-kill-ring))
+ :config
+ (helm-mode)
+ (savehist-mode))
+ #+end_src
+
+** org
+ In org mode, I want to use bullets instead of stars.
+ Also, I add a few expansions
+
+ #+begin_src emacs-lisp
+ (use-package org
+ :config
+ (unless (package-installed-p 'org-bullets)
+ (package-refresh-contents)
+ (package-install 'org-bullets))
+ (require 'org-bullets)
+ (require 'org-tempo)
+
+ :hook
+ (org-mode . (lambda () (org-bullets-mode 1))))
+ #+end_src
+
+** lean-mode
+ Shift completion for lean-mode and company-lean:
+
+ #+begin_src emacs-lisp
+ (global-set-key (kbd "S-SPC") #'company-complete)
+ #+end_src
+
+* Interface
+** GUI elements
+ Get rid of all bars.
+
+ #+begin_src emacs-lisp
+ (setq org-src-tab-acts-natively t)
+ (when window-system
+ (menu-bar-mode -1)
+ (tool-bar-mode -1)
+ (scroll-bar-mode -1)
+ (tooltip-mode -1))
+ #+end_src
+
+** Messages
+ Hide some messages I don't need.
+
+ #+begin_src emacs-lisp
+ (setq inhibit-startup-message t)
+ (setq initial-scratch-message "")
+ #+end_src
+
+** Appearance
+ Highlight the current line:
+
+ #+begin_src emacs-lisp
+ (global-hl-line-mode)
+ (show-paren-mode 1)
+ #+end_src
+
+ Line numbers:
+
+ #+begin_src emacs-lisp
+ (global-linum-mode 1)
+ #+end_src
+
+* Theme
+ Icons required for some parts of the doom theme:
+
+ #+begin_src emacs-lisp
+ (use-package all-the-icons)
+ #+end_src
+
+ Load Doom emacs themes:
+
+ #+begin_src emacs-lisp
+ (use-package doom-themes
+ :config
+ ;; Global settings (defaults)
+ (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
+ doom-themes-enable-italic t) ; if nil, italics is universally disabled
+
+ ;; Enable flashing mode-line on errors
+ (doom-themes-visual-bell-config)
+
+ ;; Enable custom neotree theme (all-the-icons must be installed!)
+ (doom-themes-neotree-config)
+ ;; or for treemacs users
+ (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
+ (doom-themes-treemacs-config)
+
+ ;; Corrects (and improves) org-mode's native fontification.
+ (doom-themes-org-config))
+ #+end_src
+
+ Change theme depending on the current system theme (I use the presence of the ~/.config/dark-theme file to indicate when dark theme is set):
+
+ #+begin_src emacs-lisp
+ (if (file-exists-p "~/.config/dark-theme")
+ (load-theme 'doom-one t)
+ (load-theme 'doom-one-light t))
+ #+end_src
+
+* Follow symlinks
+ Make sure to follow symlinks without prompting:
+
+ #+begin_src emacs-lisp
+ (setq vc-follow-symlinks t)
+ #+end_src
+
+* Backup files
+ By default, backup files (those with a tilde) are saved in the same directory as the currently edited file.
+ This setting puts them in ~/.local/share/emacs/saves.
+
+ #+begin_src emacs-lisp
+ (setq backup-directory-alist '(("." . "~/.local/share/emacs/saves")))
+ (setq backup-by-copying t)
+ #+end_src
diff --git a/emacs/emacs b/emacs/emacs
@@ -1,33 +0,0 @@
-(setq org-src-tab-acts-natively t)
-(when window-system
- (menu-bar-mode -1)
- (tool-bar-mode -1)
- (scroll-bar-mode -1)
- (tooltip-mode -1))
-
-(setq inhibit-startup-message t)
-(setq initial-scratch-message "")
-
-;;; Set up package
-(require 'package)
-(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
-(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
-(package-initialize)
-
-;;; Bootstrap use-package
-;; Install use-package if it's not already installed.
-;; use-package is used to configure the rest of the packages.
-(unless (or (package-installed-p 'use-package)
- (package-installed-p 'diminish))
- (package-refresh-contents)
- (package-install 'use-package)
- (package-install 'diminish))
-
-;; From use-package README
-(eval-when-compile
- (require 'use-package))
-
-;; Tangle configuration
-(setq vc-follow-symlinks t)
-(org-babel-load-file (expand-file-name "config.org" user-emacs-directory))
-(garbage-collect)
diff --git a/emacs/emacs.d/config.org b/emacs/emacs.d/config.org
@@ -1,163 +0,0 @@
-* Bootstrap
-** Auto-compile this config file
- #+begin_src emacs-lisp
- (defun tangle-init ()
- "If the current buffer is 'init.org' the code-blocks are
- tangled, and the tangled file is compiled."
- (when (equal (buffer-file-name)
- (expand-file-name (concat user-emacs-directory "initconfig.org")))
- ;; Avoid running hooks when tangling.
- (let ((prog-mode-hook nil))
- (org-babel-tangle)
- (byte-compile-file (concat user-emacs-directory "config.el")))))
-
- (add-hook 'after-save-hook 'tangle-init)
- #+end_src
-
-** Garbage collection
- Garbage-collect on focus-out, Emacs /should/ feel snappier.
-
- #+BEGIN_SRC emacs-lisp
- (add-hook 'focus-out-hook #'garbage-collect)
- #+END_SRC
-
-* Theming
- Load the themes (from Doom emacs).
-
- #+BEGIN_SRC emacs-lisp
- (unless (package-installed-p 'doom-themes)
- (package-refresh-contents)
- (package-install 'doom-themes))
-
- (use-package doom-themes
- :config
- ;; Global settings (defaults)
- (setq doom-themes-enable-bold t ; if nil, bold is universally disabled
- doom-themes-enable-italic t) ; if nil, italics is universally disabled
-
- ;; Enable flashing mode-line on errors
- (doom-themes-visual-bell-config)
-
- ;; Enable custom neotree theme (all-the-icons must be installed!)
- (doom-themes-neotree-config)
- ;; or for treemacs users
- (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
- (doom-themes-treemacs-config)
-
- ;; Corrects (and improves) org-mode's native fontification.
- (doom-themes-org-config))
- #+END_SRC
-
- Choose a theme depending on the system theme:
-
- #+begin_src emacs-lisp
- (if (file-exists-p "~/.config/dark-theme")
- (load-theme 'doom-one t)
- (load-theme 'doom-one-light t))
- #+end_src
-
-* Packages
-** emacs-which-key
- Minor mode for Emacs that displays the key bindings following your currently entered incomplete command (a prefix) in a popup.
-
- #+BEGIN_SRC emacs-lisp
- (unless (package-installed-p 'which-key)
- (package-refresh-contents)
- (package-install 'which-key))
- (which-key-mode)
- #+END_SRC
-** helm
- Install if not installed:
-
- #+BEGIN_SRC emacs-lisp
- (unless (package-installed-p 'helm)
- (package-refresh-contents)
- (package-install 'helm))
- #+END_SRC
-
- Configure:
-
- #+BEGIN_SRC emacs-lisp
- (use-package helm
- :defer nil
- :custom
- (helm-M-x-always-save-history t)
- (helm-display-function 'pop-to-buffer)
- (savehist-additional-variables '(extended-command-history))
- (history-delete-duplicates t)
- :custom-face
- (helm-non-file-buffer ((t (:inherit font-lock-comment-face))))
- (helm-ff-file-extension ((t (:inherit default))))
- (helm-buffer-file ((t (:inherit default))))
- :bind
- (("M-x" . helm-M-x)
- ("C-x C-f" . helm-find-files)
- ("C-x C-b" . helm-buffers-list)
- ("C-x b" . helm-buffers-list)
- ("C-x C-r" . helm-recentf)
- ("C-x C-i" . helm-imenu)
- ("M-y" . helm-show-kill-ring))
- :config
- (helm-mode)
- (savehist-mode))
- #+END_SRC
-
- I'd also like helm in a popup frame so:
-** org
- In org mode, I want to use bullets instead of stars.
- Also, I add a few expansions
- #+BEGIN_SRC emacs-lisp
- (use-package org
- :config
- (unless (package-installed-p 'org-bullets)
- (package-refresh-contents)
- (package-install 'org-bullets))
- (require 'org-bullets)
- (require 'org-tempo)
-
- :hook
- (org-mode . (lambda () (org-bullets-mode 1))))
- #+END_SRC
-** exec-path-from-shell
- In macOS, the path is not set correctly in the GUI app. This fixes it.
- #+begin_src emacs-lisp
- (when (memq window-system '(mac ns x))
- (exec-path-from-shell-initialize))
- #+end_src
-** lean-mode
- Shift completion for lean-mode and company-lean:
-
- #+begin_src emacs-lisp
- (global-set-key (kbd "S-SPC") #'company-complete)
- #+end_src
-* Defaults
-** Appearance
- Highlight the current line
-
- #+BEGIN_SRC emacs-lisp
- (global-hl-line-mode)
- (show-paren-mode 1)
- #+END_SRC
-
- Disable some UI elements:
-
- #+BEGIN_SRC emacs-lisp
- (when window-system
- (scroll-bar-mode 0) ; Disable scrollbar
- (tool-bar-mode 0)); Disable toolbar
- #+END_SRC
-
- Line numbers
-
- #+begin_src emacs-lisp
- (global-linum-mode 1)
- #+end_src
-
-** Backup files
- By default, backup files (those with a tilde) are saved in the same directory as the currently edited file.
- This setting puts them in ~/.local/share/emacs/saves.
-
- #+begin_src emacs-lisp
- (setq backup-directory-alist '(("." . "~/.local/share/emacs/saves")))
- (setq backup-by-copying t)
- #+end_src
diff --git a/emacs/init.el b/emacs/init.el
@@ -0,0 +1,18 @@
+(org-babel-load-file
+ (expand-file-name "config.org" user-emacs-directory))
+
+(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.
+ '(package-selected-packages
+ '(doom-themes all-the-icons use-package-ensure which-key use-package org-bullets helm exec-path-from-shell)))
+(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.
+ '(helm-buffer-file ((t (:inherit default))))
+ '(helm-ff-file-extension ((t (:inherit default))))
+ '(helm-non-file-buffer ((t (:inherit font-lock-comment-face)))))