From a1293a9c3de5afbfd4c93e0fa7a3aa8eb9cc3970 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 9 Dec 2020 20:24:42 -0600 Subject: Add a lot of stuff … back --- config.org | 332 +++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 271 insertions(+), 61 deletions(-) (limited to 'config.org') diff --git a/config.org b/config.org index c025f03..d171ac9 100644 --- a/config.org +++ b/config.org @@ -3,7 +3,7 @@ #+PROPERTY: header-args :tangle config.el :comments both :mkdirp yes #+EXPORT_FILE_NAME: README.md #+BANKRUPTCY_COUNT: 3 -#+Time-stamp: <2020-12-08 23:51:18 acdw> +#+Time-stamp: <2020-12-09 18:28:04 acdw> * Pave the way ** Correct =exec-path= @@ -50,6 +50,7 @@ #+begin_src emacs-lisp (setq straight-use-package-by-default t) + (setq use-package-hook-name-suffix nil) (straight-use-package 'use-package) #+end_src @@ -60,7 +61,7 @@ #+begin_src emacs-lisp (straight-use-package '(use-package-custom-update - :host "github" + :host github :repo "a13/use-package-custom-update")) (require 'use-package-custom-update) @@ -161,13 +162,6 @@ ** Tweak the remaining UI -*** Window dividers - -#+begin_src emacs-lisp - (add-to-list 'default-frame-alist '(right-divider-width . 2)) - (add-to-list 'default-frame-alist '(bottom-divider-width . 2)) -#+end_src - *** Fringes #+begin_src emacs-lisp @@ -206,14 +200,18 @@ **** Only show the tab bar when there's more than one tab #+begin_src emacs-lisp - (cuss tab-bar-show 1) + (cuss tab-bar-show 1 + "Show the tab bar only when there's more than 1 tab.") #+end_src *** Cursor #+begin_src emacs-lisp - (cuss cursor-type 'bar) - (cuss cursor-in-non-selected-windows 'hollow) + (cuss cursor-type 'bar + "Show a vertical bar for the cursor.") + (cuss cursor-in-non-selected-windows 'hollow + "In inactive windows, make the cursor an empty box.") + (blink-cursor-mode 0) #+end_src *** Buffer names @@ -237,10 +235,9 @@ ** Startup #+begin_src emacs-lisp - (cuss inhibit-startup-buffer-menu t) - (cuss inhibit-start-screen t) - (cuss initial-buffer-choice t) - (cuss initial-scratch-message ";; Hi there!\n") + (cuss inhibit-startup-screen t "Don't show Emacs' startup buffer.") + (cuss initial-buffer-choice t "Start at *scratch*.") + (cuss initial-scratch-message "" "Empty *scratch*.") #+end_src ** Theme @@ -281,6 +278,22 @@ (load-theme 'modus-operandi t)) #+end_src +*** Modeline + +#+begin_src emacs-lisp + (custom-set-faces + '(mode-line ((t (:height 0.8 + :overline t + :box nil + :foreground "black" + :background "white")))) + '(mode-line-inactive ((t (:height 0.8 + :overline t + :box nil + :foreground "#808080" + :background "white"))))) +#+end_src + *** Fonts **** Define fonts @@ -297,30 +310,31 @@ the first time, so it should be added to `window-setup-hook'. It removes itself from that hook." (interactive) - (set-face-attribute 'default nil - :font - (font-candidate - "Libertinus Mono-11" - "Linux Libertine Mono O-11" - "Go Mono-10" - "Consolas-10")) - - (set-face-attribute 'fixed-pitch nil - :font - (font-candidate - "Libertinus Mono-11" - "Linux Libertine Mono O-11" - "Go Mono-10" - "Consolas-10")) - - (set-face-attribute 'variable-pitch nil - :font - (font-candidate - "Libertinus Serif-13" - "Linux Libertine O-12" - "Georgia-11")) - - (remove-hook 'window-setup-hook #'acdw/setup-fonts)) + (when (display-graphic-p) + (set-face-attribute 'default nil + :font + (font-candidate + "Libertinus Mono-11" + "Linux Libertine Mono O-11" + "Go Mono-10" + "Consolas-10")) + + (set-face-attribute 'fixed-pitch nil + :font + (font-candidate + "Libertinus Mono-11" + "Linux Libertine Mono O-11" + "Go Mono-10" + "Consolas-10")) + + (set-face-attribute 'variable-pitch nil + :font + (font-candidate + "Libertinus Serif-13" + "Linux Libertine O-12" + "Georgia-11")) + + (remove-hook 'window-setup-hook #'acdw/setup-fonts))) (add-hook 'window-setup-hook #'acdw/setup-fonts) #+end_src @@ -388,7 +402,9 @@ (fset 'multi-occur #'consult-multi-occur)) #+end_src -** Marginalia +** COMMENT Marginalia + +Until the =marginalia-annotators= settles, I’m disabling this section. #+begin_src emacs-lisp (use-package marginalia @@ -432,6 +448,16 @@ (ctrlf-mode +1)) #+end_src +** Mouse + +#+begin_src emacs-lisp + (dolist (vec '([left-margin wheel-down] + [right-margin wheel-down] + [left-margin wheel-up] + [right-margin wheel-up])) + (bind-key vec #'mwheel-scroll)) +#+end_src + * Persistence ** Save history @@ -535,6 +561,25 @@ (global-so-long-mode)) #+end_src +** Multiple cursors + +#+begin_src emacs-lisp + (use-package multiple-cursors + :bind + ("C->" . mc/mark-next-like-this) + ("C-<" . mc/mark-previous-like-this) + ("C-c C-<" . mc/mark-all-like-this)) +#+end_src + +** Expand region + +#+begin_src emacs-lisp + (use-package expand-region + :bind + (("C-=" . er/expand-region) + ("C-+" . er/contract-region))) +#+end_src + * Files ** Encoding @@ -604,6 +649,51 @@ (which-function-mode +1) #+end_src +** Parentheses + +*** Show parentheses + +#+begin_src emacs-lisp + (cuss show-paren-delay 0 "Show matching parens immediately.") + (cuss show-paren-style 'mixed + "Show parenthesis, or whole expression, depending on visibility.") + (cuss show-paren-when-point-in-periphery t + "Show paren when point is near-to paren.") + (cuss show-paren-when-point-inside-paren t + "Show surrounding parens.") + + (add-hook 'prog-mode-hook #'show-paren-mode) +#+end_src + +*** Smart parentheses + +#+begin_src emacs-lisp + (use-package smartparens + :init + (require 'smartparens-config) + :config + (show-smartparens-global-mode +1) + :hook + (prog-mode-hook . smart-parens-strict-mode)) +#+end_src + +** Line numbers + +#+begin_src emacs-lisp + (defun acdw/enable-line-numbers () + "Enable line numbers, through either + `display-line-numbers-mode' or through `linum-mode'." + (if (and (fboundp 'display-line-numbers-mode) + (display-graphic-p)) + (display-line-numbers-mode +1) + (linum-mode +1))) + + (cuss display-line-numbers-width 2 + "Always have at least 2 digits for line numbers.") + + (add-hook 'prog-mode-hook #'acdw/enable-line-numbers) +#+end_src + * Writing ** Visual Fill Column @@ -619,7 +709,7 @@ (advice-add 'text-scale-adjust :after #'visual-fill-column-adjust) :hook - (text-mode . visual-fill-column-mode)) + (text-mode-hook . visual-fill-column-mode)) #+end_src ** Type nice-looking quote-type marks @@ -627,7 +717,7 @@ #+begin_src emacs-lisp (use-package typo :hook - (text-mode . typo-mode)) + (text-mode-hook . typo-mode)) #+end_src * Applications @@ -640,6 +730,118 @@ ("C-x g" . magit-status)) #+end_src +** Org mode + +I’ve put org mode under Applications, as opposed to [[*Writing]], because it’s more generally-applicable than that. + +#+begin_src emacs-lisp + (use-package org + :custom + (org-hide-emphasis-markers t) + (org-fontify-done-headline t) + (org-fontify-whole-heading-line t) + (org-fontify-quote-and-verse-blocks t) + (org-pretty-entities t) + + (org-src-tab-acts-natively t) + (org-src-fontify-natively t) + (org-src-window-setup 'current-window) + (org-confirm-babel-evaluate nil)) +#+end_src + +*** Export to markdown + +#+begin_src emacs-lisp + (require 'ox-md) +#+end_src + +*** Make bullets look like bullets + +#+begin_src emacs-lisp + (font-lock-add-keywords + 'org-mode + '(("^ *\\([-+]\\) " + (0 (prog1 () + (compose-region (match-beginning 1) + (match-end 1) + "•")))))) +#+end_src + +*** [[http://kitchingroup.cheme.cmu.edu/blog/2017/04/09/A-better-return-in-org-mode/][A better return in Org mode]] + +#+begin_src emacs-lisp + (require 'org-inlinetask) + + (defun scimax/org-return (&optional ignore) + "Add new list item, heading or table row with RET. + A double return on an empty element deletes it. + Use a prefix arg to get regular RET." + (interactive "P") + (if ignore + (org-return) + (cond + + ((eq 'line-break (car (org-element-context))) + (org-return t)) + + ;; Open links like usual, unless point is at the end of a line. + ;; and if at beginning of line, just press enter. + ((or (and (eq 'link (car (org-element-context))) (not (eolp))) + (bolp)) + (org-return)) + + ;; It doesn't make sense to add headings in inline tasks. Thanks Anders + ;; Johansson! + ((org-inlinetask-in-task-p) + (org-return)) + + ;; checkboxes too + ((org-at-item-checkbox-p) + (org-insert-todo-heading nil)) + + ;; lists end with two blank lines, so we need to make sure we are also not + ;; at the beginning of a line to avoid a loop where a new entry gets + ;; created with only one blank line. + ((org-in-item-p) + (if (save-excursion (beginning-of-line) (org-element-property :contents-begin (org-element-context))) + (org-insert-heading) + (beginning-of-line) + (delete-region (line-beginning-position) (line-end-position)) + (org-return))) + + ;; org-heading + ((org-at-heading-p) + (if (not (string= "" (org-element-property :title (org-element-context)))) + (progn (org-end-of-meta-data) + (org-insert-heading-respect-content) + (outline-show-entry)) + (beginning-of-line) + (setf (buffer-substring + (line-beginning-position) (line-end-position)) ""))) + + ;; tables + ((org-at-table-p) + (if (-any? + (lambda (x) (not (string= "" x))) + (nth + (- (org-table-current-dline) 1) + (org-table-to-lisp))) + (org-return) + ;; empty row + (beginning-of-line) + (setf (buffer-substring + (line-beginning-position) (line-end-position)) "") + (org-return))) + + ;; fall-through case + (t + (org-return))))) + + + (define-key org-mode-map (kbd "RET") + 'scimax/org-return) +#+end_src + * Appendices ** Emacs' files *** init.el @@ -683,30 +885,32 @@ ** Ease tangling and loading of Emacs' init #+begin_src emacs-lisp - (defun acdw/tangle-and-load-init () - (interactive) - "If the current buffer is `config.org', tangle it, then byte-compile." + (defun refresh-emacs (&optional disable-load) + (interactive "P") + "Tangle `config.org', then byte-compile the resulting files. + Then, load the byte-compilations unless passed with a prefix argument." (let ((config (expand-file-name "config.org" user-emacs-directory))) - (when (string= (buffer-file-name) config) - (let ((prog-mode-hook nil)) - (require 'org) - (org-babel-tangle-file config) - (org-md-export-to-markdown) - - (dolist (file `(,(expand-file-name "init.el" - user-emacs-directory) - ,(expand-file-name "config.el" - user-emacs-directory))) - (byte-compile-file file t)))))) - - (add-hook 'after-save-hook #'acdw/tangle-and-load-init) - #+end_src + (save-mark-and-excursion + (with-current-buffer (find-file config) + (let ((prog-mode-hook nil)) + ;; generate the readme + (require 'ox-md) + (org-md-export-to-markdown) + ;; tangle config.org + (require 'org) + (let ((inits (org-babel-tangle))) + ;; byte-compile resulting files + (dolist (f inits) + (when (string-match "\\.el\\'" f) + (byte-compile-file f (not disable-load)))))))))) + #+end_src + ** License :PROPERTIES: :header-args: :tangle LICENSE :comments no :END: - Copyright © 2020 Case Duckworth + Copyright © 2020 Case Duckworth This work is free. You can redistribute it and/or modify it under the terms of the Do What the Fuck You Want To Public License, Version 2, @@ -736,3 +940,9 @@ GPL, for what should be fairly obvious reasons. To that, I say: *SUE ME, RMS!* + +** Keymaps for /this/ file + +This isn’t working … yet. + +#+KEYMAP: C-c C-v t | refresh-emacs -- cgit 1.4.1-21-gabe81