Commit fc58733deaeb

Vincent Demeester <vincent@sbr.pm>
2020-09-25 14:43:45
tools/emacs: load way less when noninteractive
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 4977449
tools/emacs/config/config-appearance.el
@@ -2,6 +2,8 @@
 ;;; Commentary:
 ;;; Appearance configuration
 ;;; Code:
+(declare-function projectile-project-name "projectile")
+
 (use-package emacs
   :defer 3
   :bind ("C-c f r" . mu-reset-fonts)
@@ -45,6 +47,7 @@
   (global-unset-key (kbd "C-h h")))
 
 (use-package frame
+  :unless noninteractive
   :commands vde/cursor-type-mode
   :config
   (setq-default cursor-type 'box)
@@ -91,6 +94,7 @@ Ignores `ARGS'."
   :hook (after-init . window-divider-mode))
 
 (use-package tab-bar
+  :unless noninteractive
   :config
   (setq-default tab-bar-close-button-show nil)
   (setq-default tab-bar-close-last-tab-choice 'tab-bar-mode-disable)
@@ -131,6 +135,7 @@ questions.  Else use completion to select the tab to switch to."
          ("C-x t s" . tab-switcher)))
 
 (use-package moody
+  :unless noninteractive
   :config
   (setq-default x-underline-at-descent-line t
                 ;; Show buffer position percentage starting from top
@@ -158,6 +163,7 @@ questions.  Else use completion to select the tab to switch to."
   (moody-replace-vc-mode))
 
 (use-package minions
+  :unless noninteractive
   :config
   (setq-default minions-mode-line-lighter "λ="
                 minions-mode-line-delimiters '("" . "")
@@ -165,6 +171,7 @@ questions.  Else use completion to select the tab to switch to."
   (minions-mode +1))
 
 (use-package time
+  :unless noninteractive
   :config
   (setq-default display-time-24hr-format t
                 display-time-day-and-date t
@@ -180,23 +187,9 @@ questions.  Else use completion to select the tab to switch to."
                           monthname day
                           24-hours minutes)))
   (display-time))
-;; -UseMoody
-
-(use-package face-remap
-  :diminish buffer-face-mode            ; the actual mode
-  :commands vde/variable-pitch-mode
-  :config
-  (define-minor-mode vde/variable-pitch-mode
-    "Toggle `variable-pitch-mode', except for `prog-mode'."
-    :init-value nil
-    :global nil
-    (if vde/variable-pitch-mode
-        (unless (derived-mode-p 'prog-mode)
-          (variable-pitch-mode 1))
-      (variable-pitch-mode -1))))
-
 
 (use-package tooltip
+  :unless noninteractive
   :config
   (setq tooltip-delay 0.5)
   (setq tooltip-short-delay 0.5)
tools/emacs/config/config-buffers.el
@@ -3,7 +3,6 @@
 ;;; Buffer related configurations
 ;;; Code:
 
-;; UseDisplayBuffers
 (use-package emacs
   :unless noninteractive
   :config
@@ -20,7 +19,7 @@
                    (window-height . 0.25)
                    (side . bottom)
                    (slot . -1))
-                  (".*\\*\\(Completions\\|Embark Live Occur\\).*"
+                  (".*\\*\\(Completions\\).*"
                    (display-buffer-in-side-window)
                    (window-height . 0.16)
                    (side . bottom)
@@ -59,20 +58,12 @@
                    (slot . -1))
                   ("\\*\\(Flycheck\\|Package-Lint\\).*"
                    (display-buffer-in-side-window)
-                   (window-width . 0.20)
+                   (window-width . 0.40)
                    (side . right)
                    (slot . 0)
                    (window-parameters . ((no-other-window . t)
                                          (mode-line-format . (" "
                                                               mode-line-buffer-identification)))))
-                  ("\\*Faces\\*"
-                   (display-buffer-in-side-window)
-                   (window-width . 0.20)
-                   (side . right)
-                   (slot . 1)
-                   (window-parameters . ((no-other-window . t)
-                                         (mode-line-format . (" "
-                                                              mode-line-buffer-identification)))))
                   ("\\*Custom.*"
                    (display-buffer-in-side-window)
                    (window-width . 0.20)
@@ -84,9 +75,7 @@
   (setq window-combination-resize t) ; Size new windows proportionally
   :bind (("C-x +" . balance-windows-area)
          ("<C-f7>" . window-toggle-side-windows)))
-;; -UseDisplayBuffer
 
-;; UseSaveHist
 (use-package savehist
   :unless noninteractive
   :config
@@ -99,21 +88,20 @@
                                                 comint-input-ring
                                                 compile-history
                                                 last-kbd-macro
-                                                shell-command-history))
+                                                shell-command-history
+                                                projectile-project-command-history))
   (savehist-mode 1))
-;; -UseSaveHist
 
-;; UseUniquify
 (use-package uniquify
+  :unless noninteractive
   :config
   (setq-default uniquify-buffer-name-style 'post-forward
                 uniquify-separator ":"
                 uniquify-ignore-buffers-re "^\\*"
                 uniquify-after-kill-buffer-p t))
-;; -UseUniquify
 
-;; UseIBuffer
 (use-package ibuffer
+  :unless noninteractive
   :commands (ibuffer)
   :bind (("C-x C-b" . ibuffer)
          ([remap list-buffers] . ibuffer))
@@ -152,12 +140,12 @@
                 filename-and-process))))
 
 (use-package ibuffer-vc
+  :unless noninteractive
   :commands (ibuffer-vc-set-filter-groups-by-vc-root)
   :hook (ibuffer . (lambda ()
                      (ibuffer-vc-set-filter-groups-by-vc-root)
                      (unless (eq ibuffer-sorting-mode 'filename/process)
                        (ibuffer-do-sort-by-filename/process)))))
-;; -UseIBuffer
 
 (provide 'config-buffers)
 ;;; config-buffers.el ends here
tools/emacs/config/config-compile.el
@@ -5,6 +5,7 @@
 
 ;; UseCompile
 (use-package compile
+  :unless noninteractive
   :commands (compile)
   :preface
   (autoload 'ansi-color-apply-on-region "ansi-color")
@@ -64,11 +65,11 @@
                  "\\)"))
   (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer)
   (add-hook 'compilation-mode-hook #'vde/goto-address-mode))
-;; -UseCompile
 
-;; UseFlycheck
+;; FIXME(vdemeester) switch to flymake instead
 (use-package flycheck
-  :if (not (eq system-type 'windows-nt))
+  :if (and (not noninteractive)
+           (not (eq system-type 'windows-nt)))
   :hook (prog-mode . flycheck-mode)
   :commands (flycheck-mode flycheck-next-error flycheck-previous-error)
   :init
tools/emacs/config/config-completion.el
@@ -3,8 +3,8 @@
 ;;; Setup completion framework
 ;;; Code
 
-;; UseOrderless
 (use-package orderless
+  :unless noninteractive
   :config
   (setq orderless-regexp-separator " +")
   (setq orderless-matching-styles
@@ -25,9 +25,7 @@
                                       prot/orderless-initialism-dispatcher))
   :bind (:map minibuffer-local-completion-map
               ("SPC" . nil)))         ; space should never complete
-;; -UseOrderless
 
-;; UseMinibuffer
 (use-package minibuffer
   :unless noninteractive
   :config
@@ -117,9 +115,7 @@ instead."
          ("f" . next-completion)
          ("b" . previous-completion)
          ("M-v" . vde/focus-minibuffer)))
-;; -UseMinibuffer
 
-;; UseIComplete
 (use-package icomplete
   :demand
   :unless noninteractive
@@ -206,10 +202,9 @@ Otherwise, use `projectile-switch-to-project'."
                       (interactive)
                       (let ((current-prefix-arg t))
                         (vde/icomplete-toggle-completion-styles))))))
-;; -UseIComplete
 
-;; UseIcompleteVertical
 (use-package icomplete-vertical
+  :unless noninteractive
   :demand
   :after (minibuffer icomplete) ; do not forget to check those as well
   :config
@@ -240,18 +235,7 @@ normally would when calling `yank' followed by `yank-pop'."
   :bind (("C-M-y" . vde/icomplete-yank-kill-ring)
          :map icomplete-minibuffer-map
          ("C-v" . icomplete-vertical-toggle)))
-;; -UseIcompleteVertical
 
-;; FIXME: choose better shortcuts
-(use-package avy-embark-occur
-  :disabled
-  :load-path "~/.config/emacs/lisp/embark/" ; in development
-  :bind
-  (:map minibuffer-local-completion-map
-        ("'" . avy-embark-occur-choose)
-        ("\"" . avy-embark-occur-act)))
-
-;; UseCompany
 (use-package company
   :unless noninteractive
   :hook ((prog-mode . company-mode))
@@ -310,7 +294,5 @@ normally would when calling `yank' followed by `yank-pop'."
     (set (make-local-variable 'company-backends) '(company-emoji))
     (company-mode t)))
 
-;; -UseCompany
-
 (provide 'config-completion)
 ;;; config-completion.el ends here
tools/emacs/config/config-dired.el
@@ -5,6 +5,7 @@
 
 ;; UseDired
 (use-package dired
+  :unless noninteractive
   :commands (dired find-name-dired)
   :bind (("C-c RET" . vde/open-in-external-app)
          ("C-c f g" . vde/dired-get-size)
@@ -158,6 +159,7 @@ This relies on the external 'fd' executable."
 
 ;; UseDireAux
 (use-package dired-aux
+  :unless noninteractive
   :after dired
   :config
   (setq-default
@@ -169,6 +171,7 @@ This relies on the external 'fd' executable."
 
 ;; UseDiredCollapse
 (use-package dired-collapse
+  :unless noninteractive
   :commands (dired-collapse-mode)
   :hook (dired-mode . dired-collapse-mode))
 ;; -UseDiredCollapse
@@ -176,6 +179,7 @@ This relies on the external 'fd' executable."
 ;; UseDiredAsync
 (use-package async)
 (use-package dired-async
+  :unless noninteractive
   :after (dired async)
   :commands (dired-async-mode)
   :hook (dired-mode . dired-async-mode))
@@ -183,6 +187,7 @@ This relies on the external 'fd' executable."
 
 ;; UseDiredNarrow
 (use-package dired-narrow
+  :unless noninteractive
   :after dired
   :commands (dired-narrow)
   :bind (:map dired-mode-map
@@ -195,6 +200,7 @@ This relies on the external 'fd' executable."
 
 ;; UseWDired
 (use-package wdired
+  :unless noninteractive
   :after dired
   :commands (wdired-mode
              wdired-change-to-wdired-mode)
@@ -205,6 +211,7 @@ This relies on the external 'fd' executable."
 
 ;; UseDiredRsync
 (use-package dired-rsync
+  :unless noninteractive
   :after dired
   :commands (dired-rsync)
   :bind (:map dired-mode-map
@@ -212,6 +219,7 @@ This relies on the external 'fd' executable."
 ;; -UseDiredRsync
 
 (use-package dired-subtree
+  :unless noninteractive
   :after dired
   :config
   (setq dired-subtree-use-backgrounds nil)
@@ -221,6 +229,7 @@ This relies on the external 'fd' executable."
               ("<S-iso-lefttab>" . dired-subtree-remove)))
 
 (use-package diredfl
+  :unless noninteractive
   :commands (diredfl-mode)
   :config
   (setq diredfl-ignore-compressed-flag nil)
tools/emacs/config/config-editing.el
@@ -16,6 +16,7 @@
 
 ;; UseSmartParens
 (use-package smartparens
+  :unless noninteractive
   :commands (smartparens-mode smartparens-global-mode show-smartparens-global-mode
                               sp-split-sexp sp-newline sp-up-sexp)
   :hook ((prog-mode . turn-on-smartparens-mode)
@@ -41,6 +42,7 @@
 ;; -UseSmartParens
 
 (use-package color-identifiers-mode
+  :unless noninteractive
   :commands (color-identifiers-mode)
   :config
   (setq-default color-identifiers:num-colors 15
@@ -65,6 +67,7 @@
 
 ;; UseAggressiveIndent
 (use-package aggressive-indent
+  :unless noninteractive
   :bind ("C-c e i" . aggressive-indent-mode)
   :hook ((lisp-mode       . aggressive-indent-mode)
          (emacs-lisp-mode . aggressive-indent-mode))
@@ -75,6 +78,7 @@
 
 ;; UseUndoTree
 (use-package undo-tree
+  :unless noninteractive
   :hook (after-init . global-undo-tree-mode)
   :config
   (setq-default undo-tree-visualizer-timestamps t
@@ -83,6 +87,7 @@
 
 ;; UseWhitespace
 (use-package whitespace
+  :unless noninteractive
   :commands (whitespace-mode vde/toggle-invisibles)
   :config
   (setq-default whitespace-style '(face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark))
@@ -97,28 +102,33 @@
 
 ;; UseExpandRegion
 (use-package expand-region
+  :unless noninteractive
   :commands (er/expand-region er/contract-region)
   :bind (("C-=" . er/expand-region)
          ("C--". er/contract-region)))
 ;; -UseExpandRegiston
 
 (use-package visual-regexp
+  :unless noninteractive
   :commands (vr/replace vr/query-replace)
   :bind (("C-c r"   . vr/replace)
          ("C-c %"   . vr/query-replace)))
 
 ;; UseHideShow
 (use-package hs-minor-mode
+  :unless noninteractive
   :hook ((prog-mode . hs-minor-mode)))
 ;; -UseHideShow
 
 (use-package easy-kill
+  :unless noninteractive
   :commands (easy-kill)
   :config
   (global-set-key [remap kill-ring-save] 'easy-kill)
   (global-set-key [remap mark-sexp] 'easy-mark))
 
 (use-package display-line-numbers
+  :unless noninteractive
   :hook (prog-mode . display-line-numbers-mode)
   :config
   (setq-default display-line-numbers-type 'relative)
@@ -133,6 +143,7 @@
 (add-hook 'prog-mode-hook 'toggle-truncate-lines)
 
 (use-package newcomment
+  :unless noninteractive
   :config
   (setq-default comment-empty-lines t
                 comment-fill-column nil
@@ -160,6 +171,7 @@ Else toggle the comment status of the line at point."
 
 ;; FIXME(vdemeester) Do I need on-the-fly spellcheck *or* not ?
 (use-package flyspell
+  :unless noninteractive
   :commands (flyspell-prog-mode flyspell-mode)
   :hook((text-mode . flyspell-mode)
         (prog-mode . flyspell-prog-mode))
@@ -190,10 +202,12 @@ Else toggle the comment status of the line at point."
   :hook (before-save . delete-trailing-whitespace))
 
 (use-package delsel
+  :unless noninteractive
   :config
   (delete-selection-mode 1))
 
 (use-package emacs
+  :unless noninteractive
   :custom
   (repeat-on-final-keystroke t)
   (set-mark-command-repeat-pop t)
@@ -238,24 +252,8 @@ instead.  This command can then be followed by the standard
          ("<C-f6>" . tear-off-window)
          ("C-S-y" . prot/yank-replace-line-or-region)))
 
-(use-package crux
-  :disabled
-  :commands (crux-transpose-windows
-             crux-duplicate-current-line-or-region
-             crux-rename-file-and-buffer
-             crux-open-with)
-  :bind (("C-c w S" . crux-transpose-windows)
-         ("C-c d" . crux-duplicate-current-line-or-region)
-         ("<C-f2>" . crux-rename-file-and-buffer)
-         :map dired-mode-map
-         ("<M-return>" . crux-open-with)))
-
-(use-package goto-last-change
-  :disabled
-  :commands goto-last-change
-  :bind ("C-z" . goto-last-change))
-
 (use-package pdf-tools
+  :unless noninteractive
   :mode  ("\\.pdf\\'" . pdf-view-mode)
   :config
   (setq-default pdf-view-display-size 'fit-page)
@@ -265,10 +263,12 @@ instead.  This command can then be followed by the standard
   (require 'pdf-occur))
 
 (use-package paste-sbr
+  :unless noninteractive
   :commands (htmlize-paste-it)
   :bind ("C-c e p" . htmlize-paste-it))
 
 (use-package scratch
+  :unless noninteractive
   :commands (scratch)
   :config
   (defun vde/scratch-buffer-setup ()
@@ -298,6 +298,7 @@ If region is active, add its contents to the new buffer."
   :hook (prog-mode-hook . subword-mode))
 
 (use-package whole-line-or-region
+  :unless noninteractive
   :config
   (whole-line-or-region-global-mode))
 
tools/emacs/config/config-files.el
@@ -19,16 +19,11 @@
   :config (envrc-global-mode))
 
 
-;; UseHardHat
 (use-package hardhat
   :init (global-hardhat-mode))
-;; -UseHardhat
-
-(use-package image-file
-  :disabled
-  :init (auto-image-file-mode))
 
 (use-package highlight-indentation
+  :unless noninteractive
   :commands (highlight-indentation-mode highlight-indentation-current-column-mode)
   :config
   (set-face-background 'highlight-indentation-face "#e3e3d3")
tools/emacs/config/config-mouse.el
@@ -4,6 +4,7 @@
 ;;; Code:
 
 (use-package mouse
+  :unless noninteractive
   :config
   (setq mouse-wheel-scroll-amount
         '(1
tools/emacs/config/config-navigating.el
@@ -74,6 +74,7 @@ Meant to economise on key bindings."
          ("t" . toggle-truncate-lines)))
 
 (use-package avy
+  :unless noninteractive
   :commands (avy-goto-char avy-goto-line avy-goto-word-1 avy-pop-mark avy-goto-char-timer)
   :bind (("C-c j w"   . avy-goto-word-1)
          ("C-c j b" . avy-pop-mark)
@@ -81,6 +82,7 @@ Meant to economise on key bindings."
          ("C-c j l" . avy-goto-line)))
 
 (use-package hideshow
+  :unless noninteractive
   :commands (hs-show-all hs-toggle-hiding hs-hide-all hs-hide-block hs-hide-level)
   :defer 5
   :bind (("C-c @ a" . hs-show-all)
@@ -90,17 +92,20 @@ Meant to economise on key bindings."
          ("C-c @ l" . hs-hide-level)))
 
 (use-package mwim
+  :unless noninteractive
   :commands (mwim-beginning-of-code-or-line mwim-end-of-code-or-line)
   :bind (:map prog-mode-map
               ("C-a" . mwim-beginning-of-code-or-line)
               ("C-e" . mwim-end-of-code-or-line)))
 
 (use-package beginend
+  :unless noninteractive
   :defer 5
   :config
   (beginend-global-mode 1))
 
 (use-package dumb-jump
+  :unless noninteractive
   :bind (("M-g q"     . dumb-jump-quick-look) ;; Show me in a tooltip.
          ("M-g o" . dumb-jump-go-other-window)
          ("M-g j" . dumb-jump-go)
@@ -116,6 +121,7 @@ Meant to economise on key bindings."
                 dumb-jump-prefer-searcher 'rg))
 
 (use-package imenu
+  :unless noninteractive
   :config
   (setq-default imenu-use-markers t
                 imenu-auto-rescan t
@@ -146,16 +152,19 @@ aggressive fuzzy-style matching for this particular command."
   :bind ("C-'" . prot/imenu-vertical))
 
 (use-package flimenu
+  :unless noninteractive
   :config
   (flimenu-global-mode 1))
 
 (use-package man
+  :unless noninteractive
   :commands (man)
   :bind (:map Man-mode-map
               ("i" . Man-goto-section)
               ("g" . Man-update-manpage)))
 
 (use-package pulse
+  :unless noninteractive
   :config
   (defface vde/pulse-line-modus-theme
     '((t :inherit modus-theme-subtle-green :extend t))
tools/emacs/config/config-projects.el
@@ -6,6 +6,7 @@
 ;;; Code:
 
 (use-package projectile
+  :unless noninteractive
   :commands
   (projectile-ack
    projectile-ag
@@ -78,7 +79,7 @@
      ((eq major-mode 'yaml-mode) "yamllint .")
      (t "go build -v ./...")
      ))
-  
+
   (defun projectile-ko-compile-command-go ()
     "compile command for a ko project if in a go file"
     (let* ((current-file (buffer-file-name (current-buffer)))
@@ -93,7 +94,7 @@
     (cond
      ((eq major-mode 'go-mode) (projectile-ko-test-command-go))
      (t "go test -v ./...")))
-  
+
   (defun projectile-ko-test-command-go ()
     "test command for a ko project if in a go file"
     (let* ((current-file (buffer-file-name (current-buffer)))
@@ -102,19 +103,19 @@
       (cond
        ((string-suffix-p "_test.go" relative-current-file) (projectile-ko-command-go-test relative-current-file))
        (t (format "go test -v ./%s" relative-current-folder)))))
-  
+
   (defun projectile-ko-command-go-test (current-file)
     "get the command for a go test"
     (cond
      ((gotest-module-available-p) (projectile-ko-command-go-test-gotest current-file))
      (t (format "go test -v ./%s" current-file))))
-  
+
   (defun projectile-ko-command-go-test-gotest (current-file)
     "get the command for a go test with gotest module enabled"
     (message default-directory)
     (let ((data (go-test--get-current-file-testing-data)))
       (format "go test -run='%s' -v ./%s" data (file-name-directory current-file))))
-  
+
   (defun gotest-module-available-p ()
     "is go-test module available"
     (fboundp 'go-test--get-current-file-data))
@@ -124,7 +125,7 @@
      ((eq major-mode 'go-mode) (projectile-ko-run-command-go))
      ;; nothing by default ?
      ))
-  
+
   (defun projectile-ko-run-command-go ()
     "test command for a ko project if in a go file"
     (let* ((current-file (buffer-file-name (current-buffer)))
@@ -138,7 +139,7 @@
      ((eq major-mode 'go-mode) (projectile-ko-package-command-go))
      (t "ko resolve --push=false --oci-layout-path=/tmp/oci -f config")
      ))
-  
+
   (defun projectile-ko-package-command-go ()
     "package command for a ko project if in a go file"
     (let* ((current-file (buffer-file-name (current-buffer)))
tools/emacs/config/config-search.el
@@ -5,6 +5,7 @@
 
 ;; UseISearch
 (use-package isearch
+  :unless noninteractive
   :config
   (setq-default search-whitespace-regexp ".*?"
                 isearch-lax-whitespace t
@@ -64,6 +65,7 @@ confines of word boundaries (e.g. multiple words)."
 
 ;; UseWgrep
 (use-package wgrep
+  :unless noninteractive
   :commands (wgrep-change-to-wgrep-mode)
   :defer 2
   :custom
@@ -73,7 +75,8 @@ confines of word boundaries (e.g. multiple words)."
 
 ;; UseRG
 (use-package rg
-  :if *rg*
+  :if (and (*rg*)
+           (not noninteractive))
   :commands (rg rg-project rg-dwim)
   :bind (("M-s r r" . rg)
          ("M-s r p" . rg-project)
tools/emacs/config/config-vcs.el
@@ -73,6 +73,7 @@
 
 ;; UseMagit
 (use-package magit
+  :unless noninteractive
   :commands (magit-status magit-clone magit-pull magit-blame magit-log-buffer-file magit-log)
   :bind (("C-c v c" . magit-clone)
          ("C-c v C" . magit-checkout)
@@ -110,6 +111,8 @@
 
 ;; UseMagitTodos
 (use-package magit-todos
+  :after (magit)
+  :unless noninteractive
   :hook (magit-mode . magit-todos-mode)
   :custom
   (magit-todos-exclude-globs '("node_modules" "vendor" "*.json" "*.html"))
@@ -119,6 +122,7 @@
 
 ;; UseMagitAnnex
 (use-package magit-annex
+  :unless noninteractive
   :after magit)
 ;; -UseMagitAnnex
 
tools/emacs/config/config-windows.el
@@ -13,6 +13,7 @@
 
 ;; UseAceWindow
 (use-package ace-window
+  :unless noninteractive
   :commands (ace-window ace-swap-window)
   :bind (("C-x o"   . ace-window)
          ("C-c w w" . ace-window)
@@ -34,6 +35,7 @@
 
 ;; UseWindmove
 (use-package windmove
+  :unless noninteractive
   :commands (windmove-left windmove-right windmove-down windmove-up)
   :bind (("C-s-<up>" . windmove-up)
          ("C-s-<right>" . windmove-right)