From 6707795b084ac2fbcd0ee915ad91105e238415f0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 18 Mar 2021 22:47:28 -0500 Subject: Whitespace? --- init.el | 382 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 207 insertions(+), 175 deletions(-) diff --git a/init.el b/init.el index 9423887..046fdc3 100644 --- a/init.el +++ b/init.el @@ -42,31 +42,31 @@ ;; I don't want `visual-line-mode', because I really only want to wrap and ;; truncate lines. Believe me, I know what I'm doing. (acdw/set '((word-wrap t) - (truncate-lines t))) + (truncate-lines t))) ;; Whitespace (acdw/set '((whitespace-style - (empty indentation space-before-tab space-after-tab)) - (indent-tabs-mode nil "We've lost this battle...") - (tab-width 8))) + (empty indentation space-before-tab space-after-tab)) + (indent-tabs-mode nil "We've lost this battle...") + (tab-width 4))) (add-hook 'before-save-hook #'whitespace-cleanup) ;; Pairs (add-hook 'prog-mode-hook #'electric-pair-local-mode) (acdw/set '((show-paren-delay 0) - (show-paren-style mixed) - (show-paren-when-point-inside-paren t) - (show-paren-when-point-in-periphery t))) + (show-paren-style mixed) + (show-paren-when-point-inside-paren t) + (show-paren-when-point-in-periphery t))) (show-paren-mode +1) ;; Killing & Yanking (delete-selection-mode +1) (acdw/set '((save-interprogram-paste-before-kill t) - (yank-pop-change-selection t) - (x-select-enable-clipboard t) - (x-select-enable-primary t) - (mouse-drag-copy-region t) - (kill-do-not-save-duplicates t))) + (yank-pop-change-selection t) + (x-select-enable-clipboard t) + (x-select-enable-primary t) + (mouse-drag-copy-region t) + (kill-do-not-save-duplicates t))) ;; Encoding (set-charset-priority 'unicode) @@ -77,39 +77,39 @@ (set-keyboard-coding-system 'utf-8-unix) (set-selection-coding-system 'utf-8-unix) (acdw/set '((locale-coding-system utf-8-unix) - (coding-system-for-read utf-8-unix) - (coding-system-for-write utf-8-unix) - (buffer-file-coding-system utf-8-unix) - (org-export-coding-system utf-8-unix) - (org-html-coding-system utf-8-unix) - (default-process-coding-system (utf-8-unix . utf-8-unix)) - (x-select-request-type (UTF8_STRING COMPOUND_TEXT TEXT STRING)))) + (coding-system-for-read utf-8-unix) + (coding-system-for-write utf-8-unix) + (buffer-file-coding-system utf-8-unix) + (org-export-coding-system utf-8-unix) + (org-html-coding-system utf-8-unix) + (default-process-coding-system (utf-8-unix . utf-8-unix)) + (x-select-request-type (UTF8_STRING COMPOUND_TEXT TEXT STRING)))) ;; Unique buffer names (when (require 'uniquify) (acdw/set '((uniquify-buffer-name-style forward) - (uniquify-separator "/") - (uniquify-after-kill-buffer-p t) - (uniquify-ignore-buffers-re "^\\*")))) + (uniquify-separator "/") + (uniquify-after-kill-buffer-p t) + (uniquify-ignore-buffers-re "^\\*")))) ;; Backups (acdw/set `((backup-by-copying t) - (delete-old-versions -1) - (version-control t) - (vc-make-backup-files t) - (backup-directory-alist ((".*" . ,(acdw/in-dir "backup/" t)))))) + (delete-old-versions -1) + (version-control t) + (vc-make-backup-files t) + (backup-directory-alist ((".*" . ,(acdw/in-dir "backup/" t)))))) ;; Autosaves (acdw/set `((auto-save-file-name-transforms - ((".*" ,(acdw/in-dir "auto-save/" t) t))) - (auto-save-list-file-prefix - ,(acdw/in-dir "auto-save-list/.saves-" t)))) + ((".*" ,(acdw/in-dir "auto-save/" t) t))) + (auto-save-list-file-prefix + ,(acdw/in-dir "auto-save-list/.saves-" t)))) (auto-save-visited-mode +1) (defun hook--auto-save-when-unfocused () "Save all buffers when out of focus." (acdw/when-unfocused #'save-some-buffers t)) (add-function :after after-focus-change-function - #'hook--auto-save-when-unfocused) + #'hook--auto-save-when-unfocused) ;; Auto-revert (when (require 'autorevert) @@ -135,7 +135,7 @@ ;; Cursor (acdw/set '((cursor-type bar) - (cursor-in-non-selected-windows hollow))) + (cursor-in-non-selected-windows hollow))) (defun hook--overwrite-mode-change-cursor () (setq cursor-type (if overwrite-mode 'hbar 'bar))) @@ -143,113 +143,113 @@ ;; Scrolling (acdw/set '((auto-window-vscroll nil) - (fast-but-imprecise-scrolling t) - (scroll-margin 0) - (scroll-conservatively 101) - (scroll-preserve-screen-position 1))) + (fast-but-imprecise-scrolling t) + (scroll-margin 0) + (scroll-conservatively 101) + (scroll-preserve-screen-position 1))) ;; Bindings (acdw/binds (("C-h" ehelp-command :after ("ehelp" nil nil 'keymap)) - ([remap just-one-space] cycle-spacing) - ("M-/" hippie-expand) - ("M-=" count-words) - ("C-x C-b" ibuffer))) + ([remap just-one-space] cycle-spacing) + ("M-/" hippie-expand) + ("M-=" count-words) + ("C-x C-b" ibuffer))) ;;; Startup (acdw/set `((inhibit-startup-screen t) - (initial-buffer-choice t) - (initial-scratch-message - ,(concat ";; Howdy, " - (nth 0 (split-string user-full-name)) "!" - " Welcome to GNU Emacs.\n\n")))) + (initial-buffer-choice t) + (initial-scratch-message + ,(concat ";; Howdy, " + (nth 0 (split-string user-full-name)) "!" + " Welcome to GNU Emacs.\n\n")))) ;;; Minibuffer (acdw/set '((minibuffer-prompt-properties (read-only t - cursor-intangible t - face minibuffer-prompt)) - (enable-recursive-minibuffers t) - (file-name-shadow-properties (invisible t)))) + cursor-intangible t + face minibuffer-prompt)) + (enable-recursive-minibuffers t) + (file-name-shadow-properties (invisible t)))) (minibuffer-depth-indicate-mode +1) (file-name-shadow-mode +1) ;; Save history (when (require 'savehist) (acdw/set `((savehist-additional-variables - (kill-ring search-ring regexp-search-ring)) - (history-length t) - (history-delete-duplicates t) - (savehist-autosave-interval 6) - (savehist-file ,(acdw/in-dir "savehist.el")))) + (kill-ring search-ring regexp-search-ring)) + (history-length t) + (history-delete-duplicates t) + (savehist-autosave-interval 6) + (savehist-file ,(acdw/in-dir "savehist.el")))) (savehist-mode +1)) ;; Icomplete (-vertical) (when (require 'icomplete) (acdw/set '((completion-ignore-case t) - (read-buffer-completion-ignore-case t) - (icomplete-delay-completions-threshold 0) - (icomplete-max-delay-chars 0) - (icomplete-compute-delay 0) - (icomplete-show-matches-on-no-input t) - (icomplete-with-buffer-completion-tables t) - (icomplete-in-buffer t))) + (read-buffer-completion-ignore-case t) + (icomplete-delay-completions-threshold 0) + (icomplete-max-delay-chars 0) + (icomplete-compute-delay 0) + (icomplete-show-matches-on-no-input t) + (icomplete-with-buffer-completion-tables t) + (icomplete-in-buffer t))) (acdw/pkg orderless :set '((completion-styles (orderless)))) (acdw/pkg icomplete-vertical :binds (("" icomplete-forward-completions - :map icomplete-minibuffer-map) - ("C-n" icomplete-forward-completions - :map icomplete-minibuffer-map) - ("" icomplete-backward-completions - :map icomplete-minibuffer-map) - ("C-p" icomplete-backward-completions - :map icomplete-minibuffer-map) - ("C-v" icomplete-vertical-toggle - :map icomplete-minibuffer-map)) + :map icomplete-minibuffer-map) + ("C-n" icomplete-forward-completions + :map icomplete-minibuffer-map) + ("" icomplete-backward-completions + :map icomplete-minibuffer-map) + ("C-p" icomplete-backward-completions + :map icomplete-minibuffer-map) + ("C-v" icomplete-vertical-toggle + :map icomplete-minibuffer-map)) :now ((fido-mode -1) - (icomplete-mode +1) - (icomplete-vertical-mode +1)))) + (icomplete-mode +1) + (icomplete-vertical-mode +1)))) ;; Consult (acdw/pkg consult :binds (;; C-c bindings (`mode-specific-map') - ("C-c h" consult-history) - ("C-c m" consult-mode-command) - ;; C-x bindings (`ctl-x-map') - ("C-x M-:" consult-complex-command) - ("C-x b" consult-buffer) - ("C-x 4 b" consult-buffer-other-window) - ("C-x 5 b" consult-buffer-other-frame) - ("C-x r x" consult-register) - ("C-x r b" consult-bookmark) - ;; M-g bindings (`goto-map') - ("M-g o" consult-outline) - ("M-g m" consult-mark) - ("M-g k" consult-global-mark) - ("M-g i" consult-imenu) - ("M-g e" consult-error) - ;; M-s bindings (`search-map') - ("M-s g" consult-grep) ; alts: - ; consult-git-grep, - ; consult-ripgrep - ("M-s f" consult-find) ; alts: - ; consult-locate - ("M-s l" consult-line) - ("M-s m" consult-multi-occur) - ("M-s k" consult-keep-lines) - ("M-s u" consult-focus-lines) - ;; Other bindings - ("M-y" consult-yank-pop) - (" a" consult-apropos) - ("C-h a" consult-apropos)) + ("C-c h" consult-history) + ("C-c m" consult-mode-command) + ;; C-x bindings (`ctl-x-map') + ("C-x M-:" consult-complex-command) + ("C-x b" consult-buffer) + ("C-x 4 b" consult-buffer-other-window) + ("C-x 5 b" consult-buffer-other-frame) + ("C-x r x" consult-register) + ("C-x r b" consult-bookmark) + ;; M-g bindings (`goto-map') + ("M-g o" consult-outline) + ("M-g m" consult-mark) + ("M-g k" consult-global-mark) + ("M-g i" consult-imenu) + ("M-g e" consult-error) + ;; M-s bindings (`search-map') + ("M-s g" consult-grep) ; alts: + ; consult-git-grep, + ; consult-ripgrep + ("M-s f" consult-find) ; alts: + ; consult-locate + ("M-s l" consult-line) + ("M-s m" consult-multi-occur) + ("M-s k" consult-keep-lines) + ("M-s u" consult-focus-lines) + ;; Other bindings + ("M-y" consult-yank-pop) + (" a" consult-apropos) + ("C-h a" consult-apropos)) :now ((autoload 'consult-register-preview "consult")) :set '((register-preview-delay 0) - (register-preview-function #'consult-register-preview))) + (register-preview-function #'consult-register-preview))) ;; Marginalia (acdw/pkg marginalia :set '((marginalia-annotators (marginalia-annotators-heavy - marginalia-annotators-light))) + marginalia-annotators-light))) :now ((marginalia-mode +1))) ;; Imenu @@ -264,27 +264,27 @@ ;; Undo-fu (acdw/pkg undo-fu :binds (("C-/" undo-fu-only-undo) - ("C-?" undo-fu-only-redo))) + ("C-?" undo-fu-only-redo))) (acdw/pkg undo-fu-session :set `((undo-fu-session-incompatible-files ("/COMMIT_EDITMSG\\'" - "/git-rebase-todo\\'")) - (undo-fu-session-directory ,(acdw/in-dir "undo/" t))) + "/git-rebase-todo\\'")) + (undo-fu-session-directory ,(acdw/in-dir "undo/" t))) :then ((global-undo-fu-session-mode +1))) ;; Modus themes (acdw/pkg (modus-themes - :host gitlab - :repo "protesilaos/modus-themes") + :host gitlab + :repo "protesilaos/modus-themes") :set `((modus-themes-slanted-constructs t) - (modus-themes-bold-constructs t) - (modus-themes-region 'bg-only) - (modus-themes-org-blocks 'grayscale) - (modus-themes-headings ((1 . section) - (t . no-color))) - (modus-themes-scale-headings nil) - (modus-themes-mode-line nil)) + (modus-themes-bold-constructs t) + (modus-themes-region 'bg-only) + (modus-themes-org-blocks 'grayscale) + (modus-themes-headings ((1 . section) + (t . no-color))) + (modus-themes-scale-headings nil) + (modus-themes-mode-line nil)) :now ((acdw/sunrise-sunset #'modus-themes-load-operandi - #'modus-themes-load-vivendi))) + #'modus-themes-load-vivendi))) ;; Expand-region (acdw/pkg expand-region @@ -293,12 +293,12 @@ ;; CRUX (acdw/pkg crux :binds (("M-o" crux-other-window-or-switch-buffer) - ([remap move-beginning-of-line] crux-move-beginning-of-line) - ([remap kill-line] crux-kill-and-join-forward))) + ([remap move-beginning-of-line] crux-move-beginning-of-line) + ([remap kill-line] crux-kill-and-join-forward))) ;;; Frame title (acdw/set `((frame-title-format - "%b %+%* GNU Emacs"))) + "%b %+%* GNU Emacs"))) ;;; Mode line @@ -308,19 +308,19 @@ ;; Simple mode line (acdw/pkg simple-modeline :set '((simple-modeline-segments - ((;; left - acdw-modeline/modified - acdw-modeline/buffer-name - simple-modeline-segment-position - simple-modeline-segment-word-count) - (;; right - acdw-modeline/vc-branch - simple-modeline-segment-misc-info - simple-modeline-segment-process - acdw-modeline/minions - simple-modeline-segment-major-mode)))) + ((;; left + acdw-modeline/modified + acdw-modeline/buffer-name + simple-modeline-segment-position + simple-modeline-segment-word-count) + (;; right + acdw-modeline/vc-branch + simple-modeline-segment-misc-info + simple-modeline-segment-process + acdw-modeline/minions + simple-modeline-segment-major-mode)))) :now ((require 'acdw-modeline) - (simple-modeline-mode +1))) + (simple-modeline-mode +1))) ;;; Magit @@ -330,75 +330,75 @@ ;;; Web browsing (acdw/set '((browse-url-browser-function browse-url-firefox) - (browse-url-new-window-flag t) - (browse-url-firefox-new-window-is-tab t) - (shr-max-width fill-column) - (shr-width fill-column))) + (browse-url-new-window-flag t) + (browse-url-firefox-new-window-is-tab t) + (shr-max-width fill-column) + (shr-width fill-column))) (when (eq acdw/system :work) (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox")) (acdw/hooks ((text-mode-hook goto-address-mode) - (prog-mode-hook goto-address-prog-mode))) + (prog-mode-hook goto-address-prog-mode))) ;;; Dired (acdw/pkg dired :local t :set `((dired-recursive-copies always) - (dired-recursive-deletes always) - (delete-by-moving-to-trash t) - (dired-listing-switches "-Al") - (ls-lisp-dirs-first t) - (dired-dwim-target t)) + (dired-recursive-deletes always) + (delete-by-moving-to-trash t) + (dired-listing-switches "-Al") + (ls-lisp-dirs-first t) + (dired-dwim-target t)) :now ((autoload 'dired-mode-map "dired" nil nil 'keymap) - (acdw/pkg dired-subtree) - (acdw/pkg dired-x - :local t - :binds (("C-x C-j" dired-jump))) - (acdw/pkg dired-collapse - :hooks ((dired-mode-hook dired-collapse-mode))) - (defun hook--dired-mode () - (hl-line-mode +1) - (dired-hide-details-mode +1))) + (acdw/pkg dired-subtree) + (acdw/pkg dired-x + :local t + :binds (("C-x C-j" dired-jump))) + (acdw/pkg dired-collapse + :hooks ((dired-mode-hook dired-collapse-mode))) + (defun hook--dired-mode () + (hl-line-mode +1) + (dired-hide-details-mode +1))) :hooks ((dired-mode-hook hook--dired-mode)) :binds (("i" dired-subtree-toggle :map dired-mode-map))) ;;; Eshell (acdw/set `((eshell-directory-name ,(acdw/in-dir "eshell/" t)) - (eshell-aliases-file ,(acdw/in-dir "eshell/aliases" t)))) + (eshell-aliases-file ,(acdw/in-dir "eshell/aliases" t)))) ;;; Org-mode (acdw/pkg (org - :repo "https://code.orgmode.org/bzg/org-mode.git") + :repo "https://code.orgmode.org/bzg/org-mode.git") :now ((require 'acdw-org)) :set `((org-directory "~/org") - (org-hide-emphasis-markers t) - (org-fontify-whole-heading-line t) - (org-fontify-done-headline t) - (org-fontify-quote-and-verse-blocks t) - (org-src-fontify-natively t) - (org-pretty-entities t) - (org-tags-column ,(- 0 fill-column -3)) - (org-src-tab-acts-natively t) - (org-src-window-setup current-window) - (org-confirm-babel-evaluate nil) - (org-adapt-indentation nil) - (org-catch-invisible-edits smart) - (org-special-ctrl-a/e t) - (org-special-ctrl-k t) - (org-imenu-depth 3) - (org-export-headline-levels 8) - (org-export-with-smart-quotes t) - (org-export-with-sub-superscripts t)) + (org-hide-emphasis-markers t) + (org-fontify-whole-heading-line t) + (org-fontify-done-headline t) + (org-fontify-quote-and-verse-blocks t) + (org-src-fontify-natively t) + (org-pretty-entities t) + (org-tags-column ,(- 0 fill-column -3)) + (org-src-tab-acts-natively t) + (org-src-window-setup current-window) + (org-confirm-babel-evaluate nil) + (org-adapt-indentation nil) + (org-catch-invisible-edits smart) + (org-special-ctrl-a/e t) + (org-special-ctrl-k t) + (org-imenu-depth 3) + (org-export-headline-levels 8) + (org-export-with-smart-quotes t) + (org-export-with-sub-superscripts t)) :hooks ((before-save-hook acdw/hook--org-mode-fix-blank-lines)) :binds (("RET" unpackaged/org-return-dwim - :map org-mode-map :map-after 'org))) + :map org-mode-map :map-after 'org))) ;;; Nov.el -- ebook reader (acdw/pkg nov :now ((autoload #'nov-mode "nov") - (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) + (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) :set `((nov-text-width ,fill-column))) ;;; 0x0 -- upload files @@ -407,9 +407,41 @@ ;;; Programming languages +;; General + +(acdw/pkg reformatter + :now ((require 'reformatter))) + +(acdw/set `((smie-indent-basic ,tab-width))) + +;; Shell(s) +(when (executable-find "shellcheck") + (acdw/pkg flymake-shellcheck + :hooks ((sh-mode-hook (flymake-mode + flymake-shellcheck-load))))) + +(when (executable-find "shfmt") + (reformatter-define shfmt + :program "shfmt" + :lighter " Shfmt") + (defun hook--shfmt-on-save-saving-excursion () + (save-excursion + (shfmt-buffer))) + (acdw/hooks ((sh-mode-hook hook--shfmt-on-save-saving-excursion)))) + +(acdw/set `((sh-basic-offset ,tab-width) + (sh-indent-after-case 0) + (sh-indent-for-case-alt +) + (sh-indent-for-case-label 0))) + +(defun hook--sh-mode-indent-like-shfmt () + "Try to mirror `shfmt' formatting in shell scripts." + (setq indent-tabs-mode t)) +(add-hook 'sh-mode-hook #'hook--sh-mode-indent-like-shfmt) + ;; Emacs lisp (acdw/set '((eval-expression-print-length nil) - (eval-expression-print-level nil))) + (eval-expression-print-level nil))) (when (require 'cl-lib) (setq-default lisp-indent-function #'common-lisp-indent-function) @@ -427,8 +459,8 @@ ;;; Miscellaneous (acdw/set '((disabled-command-function nil) - (load-prefer-newer t) - (comp-async-report-warnings-errors nil))) + (load-prefer-newer t) + (comp-async-report-warnings-errors nil))) (fset 'yes-or-no-p #'y-or-n-p) @@ -444,6 +476,6 @@ (defun hook--gc-when-unfocused () (acdw/when-unfocused #'garbage-collect)) (add-function :after after-focus-change-function - #'hook--gc-when-unfocused) + #'hook--gc-when-unfocused) ;;; init.el ends here -- cgit 1.4.1-21-gabe81