123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919 |
- ;;;; Copyright © 2013-2017 Lily Carpenter
- ;;;; All rights reserved.
- ;;;; Web: https://azrazalea.net
- ;;;; Email: azra-license@azrazalea.net
- ;;;; This config is free software: you can redistribute it and/or modify
- ;;;; it under the terms of the GNU Lesser General Public License as published by
- ;;;; the Free Software Foundation, either version 3 of the License, or
- ;;;; (at your option) any later version.
- ;;;; This config is distributed in the hope that it will be useful,
- ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;;;; GNU Lesser General Public License for more details.
- ;;;; You should have received a copy of the GNU Lesser General Public License
- ;;;; along with this config. If not, see <http://www.gnu.org/licenses/>.
- ;;;;
- (package-initialize)
- (server-start)
- (require 'misc)
- (let ((third-party "~/.emacs.d/third-party/"))
- (add-to-list 'load-path third-party)
- (mapcar #'(lambda (path)
- (add-to-list 'load-path (concat third-party path))
- (byte-recompile-directory (concat third-party path)))
- '("diminish" "lfe-mode"))
- (byte-recompile-directory third-party))
- (add-hook 'after-init-hook (lambda ()
- (require 'use-package)
- (require 'bind-key)
- (require 'diminish)
- (require 'lfe-start)
- (load "~/.emacs.d/packages")
- (diminish 'whitespace-mode)
- (diminish 'auto-revert-mode)
- (light-colors)
- (scroll-bar-mode -1)))
- (add-hook 'emacs-startup-hook (lambda ()
- (when (file-exists-p "~/.emacs.d/local_vars.el")
- (message "Loading local vars")
- (load "~/.emacs.d/local_vars"))))
- (put 'erase-buffer 'disabled nil)
- (require 'recentf)
- ;;;; Load other configuration files
- (defun darwin? ()
- (eq system-type 'darwin))
- (defun linux? ()
- (eq system-type 'gnu/linux))
- (defun fixed-buffer-width ()
- (cond ((not window-system) 78)
- (t 100)))
- (load "~/.emacs.d/config.d/keys")
- (put 'scroll-left 'disabled nil)
- ;;; Toolbar setup
- (when (not (darwin?))
- (display-time))
- (when (darwin?)
- (setenv "PATH"
- (concat (getenv "PATH")
- ":/usr/local/bin"))
- (setq exec-path (append exec-path '("/usr/local/bin"))))
- (setenv "PATH"
- (concat (getenv "HOME") "/bin:" (getenv "PATH")))
- (column-number-mode 1)
- (blink-cursor-mode 0)
- (setenv "MANWIDTH" (number-to-string (fixed-buffer-width)))
- (custom-set-variables
- ;; custom-set-variables was added by Custom.
- ;; If you edit it by hand, you could mess it up, so be careful.
- ;; Your init file should contain only one such instance.
- ;; If there is more than one, they won't work right.
- '(Info-additional-directory-list (quote ("/usr/local/share/info" "~/gcl-info/")))
- '(TeX-auto-save t)
- '(TeX-command-extra-options "\"-shell-escape\"")
- '(TeX-parse-self t)
- '(ansi-color-faces-vector
- [default default default italic underline success warning error])
- '(ansi-color-names-vector
- ["#002b36" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#839496"])
- '(async-bytecomp-package-mode t)
- '(auth-sources (quote ("~/.authinfo.gpg")))
- '(auto-revert-use-notify nil)
- '(blink-cursor-mode nil)
- '(browse-url-browser-function (quote kill-url))
- '(c-basic-offset 4)
- '(c-default-style "linux")
- '(compilation-message-face (quote default))
- '(compilation-scroll-output t)
- '(css-indent-offset 2)
- '(cua-global-mark-cursor-color "#2aa198")
- '(cua-normal-cursor-color "#839496")
- '(cua-overwrite-cursor-color "#b58900")
- '(cua-read-only-cursor-color "#859900")
- '(custom-safe-themes
- (quote
- ("c5d6d43251953cea30a007acf7a6fbca71384558a11fe3d95953ac056a8510dc" "cd03a600a5f470994ba01dd3d1ff52d5809b59b4a37357fa94ca50a6f7f07473" "3ac266781ee0ac3aa74a6913a1506924cad669f111564507249f0ffa7c5e4b53" "71ecffba18621354a1be303687f33b84788e13f40141580fa81e7840752d31bf" "c74e83f8aa4c78a121b52146eadb792c9facc5b1f02c917e3dbb454fca931223" "c5a044ba03d43a725bd79700087dea813abcb6beb6be08c7eb3303ed90782482" "3a727bdc09a7a141e58925258b6e873c65ccf393b2240c51553098ca93957723" "d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "e16a771a13a202ee6e276d06098bc77f008b73bbac4d526f160faa2d76c1dd0e" default)))
- '(default-frame-alist (quote ((font . "Fira Code"))))
- '(display-time-24hr-format t)
- '(display-time-day-and-date t)
- '(display-time-mode t)
- '(elfeed-feeds
- (quote
- ("https://lwn.net/headlines/rss" "https://news.ycombinator.com/rss" "http://planet.lisp.org/rss20.xml")))
- '(epg-gpg-program "gpg2")
- '(erc-autojoin-channels-alist nil)
- '(erc-autojoin-mode nil)
- '(erc-email-userid "azra-freenode@azrazalea.net")
- '(erc-enable-logging nil)
- '(erc-fill-column 100)
- '(erc-fill-mode t)
- '(erc-interpret-mirc-color t)
- '(erc-join-buffer (quote bury))
- '(erc-kill-buffer-on-part t)
- '(erc-kill-queries-on-quit t)
- '(erc-kill-server-buffer-on-quit t)
- '(erc-modules
- (quote
- (autojoin button completion fill irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring services stamp spelling track)))
- '(erc-networks-mode t)
- '(erc-nick "azrazalea")
- '(erc-port 65523)
- '(erc-prompt-for-nickserv-password nil)
- '(erc-prompt-for-password nil)
- '(erc-server "azrazalea.net")
- '(erc-services-mode t)
- '(erc-track-faces-priority-list
- (quote
- (erc-error-face erc-current-nick-face erc-keyword-face erc-nick-msg-face erc-direct-msg-face erc-dangerous-host-face erc-prompt-face)))
- '(erc-track-priority-faces-only (quote all))
- '(erc-user-full-name "Lily Carpenter")
- '(eshell-cmpl-compare-entry-function (quote string-lessp))
- '(fci-rule-color "#073642")
- '(fill-column 80)
- '(fortune-file "/usr/share/games/fortunes/")
- '(gnus-alias-allow-forward-as-reply t)
- '(gnus-alias-default-identity "personal")
- '(gnus-alias-identity-alist
- (quote
- (("personal" "" "\"Lily Carpenter\" <azra@azrazalea.net>" "" nil "" "")
- ("personal gmail" "" "\"Lily Carpenter\" <azrazalea@gmail.com>" "" nil "" "")
- ("lily" "" "\"Lily Carpenter\" <lily@azrazalea.net>" "" nil "" ""))))
- '(gnus-secondary-select-methods
- (quote
- ((nnml "")
- (nnimap "azrazalea-gmail"
- (nnimap-address "imap.gmail.com")
- (nnimap-server-port "imaps")
- (nnimap-stream ssl)))))
- '(gnus-select-method
- (quote
- (nnimap "azra-azrazalea.net"
- (nnimap-address "mail.azrazalea.net")
- (nnimap-server-port "imaps")
- (nnimap-stream ssl))))
- '(gnus-sum-thread-tree-false-root "")
- '(gnus-sum-thread-tree-indent " ")
- '(gnus-sum-thread-tree-leaf-with-other "├► ")
- '(gnus-sum-thread-tree-root "")
- '(gnus-sum-thread-tree-single-leaf "╰► ")
- '(gnus-sum-thread-tree-vertical "│")
- '(gnus-summary-line-format
- "%U%R%z %(%&user-date class=\"comment\">; %-15,15f %B%s%)
- ")
- '(gnus-summary-thread-gathering-function (quote gnus-gather-threads-by-references))
- '(gnus-thread-sort-functions (quote (gnus-thread-sort-by-date)))
- '(gnus-user-date-format-alist (quote ((t . "%Y-%m-%d %H:%M"))))
- '(helm-M-x-fuzzy-match t)
- '(helm-buffers-fuzzy-matching t)
- '(helm-ff-file-name-history-use-recentf t)
- '(helm-ff-search-library-in-sexp t)
- '(helm-move-to-line-cycle-in-source t)
- '(helm-recentf-fuzzy-match t)
- '(helm-scroll-amount 8)
- '(helm-split-window-in-side-p t)
- '(highlight-changes-colors (quote ("#d33682" "#6c71c4")))
- '(highlight-symbol-colors
- (--map
- (solarized-color-blend it "#fdf6e3" 0.25)
- (quote
- ("#b58900" "#2aa198" "#dc322f" "#6c71c4" "#859900" "#cb4b16" "#268bd2"))))
- '(highlight-symbol-foreground-color "#586e75")
- '(highlight-tail-colors
- (quote
- (("#073642" . 0)
- ("#546E00" . 20)
- ("#00736F" . 30)
- ("#00629D" . 50)
- ("#7B6000" . 60)
- ("#8B2C02" . 70)
- ("#93115C" . 85)
- ("#073642" . 100))))
- '(hl-bg-colors
- (quote
- ("#DEB542" "#F2804F" "#FF6E64" "#F771AC" "#9EA0E5" "#69B7F0" "#69CABF" "#B4C342")))
- '(hl-fg-colors
- (quote
- ("#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3" "#fdf6e3")))
- '(indent-tabs-mode nil)
- '(inf-ruby-default-implementation "pry")
- '(inhibit-startup-screen t)
- '(js-indent-level 2)
- '(js2-basic-offset 2)
- '(js2-bounce-indent-p nil)
- '(js2-global-externs
- (quote
- ("beforeEach" "describe" "it" "angular" "_" "inject" "expect" "module")))
- '(js2-mode-indent-ignore-first-tab t)
- '(magit-commit-arguments nil)
- '(magit-default-tracking-name-function (quote magit-default-tracking-name-branch-only))
- '(magit-diff-use-overlays nil)
- '(magit-log-arguments (quote ("--graph" "--decorate" "--show-signature" "-n256")))
- '(magit-tag-arguments (quote ("--sign")))
- '(magit-use-overlays nil)
- '(menu-bar-mode nil)
- '(message-send-mail-function (quote smtpmail-multi-send-it))
- '(mouse-wheel-progressive-speed t)
- '(mouse-wheel-scroll-amount (quote (6 ((shift) . 6))))
- '(nrepl-message-colors
- (quote
- ("#dc322f" "#cb4b16" "#b58900" "#546E00" "#B4C342" "#00629D" "#2aa198" "#d33682" "#6c71c4")))
- '(org-agenda-files (quote ("~/org/home.org")))
- '(org-babel-load-languages (quote ((dot . t) (sh . t))))
- '(org-log-done t)
- '(org-src-fontify-natively t)
- '(org-todo-keywords
- (quote
- ((sequence "TODO" "PROGRESS" "REVIEW" "|" "DONE" "ABORTED"))))
- '(package-archives
- (quote
- (("melpa" . "https://melpa.org/packages/")
- ("marmalade" . "https://marmalade-repo.org/packages/")
- ("gnu" . "https://elpa.gnu.org/packages/"))))
- '(package-selected-packages
- (quote
- (wttrin sly rust-mode inf-ruby nlinum helm flycheck clojure-mode async yasnippet yari yaml-mode web-mode w3m use-package undo-tree twittering-mode toml-mode tide sws-mode solarized-theme smtpmail-multi smartparens smart-mode-line sly-company shen-mode scss-mode sane-term ruby-electric ruby-block rubocop rspec-mode robe reverse-theme refheap rbenv rainbow-identifiers rainbow-delimiters pkg-info-dummy-package php-mode paradox notify nlinum-relative multi-term markdown-mode magit macrostep lua-mode leuven-theme less-css-mode json-mode js2-mode jade-mode info+ helm-projectile helm-company helm-ag haml-mode go-mode gnus-desktop-notify gnus-alias gitignore-mode gitconfig-mode gitattributes-mode geiser exec-path-from-shell elfeed cyberpunk-theme company-quickhelp column-enforce-mode color-theme cider cargo auctex alchemist ag ace-jump-mode 4clojure)))
- '(paradox-github-token t)
- '(pos-tip-background-color "#eee8d5")
- '(pos-tip-foreground-color "#586e75")
- '(projectile-completion-system (quote helm))
- '(projectile-enable-caching t)
- '(projectile-global-mode t)
- '(projectile-switch-project-action (quote projectile-dired))
- '(projectile-use-git-grep t)
- '(rainbow-identifiers-choose-face-function (quote rainbow-identifiers-cie-l*a*b*-choose-face))
- '(rainbow-identifiers-cie-l*a*b*-saturation 50)
- '(reftex-plug-into-AUCTeX t)
- '(require-final-newline t)
- '(rspec-use-rake-when-possible t)
- '(rspec-use-spring-when-possible nil)
- '(rspec-use-zeus-when-possible nil)
- '(ruby-block-highlight-toggle t)
- '(ruby-deep-arglist nil)
- '(ruby-deep-indent-paren nil)
- '(safe-local-variable-values
- (quote
- ((Package . CLIM-CLX)
- (indent-tabs)
- (Lowercase . Yes)
- (Base . 10)
- (Package . CLIM-DEMO)
- (Syntax . ANSI-Common-Lisp)
- (Package . MCCLIM-TRUETYPE)
- (Package . CLIM-INTERNALS)
- (Syntax . Common-Lisp)
- (eval modify-syntax-entry 43 "'")
- (eval modify-syntax-entry 36 "'")
- (eval modify-syntax-entry 126 "'")
- (bug-reference-bug-regexp . "<https?://\\(debbugs\\|bugs\\)\\.gnu\\.org/\\([0-9]+\\)>")
- (TeX-command-extra-options . "-shell-escape"))))
- '(sane-term-shell-command "zsh")
- '(save-place t nil (saveplace))
- '(scroll-bar-mode nil)
- '(scroll-conservatively 75)
- '(scroll-step 1)
- '(scss-compile-at-save nil)
- '(send-mail-function (quote smtpmail-multi-send-it))
- '(show-paren-mode t)
- '(size-indication-mode t)
- '(smartrep-mode-line-active-bg (solarized-color-blend "#859900" "#073642" 0.2))
- '(sml/name-width 35)
- '(sml/theme (quote respectful))
- '(smtpmail-multi-accounts
- (quote
- ((Personal\ Gmail "azrazalea" "smtp.gmail.com" 587 nil nil nil nil nil)
- (Personal "azra" "mail.azrazalea.net" 587 nil starttls nil nil nil))))
- '(smtpmail-multi-associations
- (quote
- (("gmail.com" Personal\ Gmail)
- ("azrazalea.net" Personal))))
- '(smtpmail-multi-default-account (quote Personal))
- '(smtpmail-smtp-server "mail.azrazalea.net")
- '(smtpmail-smtp-service 587)
- '(smtpmail-smtp-user "azra")
- '(smtpmail-stream-type (quote ssl))
- '(socks-server (quote ("default" "localhost" 9999 5)))
- '(sp-lisp-modes
- (quote
- (cider-repl-mode clojure-mode clojurec-mode clojurescript-mode clojurex-mode common-lisp-mode emacs-lisp-mode eshell-mode geiser-repl-mode inf-clojure-mode inferior-emacs-lisp-mode inferior-lisp-mode inferior-scheme-mode lisp-interaction-mode lisp-mode monroe-mode racket-mode racket-repl-mode scheme-interaction-mode scheme-mode slime-repl-mode stumpwm-mode lfe-mode)))
- '(term-bind-key-alist
- (quote
- (("C-c C-c" . term-interrupt-subjob)
- ("C-p" . previous-line)
- ("C-n" . next-line)
- ("C-s" . isearch-forward)
- ("C-r" . isearch-backward)
- ("C-m" . term-send-raw)
- ("M-f" . term-send-forward-word)
- ("M-b" . term-send-backward-word)
- ("M-o" . term-send-backspace)
- ("M-p" . term-send-up)
- ("M-n" . term-send-down)
- ("M-M" . term-send-forward-kill-word)
- ("M-N" . term-send-backward-kill-word)
- ("M-r" . term-send-reverse-search-history)
- ("M-," . term-send-input)
- ("M-." . comint-dynamic-complete)
- ("C-c C-j" . term-line-mode)
- ("C-c C-k" . term-char-mode)
- ("C-c C-e" . term-send-escape))))
- '(term-default-bg-color (face-background (quote default)))
- '(term-default-fg-color (face-foreground (quote default)))
- '(tool-bar-mode nil)
- '(tramp-default-method "ssh")
- '(typescript-indent-level 2)
- '(uniquify-buffer-name-style (quote forward) nil (uniquify))
- '(use-package-always-ensure t)
- '(user-full-name "Lily Carpenter")
- '(user-mail-address "")
- '(vc-annotate-background nil)
- '(vc-annotate-background-mode nil)
- '(vc-annotate-color-map
- (quote
- ((20 . "#dc322f")
- (40 . "#CF4F1F")
- (60 . "#C26C0F")
- (80 . "#b58900")
- (100 . "#AB8C00")
- (120 . "#A18F00")
- (140 . "#989200")
- (160 . "#8E9500")
- (180 . "#859900")
- (200 . "#729A1E")
- (220 . "#609C3C")
- (240 . "#4E9D5B")
- (260 . "#3C9F79")
- (280 . "#2aa198")
- (300 . "#299BA6")
- (320 . "#2896B5")
- (340 . "#2790C3")
- (360 . "#268bd2"))))
- '(vc-annotate-very-old-color nil)
- '(visible-bell t)
- '(web-mode-code-indent-offset 2)
- '(web-mode-css-indent-offset 2)
- '(web-mode-enable-auto-closing t)
- '(web-mode-enable-auto-indentation t)
- '(web-mode-enable-auto-opening t)
- '(web-mode-enable-auto-pairing nil)
- '(web-mode-enable-auto-quoting t)
- '(web-mode-enable-current-element-highlight t)
- '(web-mode-markup-indent-offset 2)
- '(weechat-color-list
- (quote
- (unspecified "#002b36" "#073642" "#990A1B" "#dc322f" "#546E00" "#859900" "#7B6000" "#b58900" "#00629D" "#268bd2" "#93115C" "#d33682" "#00736F" "#2aa198" "#839496" "#657b83")))
- '(whitespace-style (quote (face empty tabs trailing)))
- '(woman-bold-headings t)
- '(woman-fill-column (fixed-buffer-width))
- '(woman-fill-frame t)
- '(wttrin-default-cities (quote ("63043" "65802")))
- '(xterm-color-names
- ["#eee8d5" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#073642"])
- '(xterm-color-names-bright
- ["#fdf6e3" "#cb4b16" "#93a1a1" "#839496" "#657b83" "#6c71c4" "#586e75" "#002b36"]))
- (setenv "TERM" "xterm-color")
- (defun dark-colors (&optional frame)
- (interactive)
- (package-install? 'solarized-theme)
- (disable-theme 'solarized-light)
- (disable-theme 'cyberpunk)
- (disable-theme 'leuven)
- (load-theme 'solarized-dark))
- (defun presentation-font ()
- (interactive)
- (set-frame-font "Fira Code 24"))
- (defun dark-colors-presentation (&optional frame)
- (interactive)
- (package-install? 'reverse-theme)
- (disable-theme 'solarized-light)
- (disable-theme 'solarized-dark)
- (disable-theme 'leuven)
- (load-theme 'reverse))
- (defun light-colors (&optional frame)
- (interactive)
- (package-install? 'solarized-theme)
- (disable-theme 'solarized-dark)
- (disable-theme 'reverse)
- (disable-theme 'leuven)
- (load-theme 'solarized-light))
- (defun light-colors-presentation (&optional frame)
- (interactive)
- (package-install? 'leuven-theme)
- (disable-theme 'solarized-dark)
- (disable-theme 'solarized-light)
- (disable-theme 'reverse)
- (load-theme 'leuven))
- (defun ssh (ssh-to)
- (interactive "sSSH to: ")
- (let ((multi-term-program "ssh")
- (multi-term-buffer-name ssh-to)
- (multi-term-program-switches ssh-to))
- (multi-term)))
- (defun ssh-proxy (ssh-to port)
- (interactive "sSSH to: \nsPort[9999]: ")
- (if (string= "" port)
- (setq port "9999"))
- (make-comint-in-buffer "ssh-proxy" nil "ssh" nil "-CND" port ssh-to))
- (defun ssh-copy-id (ssh-to)
- (interactive "sSSH to: ")
- (make-comint-in-buffer "ssh-copy-id" nil "ssh-copy-id" nil ssh-to))
- (defvar hexcolour-keywords
- '(("#[[:xdigit:]]\\{6\\}"
- (0 (put-text-property (match-beginning 0)
- (match-end 0)
- 'face (list :background
- (match-string-no-properties 0)))))))
- (defun hexcolour-add-to-font-lock ()
- (font-lock-add-keywords nil hexcolour-keywords))
- (add-hook 'less-css-mode-hook 'hexcolour-add-to-font-lock)
- (require 'erc-services)
- (erc-services-mode 1)
- (add-to-list 'erc-modules 'log 'scrolltobottom)
- (erc-update-modules)
- (erc-spelling-mode 1)
- ;;; TeX and LaTeX
- (add-to-list 'auto-mode-alist '("\\.latex$" . latex-mode))
- ;;; Git
- (add-to-list 'auto-mode-alist '("\\.gitconfig" . conf-mode))
- ;;; Buffers
- (put 'downcase-region 'disabled nil)
- (put 'narrow-to-region 'disabled nil)
- ;;; GPG stuff.
- (require 'epa-file)
- ;; With this, you can find-file something.gpg and it will just work.
- (epa-file-enable)
- ;;; Whitespace mode
- (require 'whitespace)
- (global-whitespace-mode 0)
- (mapc (lambda (mode-hook)
- (add-hook mode-hook 'whitespace-mode))
- '(c-mode-hook
- c++-mode-hook
- emacs-lisp-mode-hook
- lisp-mode-hook
- python-mode-hook
- ruby-mode-hook))
- (define-key global-map (kbd "RET") 'newline-and-indent)
- (add-hook 'before-save-hook 'delete-trailing-whitespace)
- (add-hook 'prog-mode-hook
- (lambda ()
- (font-lock-add-keywords nil
- '(("\\<\\(FIXME\\|TODO\\|BUG\\|XXX\\):" 1 font-lock-warning-face prepend)))))
- (defun kill-url (url &rest _ignore)
- "Append URL to kill ring, so that user can take appropriate action."
- (interactive)
- (kill-new url))
- ;;; Custom Functions
- ;; Originally from stevey, adapted to support moving to a new directory.
- ;; <http://stackoverflow.com/a/1834038/693712>
- (defun rename-file-and-buffer (new-name)
- "Renames both current buffer and file it's visiting to NEW-NAME."
- (interactive
- (progn
- (if (not (buffer-file-name))
- (error "Buffer '%s' is not visiting a file!" (buffer-name)))
- (list (read-file-name (format "Rename %s to: " (file-name-nondirectory
- (buffer-file-name)))))))
- (if (equal new-name "")
- (error "Aborted rename"))
- (setq new-name (if (file-directory-p new-name)
- (expand-file-name (file-name-nondirectory
- (buffer-file-name))
- new-name)
- (expand-file-name new-name)))
- ;; If the file isn't saved yet, skip the file rename, but still update the
- ;; buffer name and visited file.
- (if (file-exists-p (buffer-file-name))
- (rename-file (buffer-file-name) new-name 1))
- (let ((was-modified (buffer-modified-p)))
- ;; This also renames the buffer, and works with uniquify
- (set-visited-file-name new-name)
- (if was-modified
- (save-buffer)
- ;; Clear buffer-modified flag caused by set-visited-file-name
- (set-buffer-modified-p nil))
- (message "Renamed to %s." new-name)))
- ;; From http://emacsredux.com/blog/2013/04/03/delete-file-and-buffer/
- ;; License unknown
- (defun delete-file-and-buffer ()
- "Kill the current buffer and deletes the file it is visiting."
- (interactive)
- (let ((filename (buffer-file-name)))
- (when filename
- (if (vc-backend filename)
- (vc-delete-file filename)
- (progn
- (delete-file filename)
- (message "Deleted file %s" filename)
- (kill-buffer))))))
- ;; http://www.emacswiki.org/emacs/ElispCookbook
- ;; Under Trim Whitespace
- (defun chomp (str)
- "Chomp leading and tailing whitespace from STR."
- (replace-regexp-in-string (rx (or (: bos (* (any " \t\n")))
- (: (* (any " \t\n")) eos)))
- ""
- str))
- ;; Gets current git top dir
- (defun git-top-dir ()
- (projectile-project-root))
- ;; Run rspecs at root of git
- (defun git-run-rspecs ()
- (interactive)
- (let ((default-directory (git-top-dir)))
- (if (and default-directory (file-directory-p default-directory))
- (let ((buffer-name "*rspec output*"))
- (if (get-buffer buffer-name)
- (with-current-buffer buffer-name
- (erase-buffer)))
- (start-process "git-rspec" buffer-name "rspec")
- (display-buffer buffer-name))
- (error "No valid top git directory found"))))
- ;; Rebase all whitespace seperated branches on top of each other,
- ;; from left to right. Current branch will be on the bottom
- (defun git-tree-rebase (branches)
- (interactive "sWhitespace seperated list of branches: ")
- (let ((branches (split-string branches))
- (prev-branch (magit-get-current-branch)))
- (dolist (cur-branch branches)
- (let ((rc (shell-command (format "git checkout %s; git rebase %s" cur-branch prev-branch))))
- (if (not (equal rc 0))
- (error "Failed to rebase %s on %s" cur-branch prev-branch)))
- (setq prev-branch cur-branch))))
- ;; Force update all whitespace seperated branches
- (defun git-fix-tree (branches)
- (interactive "sWhitespace seperated list of branches: ")
- (let ((branches (split-string branches)))
- (dolist (branch branches)
- (let ((rc (shell-command (format "git push origin :%s; git push origin %s" branch branch))))
- (if (not (equal rc 0))
- (error "Failed to fix branch %s" branch))))))
- ;; Get current branch
- (defun git-current-branch ()
- (let ((default-directory (git-top-dir)))
- (if default-directory
- (chomp (shell-command-to-string "git rev-parse --abbrev-ref HEAD"))
- (error "Failed to get top directory of repo"))))
- ;; Set experimental to current branch and push
- (defun git-set-experimental ()
- (interactive)
- (let* ((current-branch (git-current-branch))
- (rc (shell-command (format "git branch -f experimental %s;" current-branch))))
- (if (not (equal rc 0))
- (error "Failed to move branch experimental to %s" current-branch)))
- (git-fix-tree "experimental"))
- ;; Check entire git repo's ruby syntax
- (require 'find-lisp)
- (defun git-check-ruby ()
- (interactive)
- (let ((default-directory (git-top-dir)))
- (if (and default-directory (file-directory-p default-directory))
- (let ((buffer-name "*syntax checker*"))
- (if (get-buffer buffer-name)
- (with-current-buffer buffer-name
- (erase-buffer)))
- (dolist (file (find-lisp-find-files default-directory "\\.rb$"))
- (start-process "ruby-syntax-check" buffer-name "ruby" "-c" file))
- (display-buffer buffer-name))
- (error "Syntax check failed."))))
- ;; Check whether or not a git repo is dirty
- (defun git-dirty? (directory)
- (let* ((default-directory directory)
- (status (shell-command-to-string "git status -s"))
- (good-status '("" " M .gitmodules\n" "M .gitmodules\n"))
- (result t))
- (if (member status good-status)
- (setq result nil))
- result))
- ;; Update a git repo
- (defun update-git (directory)
- (let* ((default-directory directory)
- (orig-branch (magit-get-current-branch))
- rc)
- (setq rc (shell-command "git checkout master && git pull"))
- (if (not (equal rc 0))
- (error "Error: Failed to update repo %s" directory))
- (setq rc (shell-command (format "git checkout %s" orig-branch)))
- (if (not (equal rc 0))
- (error "Error: Failed to checkout original branch %s in repo %s" orig-branch directory))))
- ;; Update all repos in the home directory
- (defun update-all-repos ()
- (interactive)
- (let* ((directory (concat (getenv "HOME") "/git-repos"))
- (files (directory-files-and-attributes directory t)))
- (dolist (file files)
- (cond
- ;; Ignore . and ..
- ((or (string-match "\\.$" (car file)) (string-match "\\.\\.$" (car file))))
- ;; Directories with non dirty git need to be checked for git info
- ((and (eq t (car (cdr file))) (not (git-dirty? (format "%s/" (car file)))))
- (update-git (format "%s/" (car file))))))))
- (defun kill-dired-buffers ()
- (interactive)
- (mapc (lambda (buffer)
- (when (eq 'dired-mode (buffer-local-value 'major-mode buffer))
- (kill-buffer buffer)))
- (buffer-list)))
- (defun kill-tramp-buffers ()
- (interactive)
- (tramp-cleanup-all-connections)
- (tramp-cleanup-all-buffers))
- (defun git-all-files ()
- (let ((default-directory (git-top-dir)))
- (split-string (shell-command-to-string "git ls-tree -r --name-only --full-name HEAD"))))
- ;; A proper projectile replace with regex support
- (defun git-replace-regexp (from to)
- (interactive "sFrom regexp: \nsTo regexp: ")
- (let ((files '(delq nil (mapcar (lambda (directory)
- (let ((file (concat (projectile-project-root) directory)))
- (if (file-writable-p file)
- file)))
- (git-all-files)))))
- (tags-query-replace from to nil files)))
- ;; From http://stackoverflow.com/a/7250027/693712
- (defun smart-line-beginning ()
- "Move point to the beginning of text on the current line; if that is already
- the current position of point, then move it to the beginning of the line."
- (interactive)
- (let ((pt (point)))
- (beginning-of-line-text)
- (when (eq pt (point))
- (beginning-of-line))))
- (add-hook 'prog-mode-hook (lambda () (local-set-key (kbd "C-a") 'smart-line-beginning)))
- ;;; Eshell Functions
- ;; Taken from <http://www.emacswiki.org/emacs/EshellFunctions>
- (defun eshell/emacs (&rest args)
- "Open a file in emacs. Some habits die hard."
- (if (null args)
- ;; If I just ran "emacs", I probably expect to be launching
- ;; Emacs, which is rather silly since I'm already in Emacs.
- ;; So just pretend to do what I ask.
- (bury-buffer)
- ;; We have to expand the file names or else naming a directory in an
- ;; argument causes later arguments to be looked for in that directory,
- ;; not the starting directory
- (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args))))))
- (defun format-commands (&rest commands)
- (mapcar (lambda (command)
- (shell-command (apply 'format command)))
- commands))
- (defun eshell/git-branch-here (branch)
- (format-commands `("git push origin :%s" ,branch)
- `("git branch -d %s" ,branch)
- `("git checkout -b %s" ,branch)
- `("git push origin %s:%s" ,branch ,branch)))
- (defun eshell/git-experimental-here ()
- (eshell/git-branch-here "experimental"))
- ;;; Spell Checking
- (add-hook 'prog-mode-hook 'flyspell-prog-mode)
- (mapcar #'(lambda (mode-hook)
- (add-hook mode-hook 'flyspell-mode))
- '(latex-mode-hook
- magit-log-edit-mode-hook
- org-mode-hook
- message-mode-hook))
- ;;; Maxima
- (add-to-list 'load-path "/usr/share/maxima/5.32.1/emacs/")
- (autoload 'maxima-mode "maxima" "Maxima mode" t)
- (autoload 'imaxima "imaxima" "Frontend for maxima with Image support" t)
- (autoload 'maxima "maxima" "Maxima interaction" t)
- (autoload 'imath-mode "imath" "Imath mode for math formula input" t)
- (setq imaxima-use-maxima-mode-flag t
- imaxima-pt-size 12
- imaxima-fnt-size "large"
- imaxima-max-scale nil
- imaxima-linearize-flag nil)
- (add-to-list 'auto-mode-alist '("\\.ma[cx]" . maxima-mode))
- (global-prettify-symbols-mode)
- ;;; Fira code
- ;; This works when using emacs --daemon + emacsclient
- (add-hook 'after-make-frame-functions (lambda (frame) (set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")))
- (add-hook 'after-make-frame-functions (lambda (frame) (set-fontset-font t nil (font-spec :size 20 :name "Symbola"))))
- ;; This works when using emacs without server/client
- (set-fontset-font t '(#Xe100 . #Xe16f) "Fira Code Symbol")
- (set-fontset-font t nil (font-spec :size 20 :name "Symbola"))
- (defconst fira-code-font-lock-keywords-alist
- (mapcar (lambda (regex-char-pair)
- `(,(car regex-char-pair)
- (0 (prog1 ()
- (compose-region (match-beginning 1)
- (match-end 1)
- ;; The first argument to concat is a string containing a literal tab
- ,(concat " " (list (decode-char 'ucs (cadr regex-char-pair)))))))))
- '(("\\(www\\)" #Xe100)
- ("[^/]\\(\\*\\*\\)[^/]" #Xe101)
- ("\\(\\*\\*\\*\\)" #Xe102)
- ("\\(\\*\\*/\\)" #Xe103)
- ("\\(\\*>\\)" #Xe104)
- ("[^*]\\(\\*/\\)" #Xe105)
- ("\\(\\\\\\\\\\)" #Xe106)
- ("\\(\\\\\\\\\\\\\\)" #Xe107)
- ("\\({-\\)" #Xe108)
- ("\\(\\[\\]\\)" #Xe109)
- ("\\(::\\)" #Xe10a)
- ("\\(:::\\)" #Xe10b)
- ("[^=]\\(:=\\)" #Xe10c)
- ("\\(!!\\)" #Xe10d)
- ("\\(!=\\)" #Xe10e)
- ("\\(!==\\)" #Xe10f)
- ("\\(-}\\)" #Xe110)
- ("\\(--\\)" #Xe111)
- ("\\(---\\)" #Xe112)
- ("\\(-->\\)" #Xe113)
- ("[^-]\\(->\\)" #Xe114)
- ("\\(->>\\)" #Xe115)
- ("\\(-<\\)" #Xe116)
- ("\\(-<<\\)" #Xe117)
- ("\\(-~\\)" #Xe118)
- ("\\(#{\\)" #Xe119)
- ("\\(#\\[\\)" #Xe11a)
- ("\\(##\\)" #Xe11b)
- ("\\(###\\)" #Xe11c)
- ("\\(####\\)" #Xe11d)
- ("\\(#(\\)" #Xe11e)
- ("\\(#\\?\\)" #Xe11f)
- ("\\(#_\\)" #Xe120)
- ("\\(#_(\\)" #Xe121)
- ("\\(\\.-\\)" #Xe122)
- ("\\(\\.=\\)" #Xe123)
- ("\\(\\.\\.\\)" #Xe124)
- ("\\(\\.\\.<\\)" #Xe125)
- ("\\(\\.\\.\\.\\)" #Xe126)
- ("\\(\\?=\\)" #Xe127)
- ("\\(\\?\\?\\)" #Xe128)
- ("\\(;;\\)" #Xe129)
- ("\\(/\\*\\)" #Xe12a)
- ("\\(/\\*\\*\\)" #Xe12b)
- ("\\(/=\\)" #Xe12c)
- ("\\(/==\\)" #Xe12d)
- ("\\(/>\\)" #Xe12e)
- ("\\(//\\)" #Xe12f)
- ("\\(///\\)" #Xe130)
- ("\\(&&\\)" #Xe131)
- ("\\(||\\)" #Xe132)
- ("\\(||=\\)" #Xe133)
- ("[^|]\\(|=\\)" #Xe134)
- ("\\(|>\\)" #Xe135)
- ("\\(\\^=\\)" #Xe136)
- ("\\(\\$>\\)" #Xe137)
- ("\\(\\+\\+\\)" #Xe138)
- ("\\(\\+\\+\\+\\)" #Xe139)
- ("\\(\\+>\\)" #Xe13a)
- ("\\(=:=\\)" #Xe13b)
- ("[^!/]\\(==\\)[^>]" #Xe13c)
- ("\\(===\\)" #Xe13d)
- ("\\(==>\\)" #Xe13e)
- ("[^=]\\(=>\\)" #Xe13f)
- ("\\(=>>\\)" #Xe140)
- ("\\(<=\\)" #Xe141)
- ("\\(=<<\\)" #Xe142)
- ("\\(=/=\\)" #Xe143)
- ("\\(>-\\)" #Xe144)
- ("\\(>=\\)" #Xe145)
- ("\\(>=>\\)" #Xe146)
- ("[^-=]\\(>>\\)" #Xe147)
- ("\\(>>-\\)" #Xe148)
- ("\\(>>=\\)" #Xe149)
- ("\\(>>>\\)" #Xe14a)
- ("\\(<\\*\\)" #Xe14b)
- ("\\(<\\*>\\)" #Xe14c)
- ("\\(<|\\)" #Xe14d)
- ("\\(<|>\\)" #Xe14e)
- ("\\(<\\$\\)" #Xe14f)
- ("\\(<\\$>\\)" #Xe150)
- ("\\(<!--\\)" #Xe151)
- ("\\(<-\\)" #Xe152)
- ("\\(<--\\)" #Xe153)
- ("\\(<->\\)" #Xe154)
- ("\\(<\\+\\)" #Xe155)
- ("\\(<\\+>\\)" #Xe156)
- ("\\(<=\\)" #Xe157)
- ("\\(<==\\)" #Xe158)
- ("\\(<=>\\)" #Xe159)
- ("\\(<=<\\)" #Xe15a)
- ("\\(<>\\)" #Xe15b)
- ("[^-]\\(<<\\)" #Xe15c)
- ("\\(<<-\\)" #Xe15d)
- ("\\(<<=\\)" #Xe15e)
- ("\\(<<<\\)" #Xe15f)
- ("\\(<~\\)" #Xe160)
- ("\\(<~~\\)" #Xe161)
- ("\\(</\\)" #Xe162)
- ("\\(</>\\)" #Xe163)
- ("\\(~@\\)" #Xe164)
- ("\\(~-\\)" #Xe165)
- ("\\(~=\\)" #Xe166)
- ("\\(~>\\)" #Xe167)
- ("[^<]\\(~~\\)" #Xe168)
- ("\\(~~>\\)" #Xe169)
- ("\\(%%\\)" #Xe16a)
- ;; ("\\(x\\)" #Xe16b)
- ("[^:=]\\(:\\)[^:=]" #Xe16c)
- ("[^\\+<>]\\(\\+\\)[^\\+<>]" #Xe16d)
- ("[^\\*/<>]\\(\\*\\)[^\\*/<>]" #Xe16f))))
- (defun add-fira-code-symbol-keywords ()
- (font-lock-add-keywords nil fira-code-font-lock-keywords-alist))
- (add-hook 'prog-mode-hook
- #'add-fira-code-symbol-keywords)
- (defun bf-pretty-print-xml-region (begin end)
- "Pretty format XML markup in region. You need to have nxml-mode
- http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
- this. The function inserts linebreaks to separate tags that have
- nothing but whitespace between them. It then indents the markup
- by using nxml's indentation rules."
- (interactive "r")
- (save-excursion
- (nxml-mode)
- (goto-char begin)
- (while (search-forward-regexp "\>[ \\t]*\<" nil t)
- (backward-char) (insert "\n"))
- (indent-region begin end))
- (message "Ah, much better!"))
- (custom-set-faces
- ;; custom-set-faces was added by Custom.
- ;; If you edit it by hand, you could mess it up, so be careful.
- ;; Your init file should contain only one such instance.
- ;; If there is more than one, they won't work right.
- )
- (defun package-install? (package-name)
- (when (not (package-installed-p package-name))
- (package-install package-name)))
- (defun insert-random-uuid ()
- (interactive)
- (lexical-let ((string (replace-regexp-in-string "\n" "" (shell-command-to-string "uuidgen"))))
- (insert string)
- (kill-new string)))
|