refactor: Begin moving package configuration to use-package

This is the first in a series of commits for refactoring my
configuration to make use of jwiegley's use-package.

In the previous layout of the configuration there were some questions
around what settings go into which file, but in the end it is all just
related to which packages are being configured (besides settings
related to global Emacs behaviour).

This commit introduces use-package forms for all currently used
packages (which are still installed via Nix, not via package.el) but
does not yet clean up the rest of the configuration in a suitable way.

Note that this version introduces a bug in which the configuration of
telephone line is not correctly initialised after package setup.
This commit is contained in:
Vincent Ambo 2018-06-22 10:29:31 +02:00 committed by Vincent Ambo
parent f0dfc8b06d
commit 4fe8d78dbb
10 changed files with 218 additions and 216 deletions

View file

@ -14,16 +14,9 @@
;; Counsel stuff:
(global-set-key (kbd "C-c r g") 'counsel-rg)
;; Avy mode
(global-set-key (kbd "M-j") 'avy-goto-char)
(global-set-key (kbd "M-p") 'avy-pop-mark)
;; imenu instead of insert-file
(global-set-key (kbd "C-x i") 'imenu)
(global-set-key (kbd "C-x o") ; Yes, I went there!
'ace-window)
;; Window switching. (C-x o goes to the next window)
(windmove-default-keybindings) ;; Shift+direction
@ -33,12 +26,7 @@
;; Start a new eshell even if one is active.
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
;; Magit!
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-x p") 'ivy-browse-repositories)
;; Replace standard goto-line with ace-jump-line-mode
(global-set-key (kbd "M-g g") 'avy-goto-line)
(global-set-key (kbd "M-g M-g") 'goto-line-with-feedback)
(global-set-key (kbd "C-c w") 'whitespace-cleanup)

View file

@ -1,5 +0,0 @@
(require 'haskell-mode)
(add-hook 'haskell-mode-hook 'intero-mode)
(provide 'haskell-setup)

View file

@ -1,21 +0,0 @@
;; lisp-settings.el - settings for various Lisp dialects
;; -*- lexical-binding: t; -*-
(require 'adjust-parens)
(require 'sly)
;; All the lisps:
(add-to-list 'lisp-mode-hook #'company-mode)
(add-to-list 'lisp-mode-hook #'paredit-mode)
(add-to-list 'lisp-mode-hook #'adjust-parens-mode)
(define-key lisp-mode-map (kbd "TAB")
#'company-indent-or-complete-common)
;; Common Lisp:
(setq inferior-lisp-program (concat (nix-store-path "sbcl") "/bin/sbcl"))
(add-to-list 'company-backends 'sly-company)
(provide 'lisp-setup)

View file

@ -1,7 +1,5 @@
;;; -*- lexical-binding: t; -*-
(require 'telephone-line)
;; Hide those ugly tool bars:
(tool-bar-mode 0)
(scroll-bar-mode 0)
@ -46,36 +44,37 @@
(when (bottom-right-window-p)
(telephone-line-raw mode-line-misc-info t)))
(telephone-line-defsegment telephone-line-last-window-segment ()
(telephone-misc-if-last-window))
(defun telephone-line-setup ()
(telephone-line-defsegment telephone-line-last-window-segment ()
(telephone-misc-if-last-window))
;; Display the current EXWM workspace index in the mode-line
(telephone-line-defsegment telephone-line-exwm-workspace-index ()
(when (bottom-right-window-p)
(format "[%s]" exwm-workspace-current-index)))
;; Display the current EXWM workspace index in the mode-line
(telephone-line-defsegment telephone-line-exwm-workspace-index ()
(when (bottom-right-window-p)
(format "[%s]" exwm-workspace-current-index)))
;; Define a highlight font for ~ important ~ information in the last
;; window.
(defface special-highlight '((t (:foreground "white" :background "#5f627f"))) "")
(add-to-list 'telephone-line-faces
'(highlight . (special-highlight . special-highlight)))
;; Define a highlight font for ~ important ~ information in the last
;; window.
(defface special-highlight '((t (:foreground "white" :background "#5f627f"))) "")
(add-to-list 'telephone-line-faces
'(highlight . (special-highlight . special-highlight)))
(setq telephone-line-lhs
'((nil . (telephone-line-position-segment))
(accent . (telephone-line-buffer-segment))))
(setq telephone-line-lhs
'((nil . (telephone-line-position-segment))
(accent . (telephone-line-buffer-segment))))
(setq telephone-line-rhs
'((accent . (telephone-line-major-mode-segment))
(nil . (telephone-line-last-window-segment
telephone-line-exwm-workspace-index))
(highlight . (telephone-line-notmuch-counts))))
(setq telephone-line-rhs
'((accent . (telephone-line-major-mode-segment))
(nil . (telephone-line-last-window-segment
telephone-line-exwm-workspace-index))
(highlight . (telephone-line-notmuch-counts))))
(setq telephone-line-primary-left-separator 'telephone-line-tan-left
telephone-line-primary-right-separator 'telephone-line-tan-right
telephone-line-secondary-left-separator 'telephone-line-tan-hollow-left
telephone-line-secondary-right-separator 'telephone-line-tan-hollow-right)
(setq telephone-line-primary-left-separator 'telephone-line-tan-left
telephone-line-primary-right-separator 'telephone-line-tan-right
telephone-line-secondary-left-separator 'telephone-line-tan-hollow-left
telephone-line-secondary-right-separator 'telephone-line-tan-hollow-right)
(telephone-line-mode 1)
(telephone-line-mode 1))
;; Auto refresh buffers
(global-auto-revert-mode 1)

View file

@ -1,14 +1,6 @@
;; Initializes modes I use.
(add-hook 'prog-mode-hook 'esk-add-watchwords)
(add-hook 'prog-mode-hook 'idle-highlight-mode)
;; Configure markdown-mode
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.txt\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; Use auto-complete as completion at point
(defun set-auto-complete-as-completion-at-point-function ()
@ -17,35 +9,18 @@
(add-hook 'auto-complete-mode-hook
'set-auto-complete-as-completion-at-point-function)
;; Configure Erlang mode
(defun erlang-mode-init-setup ()
(interactive)
;; Don't indent after '>' while I'm writing
(local-set-key ">" 'self-insert-command)
;;(local-set-key "RET" 'newline)
(rainbow-delimiters-mode 1)
)
(add-hook 'erlang-mode-hook 'erlang-mode-init-setup)
;; Enable rainbow-delimiters for all things programming
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
;; Enable Paredit & Company in Emacs Lisp mode
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'emacs-lisp-mode-hook 'company-mode)
;; Always highlight matching brackets
(show-paren-mode 1)
;; Always auto-close parantheses and other pairs
(electric-pair-mode)
;; Represent undo-history as an actual tree (visualize with C-x u)
(setq undo-tree-mode-lighter "")
(require 'undo-tree)
(global-undo-tree-mode)
;; (replaced by smartparens)
;; (electric-pair-mode)
;; Keep track of recent files
(recentf-mode)
@ -57,9 +32,5 @@
(auto-compression-mode t)
;; Show available key chord completions
(which-key-mode t)
;; Show previews of ace-window numbers in the mode line for each window.
(ace-window-display-mode)
(provide 'modes)

View file

@ -6,11 +6,6 @@
(require 'f)
(require 'dash)
(defvar is-nixos
(let ((os-f "/etc/os-release"))
(s-contains?
"NixOS" (if (f-file? os-f) (f-read os-f)))))
(defun pulseaudio-ctl (cmd)
(shell-command (concat "pulseaudio-ctl " cmd))
(message "Volume command: %s" cmd))
@ -38,70 +33,68 @@
(0 "eDP1")
,(-map (lambda (n) (list n "eDP1")) (number-sequence 6 9)))))
(if is-nixos
(progn
(message "Running on NixOS, configuring ExWM.")
(require 'exwm)
(require 'exwm-config)
(use-package exwm
:hook ((exwm-update-class . (lambda ()
;; Make class name the buffer name
(exwm-workspace-rename-buffer exwm-class-name))))
:init
(progn
(require 'exwm-config)
(fringe-mode 3)
(fringe-mode 3)
(setq exwm-workspace-number 10)
;; Make class name the buffer name
(add-hook 'exwm-update-class-hook
(lambda ()
(exwm-workspace-rename-buffer exwm-class-name)))
(setq exwm-workspace-number 10)
;; 's-r': Reset
(exwm-input-set-key (kbd "s-r") #'exwm-reset)
;; 's-w': Switch workspace
(exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
;; 's-N': Switch to certain workspace
(dotimes (i 10)
(exwm-input-set-key (kbd (format "s-%d" i))
`(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
;; 's-r': Reset
(exwm-input-set-key (kbd "s-r") #'exwm-reset)
;; 's-w': Switch workspace
(exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
;; 's-N': Switch to certain workspace
(dotimes (i 10)
(exwm-input-set-key (kbd (format "s-%d" i))
`(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
;; Launch applications with completion (dmenu style!)
(exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
(exwm-input-set-key (kbd "s-p") #'ivy-password-store)
(exwm-input-set-key (kbd "C-s-p") '(lambda ()
(interactive)
(ivy-password-store "~/.aprila-secrets")))
;; Launch applications with completion (dmenu style!)
(exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
(exwm-input-set-key (kbd "s-p") #'ivy-password-store)
(exwm-input-set-key (kbd "C-s-p") '(lambda ()
(interactive)
(ivy-password-store "~/.aprila-secrets")))
;; Toggle between line-mode / char-mode
(exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
;; Toggle between line-mode / char-mode
(exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)
;; Volume keys
(exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
(exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
(exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
;; Volume keys
(exwm-input-set-key (kbd "<XF86AudioMute>") #'volume-mute)
(exwm-input-set-key (kbd "<XF86AudioRaiseVolume>") #'volume-up)
(exwm-input-set-key (kbd "<XF86AudioLowerVolume>") #'volume-down)
;; Brightness keys
(exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
(exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
(exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
;; Brightness keys
(exwm-input-set-key (kbd "<XF86MonBrightnessDown>") #'brightness-down)
(exwm-input-set-key (kbd "<XF86MonBrightnessUp>") #'brightness-up)
(exwm-input-set-key (kbd "<XF86Display>") #'lock-screen)
;; Line-editing shortcuts
(exwm-input-set-simulation-keys
'(([?\C-d] . delete)
([?\C-w] . ?\C-c)))
;; Line-editing shortcuts
(exwm-input-set-simulation-keys
'(([?\C-d] . delete)
([?\C-w] . ?\C-c)))
;; Enable EXWM
(exwm-enable)
;; Enable EXWM
(exwm-enable)
;; Show time in the mode line
(display-time-mode)
;; Show time in the mode line
(display-time-mode)
;; Configure xrandr when running on laptop
(when (equal (shell-command-to-string "hostname") "adho\n")
(require 'exwm-randr)
(setq exwm-randr-workspace-output-plist (generate-randr-config))
(exwm-randr-enable))
;; Configure xrandr when running on laptop
(when (equal (shell-command-to-string "hostname") "adho\n")
(require 'exwm-randr)
(setq exwm-randr-workspace-output-plist (generate-randr-config))
(exwm-randr-enable))
;; Let buffers move seamlessly between workspaces
(setq exwm-workspace-show-all-buffers t)
(setq exwm-layout-show-all-buffers t)))
;; Let buffers move seamlessly between workspaces
(setq exwm-workspace-show-all-buffers t)
(setq exwm-layout-show-all-buffers t)))
(provide 'nixos)

View file

@ -1,23 +0,0 @@
(require 'company)
(require 'eglot)
(require 'rust-mode)
;; LSP configuration:
(defvar rust-eglot-initialized nil)
(add-hook 'rust-mode-hook (lambda ()
(unless rust-eglot-initialized
(call-interactively #'eglot)
(setq rust-eglot-initialized t))))
;; Enable cargo-related (C-c C-c C-...) commands.
(add-hook 'rust-mode-hook #'cargo-minor-mode)
;; Configure autocompletion for rust
(add-hook 'rust-mode-hook #'company-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)
;; Ensure long compiler errors don't flow out of the screen (very annoying!)
(add-hook 'cargo-process-mode-hook #'visual-line-mode)
(provide 'rust-setup)

View file

@ -1,7 +1,6 @@
(require 'prescient)
(require 'ivy-prescient)
(require 'uniquify)
(require 'password-store)
(require 'ivy-pass)
;; Make ivy go!
@ -63,20 +62,4 @@
;; Show time in 24h format
(setq display-time-24hr-format t)
;; Make ace-window behave in a sane way:
(setq aw-keys '(?f ?j ?d ?k ?s ?l ?a)) ; Homerow keys in sensible order!
(setq aw-scope 'frame) ; There are many frames in exwm, I don't care!
;; Configure pinentry for use with GPG
(setq epa-pinentry-mode 'loopback)
(pinentry-start)
;; Configure password-store as an auth-source
;; (this requires emacs 26)
(require 'auth-source-pass)
(auth-source-pass-enable)
;; Configure magit-repository-list
(setq magit-repository-directories '(("/home/vincent/projects" . 2)))
(provide 'settings)

View file

@ -1,6 +1,4 @@
;; Configuration for multi-term mode:
(require 'multi-term)
;; Utilities for term-mode
(defun open-or-create-term-buffer (buffer-name)
"Switch to the buffer with BUFFER-NAME or create a
@ -31,16 +29,4 @@
(rename-buffer (format "*terminal<%s>*" (read-string "New terminal name: ")))
(error "This function is only intended to rename terminal buffers."))))
(global-set-key (kbd "C-x t") #'counsel-switch-to-term)
;; term-mode's attempt to use isearch is not my favourite thing in the
;; world.
(delete '("C-r" . isearch-backward) term-bind-key-alist)
(delete '("C-s" . isearch-forward) term-bind-key-alist)
(add-to-list 'term-bind-key-alist '("C-r" . term-send-reverse-search-history))
(add-to-list 'term-bind-key-alist '("C-c C-l" . term-line-mode))
(add-to-list 'term-bind-key-alist '("C-s" . swiper))
(add-to-list 'term-bind-key-alist '("C-c C-r" . term-rename))
(provide 'term-setup)