Skip to content

Instantly share code, notes, and snippets.

@darkfeline
Created January 27, 2018 07:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darkfeline/1c78690dc914fc275c8f563ddc9616bc to your computer and use it in GitHub Desktop.
Save darkfeline/1c78690dc914fc275c8f563ddc9616bc to your computer and use it in GitHub Desktop.
;;; Bootstrap
(setq gc-cons-threshold most-positive-fixnum)
(package-initialize)
;; Load customizations
(setq custom-file (locate-user-emacs-file "custom.el"))
(load custom-file)
;;; Configure fonts
(require 'unicode-fonts)
(unicode-fonts-setup)
;;; Emacs config
(setq disabled-command-function nil)
(add-to-list 'auto-mode-alist '("\\.ini.erb\\'" . conf-mode))
(add-to-list 'auto-mode-alist '("Cask\\'" . emacs-lisp-mode))
(add-to-list 'auto-mode-alist '("\\.sls\\'" . yaml-mode))
;;; Hooks
(require 'mir-init)
(add-hook 'after-save-hook
#'executable-make-buffer-file-executable-if-script-p)
(add-hook 'comint-preoutput-filter-functions #'xterm-color-filter)
(add-hook 'diary-list-entries-hook 'diary-sort-entries t)
(add-hook 'display-time-hook (mir-init-setter display-time-string
(concat " " display-time-string)))
(add-hook 'erc-mode-hook #'abbrev-mode)
(add-hook 'find-file-hook #'auto-insert)
(add-hook 'flycheck-mode-hook #'flycheck-cask-setup)
(add-hook 'go-mode-hook #'subword-mode)
(add-hook 'go-mode-hook (lambda ()
(when (fboundp 'gofmt-before-save)
(add-hook 'before-save-hook
#'gofmt-before-save t t))))
(add-hook 'js-mode-hook #'subword-mode)
(add-hook 'message-sent-hook #'mir-mail-flush-msmtpq)
(add-hook 'minibuffer-exit-hook (mir-init-setter gc-cons-threshold 800000))
(add-hook 'minibuffer-setup-hook (mir-init-setter gc-cons-threshold most-positive-fixnum))
(add-hook 'org-mode-hook (mir-init-disable flycheck-mode))
(add-hook 'prog-mode-hook #'abbrev-mode)
(add-hook 'prog-mode-hook #'flyspell-prog-mode)
(add-hook 'python-mode-hook #'hs-minor-mode)
(add-hook 'python-mode-hook #'subword-mode)
(add-hook 'python-mode-hook (mir-init-setter fill-column 72))
(add-hook 'python-mode-hook (mir-init-setter dabbrev-case-fold-search nil))
(add-hook 'rst-mode-hook (mir-init-disable electric-quote-local-mode))
(add-hook 'text-mode-hook #'abbrev-mode)
(add-hook 'text-mode-hook (lambda ()
;; https://github.com/magit/magit/issues/2915
(unless (bound-and-true-p git-commit-mode)
(flyspell-mode))))
(autoload 'xterm-color-filter "xterm-color")
;;; Keys
(mir-init-bind-keys global-map
;; Builtin commands
([remap upcase-word] #'upcase-dwim)
([remap downcase-word] #'downcase-dwim)
([remap capitalize-word] #'capitalize-dwim)
([?\C-h ?A] #'apropos)
([?\C-h ?M] #'man)
([?\C-x ?\C-b] #'ibuffer)
([?\C-c ?e] #'elfeed)
([?\C-c ?i] #'imenu)
([?\C-c ?o] #'browse-url)
;; Packages
([?\C-c ?g] #'magit-status)
([?\C-c ?G] #'magit-list-repositories)
([?\C-c ?a] #'org-agenda)
([?\C-c ?c] #'org-capture)
([?\C-c ?l] #'org-store-link)
([?\C-c ?=] #'er/expand-region)
;; Personal
([?\C-c ?f] #'mir-wiki-find-page)
([?\C-c ?q] #'mir-qualia-qsync)
([?\C-c ?v ?u] #'mir-volman-up)
([?\C-c ?v ?d] #'mir-volman-down)
([?\C-c ?v ?m] #'mir-volman-mute)
([?\C-c ?s ?d] #'mir-pair-delete)
([?\C-c ?s ?m] #'mir-pair-mark)
([?\C-c ?s ?s] #'mir-pair-replace))
(mir-init-bind-keys occur-mode-map
([?n] #'occur-next)
([?p] #'occur-prev))
;;; Eval after load
(with-eval-after-load 'autoinsert
(mir-init-auto-insert
('org-mode "Org mode header" #'mir-org-auto-insert)
('puppet-mode "Puppet mode template" #'mir-puppet-auto-insert)
("\\.el\\'" "Emacs Lisp header" #'mir-elisp-auto-insert)))
(with-eval-after-load 'dired
(require 'dired-x))
(with-eval-after-load 'elisp-mode
;; Load checkdoc configuration for disabling
;; ‘checkdoc-verb-check-experimental-flag’ in flycheck.
(require 'checkdoc)
(mir-init-bind-keys lisp-interaction-mode-map
([?\C-c ?\C-e] #'emacs-lisp-macroexpand)
([?\C-c ?\C-q] #'mir-elisp-indent-defun))
(mir-init-bind-keys emacs-lisp-mode-map
([?\C-c ?\C-e] #'emacs-lisp-macroexpand)
([?\C-c ?\C-q] #'mir-elisp-indent-defun)
([?\C-c ?\C-c] #'mir-custom-eval-set-variable)))
(with-eval-after-load 'eshell
(require 'em-smart))
(with-eval-after-load 'magit
(mir-init-bind-keys magit-mode-map
([?G] #'mir-gerrit-magit-popup)))
(with-eval-after-load 'ob-core
(mir-init-defvars org-babel-capitalize-example-region-markers
org-babel-min-lines-for-block-output)
(setq org-babel-capitalize-example-region-markers t
org-babel-min-lines-for-block-output 0))
(with-eval-after-load 'org
(require 'org-id)
(require 'org-depend))
(with-eval-after-load 'python
(advice-add 'python-indent--calculate-indentation
:around
#'mir-python-calculate-indentation))
(with-eval-after-load 'shell
(mir-init-bind-keys shell-mode-map
([?\s] 'comint-magic-space)))
(with-eval-after-load 'smerge-mode
(mir-init-bind-keys smerge-mode-map
([?\C-c ?^ ?V] #'mir-smerge-fix-move-conflict)
([?\C-c ?^ ?M] #'mir-smerge-keep-mine-substitute)
([?\C-c ?^ ?O] #'mir-smerge-keep-other-substitute)))
(with-eval-after-load 'which-func
(require 's)
(defvar which-func-cleanup-function)
(setq which-func-cleanup-function
(lambda (s)
(s-truncate 30 s))))
;;; Delight
(delight '((abbrev-mode nil abbrev)
(dired-async-mode (:eval (when (eq major-mode 'dired-mode)
" Async"))
dired-async)
(ivy-mode nil ivy)
(ws-butler-mode nil ws-butler)
(yas-minor-mode nil yasnippet)))
;;; Setup
(filesets-init)
(server-start)
(windmove-default-keybindings)
(require 'org-protocol)
(org-clock-persistence-insinuate)
(mir-ivy-bind-keys)
;;; Finalization
(setq gc-cons-threshold 800000)
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment