.spacemacs (18796B)
1 ;; -*- mode: emacs-lisp -*- 2 ;; This file is loaded by Spacemacs at startup. 3 4 ;; It must be stored in your home directory. 5 6 (setq jb55/base-layers 7 '( 8 (auto-completion :variables auto-completion-enable-help-tooltip t) 9 10 11 notmuch 12 (org :variables org-want-todo-bindings t 13 org-enable-trello-support t) 14 ;sml 15 spacemacs-layouts 16 syntax-checking 17 18 )) 19 20 (setq jb55/additional-packages 21 '( envrc 22 editor-config 23 24 (notmuch 25 :location (recipe :fetcher github 26 :repo "jb55/notmuch" 27 :branch "dev" 28 :upgrade 't 29 :files ("emacs/notmuch*.el"))) 30 (flycheck 31 :location (recipe :repo "flycheck/flycheck" 32 :fetcher github) 33 :upgrade 't) 34 35 (shen-elisp 36 :location (recipe :repo "deech/shen-elisp" 37 :fetcher github 38 :files ("shen*.el") 39 :upgrade 't)))) 40 41 (defun is-mac () 42 (string-equal system-type "darwin")) 43 44 (setq jb55/layers (if (is-mac) (cons 'osx jb55/base-layers) 45 jb55/base-layers)) 46 47 48 (setq jb55/excluded-packages (let ((base-excluded '(org-bullets org-superstar vi-tilde-fringe anaconda-mode))) 49 (if (not (is-mac)) 50 (cons 'exec-path-from-shell base-excluded) 51 base-excluded) 52 )) 53 54 (setq jb55/light-theme 'spacemacs-light) 55 (setq jb55/dark-theme 'base16-onedark) 56 (setq jb55/current-theme jb55/dark-theme) 57 58 ; needed for compilation hooks as well 59 (require 'ansi-color) 60 61 (defun display-ansi-colors () 62 (interactive) 63 (let ((inhibit-read-only t)) 64 (ansi-color-apply-on-region (point-min) (point-max)))) 65 66 (defun jb55/at-work () 67 (let* ((time (decode-time)) 68 (hour (nth 2 time))) 69 (and (>= hour 9) 70 (< hour 17)))) 71 72 (defun jb55/load-theme (theme) 73 (print (concat "loading theme " (symbol-name theme))) 74 (counsel-load-theme-action (symbol-name theme)) 75 (setq jb55/current-theme theme)) 76 77 (setq jb55/themes 78 `(("light" . ,jb55/light-theme) 79 ("dark" . ,jb55/dark-theme))) 80 81 (defun jb55/themeswitch (&optional theme) 82 (interactive) 83 (let* ((neq (lambda (x) (not (eq (cdr x) jb55/current-theme)))) 84 (tlist (seq-filter neq jb55/themes)) 85 (selected (cond ((stringp theme) theme) 86 ((and (symbolp theme) (not (eq nil theme))) (symbol-name theme)) 87 ((eq (length tlist) 1) (car (car tlist))) 88 (t (cdr (assoc (completing-read "jb55's themes" tlist) tlist))))) 89 (th (cdr (assoc selected tlist)))) 90 (if th (jb55/load-theme th)))) 91 92 (defun jb55/link-hint-download () 93 (interactive) 94 (let ((before (current-kill 0))) 95 (link-hint-copy-link) 96 (let ((url (current-kill 0))) 97 (if (not (eq url before)) 98 (with-current-buffer (get-buffer-create 99 (generate-new-buffer-name "*link-hint-url*")) 100 (condition-case exception 101 (url-insert-file-contents url) 102 ('file-error 103 ;; In case the link is private repository github will respond with a 104 ;; temporary redirect 302 HTTP code and calculate the request-token 105 ;; with javascript. In this case open diff in browser 106 (browse-url url))) 107 (switch-to-buffer (current-buffer))))))) 108 109 (defun jb55/mm-pipe-part-pdfnow (handle) 110 (mm-pipe-part handle "/home/jb55/bin/pdfnow markdown")) 111 112 (defun jb55/do-notmuch-pdfnow () 113 (notmuch-show-apply-to-current-part-handle #'jb55/mm-pipe-part-pdfnow)) 114 115 (defun jb55/notmuch-pdfnow () 116 (interactive) 117 (if (window-live-p notmuch-tree-message-window) 118 (with-selected-window notmuch-tree-message-window 119 (progn 120 (goto-line 10) 121 (jb55/do-notmuch-pdfnow))) 122 (jb55/do-notmuch-pdfnow))) 123 124 (defun jb55/determine-theme () 125 (if (jb55/at-work) 126 jb55/dark-theme 127 jb55/dark-theme)) 128 129 (defun dotspacemacs/layers () 130 "Layer configuration: 131 This function should only modify configuration layer settings." 132 (setq-default 133 dotspacemacs-distribution 'spacemacs 134 ;;dotspacemacs-enable-lazy-installation nil 135 ;;dotspacemacs-delete-orphan-packages t 136 dotspacemacs-enable-lazy-installation 'unused 137 dotspacemacs-ask-for-lazy-installation t 138 dotspacemacs-configuration-layer-path '() 139 dotspacemacs-configuration-layers jb55/layers 140 dotspacemacs-additional-packages jb55/additional-packages 141 dotspacemacs-frozen-packages '(swift 142 react 143 ruby 144 elixir 145 fsharp 146 ) 147 dotspacemacs-excluded-packages jb55/excluded-packages 148 dotspacemacs-install-packages 'used-only)) 149 150 (defun dotspacemacs/init () 151 "Initialization: 152 This function is called at the very beginning of Spacemacs startup, 153 before layer configuration. 154 It should only modify the values of Spacemacs settings." 155 (setq-default 156 dotspacemacs-themes (list (jb55/determine-theme)) 157 dotspacemacs-elpa-https t 158 dotspacemacs-elpa-timeout 5 159 dotspacemacs-use-spacelpa nil 160 dotspacemacs-verify-spacelpa-archives nil 161 dotspacemacs-check-for-update nil 162 dotspacemacs-elpa-subdirectory 'emacs-version 163 dotspacemacs-editing-style 'vim 164 dotspacemacs-verbose-loading nil 165 dotspacemacs-startup-banner 'official 166 dotspacemacs-startup-lists '((recents . 5) 167 (projects . 7)) 168 dotspacemacs-startup-buffer-responsive t 169 dotspacemacs-scratch-mode 'text-mode 170 ;; dotspacemacs-themes '(spacemacs-dark 171 ;; spacemacs-light) 172 dotspacemacs-colorize-cursor-according-to-state t 173 ;; dotspacemacs-default-font '("terminus" 174 ;; :size 16 175 ;; :style normal 176 ;; :weight normal 177 ;; :width normal 178 ;; ) 179 dotspacemacs-default-font '("Inconsolata" 180 :size 18 181 :weight normal 182 :width normal 183 :powerline-scale 1.1) 184 dotspacemacs-active-transparency 90 185 dotspacemacs-auto-generate-layout-names nil 186 dotspacemacs-auto-resume-layouts nil 187 dotspacemacs-auto-save-file-location 'cache 188 dotspacemacs-default-layout-name "Default" 189 dotspacemacs-default-package-repository nil 190 dotspacemacs-display-default-layout nil 191 dotspacemacs-distinguish-gui-tab nil 192 dotspacemacs-emacs-command-key "SPC" 193 dotspacemacs-emacs-leader-key "M-m" 194 dotspacemacs-enable-paste-transient-state nil 195 dotspacemacs-ex-command-key ":" 196 dotspacemacs-ex-substitute-global nil 197 dotspacemacs-folding-method 'evil 198 dotspacemacs-frame-title-format "%I@%S" 199 dotspacemacs-fullscreen-at-startup nil 200 dotspacemacs-fullscreen-use-non-native nil 201 dotspacemacs-helm-no-header nil 202 dotspacemacs-helm-position 'bottom 203 dotspacemacs-helm-resize nil 204 dotspacemacs-helm-use-fuzzy 'always 205 dotspacemacs-highlight-delimiters 'all 206 dotspacemacs-icon-title-format nil 207 dotspacemacs-inactive-transparency 90 208 dotspacemacs-large-file-size 1 209 dotspacemacs-leader-key "SPC" 210 dotspacemacs-line-numbers nil 211 dotspacemacs-loading-progress-bar t 212 dotspacemacs-major-mode-emacs-leader-key "C-M-m" 213 dotspacemacs-major-mode-leader-key "," 214 dotspacemacs-maximized-at-startup nil 215 dotspacemacs-max-rollback-slots 5 216 dotspacemacs-mode-line-unicode-symbols nil 217 dotspacemacs-persistent-server nil 218 dotspacemacs-pretty-docs nil 219 dotspacemacs-remap-Y-to-y$ 't 220 dotspacemacs-retain-visual-state-on-shift t 221 dotspacemacs-search-tools '("rg" "ag" "pt" "ack" "grep") 222 dotspacemacs-server-socket-dir "~/.emacs.d/server" 223 dotspacemacs-show-transient-state-color-guide t 224 dotspacemacs-show-transient-state-title t 225 dotspacemacs-smart-closing-parenthesis nil 226 dotspacemacs-smartparens-strict-mode nil 227 dotspacemacs-smooth-scrolling t 228 dotspacemacs-switch-to-buffer-prefers-purpose nil 229 dotspacemacs-visual-line-move-text nil 230 dotspacemacs-which-key-delay 0.4 231 dotspacemacs-which-key-position 'bottom 232 dotspacemacs-whitespace-cleanup nil 233 dotspacemacs-zone-out-when-idle nil 234 )) 235 236 (defun dotspacemacs/user-env () 237 (setq custom-file "~/dotfiles/custom.el") 238 (load custom-file) 239 ) 240 241 (defun notmuch-always-bcc-sender () 242 (message-add-header (concat "Bcc: " (message-fetch-field "From")))) 243 244 (defun dotspacemacs/user-init () 245 "Initialization for user code: 246 This function is called immediately after `dotspacemacs/init', before layer 247 configuration. 248 It is mostly for variables that should be set before packages are loaded. 249 If you are unsure, try setting them in `dotspacemacs/user-config' first." 250 (setq server-socket-dir "/home/jb55/.emacs.d/server") 251 252 (defun cd-github () 253 (interactive) 254 (cd (concat "/home/jb55/dev/github/" (read-string "Repo: ")))) 255 256 257 (defun jb55/eshell-prompt () 258 (concat (abbreviate-file-name (eshell/basename (eshell/pwd))) 259 (if (= (user-uid) 0) " # " " $ "))) 260 261 (load "~/src/elisp/notmuch/notmuch-github.el") 262 (add-hook 'message-send-hook 'notmuch-always-bcc-sender) 263 ;; (load "~/src/elisp/overlays/overlays.el") 264 265 (defun cd-gh (&optional repo) 266 (interactive) 267 (let ((rep (or repo (read-string "cd github owner/repo: ")))) 268 (when (not (eq 0 (length rep))) 269 (cd (concat "/home/jb55/dev/github/" rep))))) 270 271 (defun cd-repo () 272 (interactive) 273 (let ((repo (notmuch-repo-from-message))) 274 (cd-gh repo))) 275 276 (defun colorize-compilation-buffer () 277 (toggle-read-only) 278 (ansi-color-apply-on-region (point-min) (point-max)) 279 (toggle-read-only)) 280 281 (add-hook 'compilation-filter-hook 'colorize-compilation-buffer) 282 (add-to-list 'comint-output-filter-functions 'ansi-color-process-output) 283 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) 284 285 (require 'compile) 286 ;; node stack track compilation errors in js-mode 287 (add-to-list 'compilation-error-regexp-alist-alist 288 '(npm "[[:space:]](?\\(.*?\\)\\([0-9A-Za-z_./\:-]+\\.\\(js\\|coffee\\)\\):\\([0-9]+\\):\\([0-9]+\\)" 2 4 5) 289 ) 290 291 (add-to-list 'compilation-error-regexp-alist 'npm) 292 (global-hl-line-mode -1) 293 (setq compilation-scroll-output t) 294 295 ) 296 297 (defun jb55/error-config () 298 (defcustom next-error-message-highlight-p nil 299 "If non-nil, highlight the current error message in the ‘next-error’ buffer" 300 :type 'boolean 301 :group 'next-error 302 :version "??") 303 304 (defface next-error-message 305 '((t (:inherit highlight))) 306 "Face used to highlight the current error message in the ‘next-error’ buffer" 307 :group 'next-error 308 :version "??") 309 310 (defvar next-error-message-highlight-overlay 311 nil 312 "Overlay highlighting the current error message in the ‘next-error’ buffer") 313 314 (make-variable-buffer-local 'next-error-message-highlight-overlay) 315 316 (defun next-error-message-highlight () 317 "Highlight the current error message in the ‘next-error’ buffer." 318 (when next-error-message-highlight-p 319 (with-current-buffer next-error-last-buffer 320 (when next-error-message-highlight-overlay 321 (delete-overlay next-error-message-highlight-overlay)) 322 (save-excursion 323 (goto-char (point)) 324 (let ((ol (make-overlay (line-beginning-position) (line-end-position)))) 325 ;; do not override region highlighting 326 (overlay-put ol 'priority -50) 327 (overlay-put ol 'face 'next-error-message) 328 (overlay-put ol 'window (get-buffer-window)) 329 (setf next-error-message-highlight-overlay ol)))))) 330 331 (add-hook 'next-error-hook 'next-error-message-highlight) 332 333 (setq next-error-message-highlight-p t) 334 ) 335 336 (defun dotspacemacs/user-config () 337 "Configuration for user code: 338 This function is called at the very end of Spacemacs startup, after layer 339 configuration. 340 Put your configuration code here, except for variables that should be set 341 before packages are loaded." 342 (setq jb55/org-path "~/docs/org") 343 344 (envrc-global-mode) 345 346 ;;(use-package direnv 347 ;; ;; Ensures that external dependencies are available before they are called. 348 ;; :config 349 ;; (add-to-list 'direnv-non-file-modes 'vterm-mode) 350 ;; (direnv-mode 1)) 351 352 ;; fix really annoying clipboard race issue 353 (fset 'evil-visual-update-x-selection 'ignore) 354 (jb55/error-config) 355 356 (setq ediff-window-setup-function 'ediff-setup-windows-plain) 357 (set-face-background 'fringe "#1e1f22") 358 (set-face-foreground 'vertical-border "#1e1f22") 359 (setq gnus-inhibit-images nil) 360 361 (defun jb55/compilation-finish (buffer status) 362 (call-process "notify-send" nil nil nil 363 "-i" "emacs" 364 "Emacs compilation" 365 status)) 366 367 (setq compilation-finish-functions 368 (append compilation-finish-functions 369 '(jb55/compilation-finish))) 370 371 (defun jb55/notmuch-show-insert-header-p (part hide) 372 ;; Show all part buttons except for the first part if it is text/plain. 373 (let ((mime-type (notmuch-show-mime-type part))) 374 (not (or (and (string= mime-type "text/plain") 375 (<= (plist-get part :id) 3)) 376 (member mime-type (list "multipart/alternative" 377 "multipart/mixed" 378 "multipart/signed")))))) 379 380 (setq notmuch-show-insert-header-p-function 381 'jb55/notmuch-show-insert-header-p) 382 383 (setq ivy-initial-inputs-alist (list)) 384 385 (setq spacemacs-indent-sensitive-modes 386 (add-to-list 'spacemacs-indent-sensitive-modes 'nix-mode)) 387 388 (setq org-want-todo-bindings 't) 389 390 (defun jb55/forward-page-recenter-top () 391 (interactive) 392 (evil-ex-search-next) 393 (evil-scroll-line-to-center (line-number-at-pos))) 394 395 (defun jb55/backward-page-recenter-top () 396 (interactive) 397 (evil-ex-search-previous) 398 (evil-scroll-line-to-center (line-number-at-pos))) 399 400 (defun jb55/xref-find-def () 401 (interactive) 402 (let ((current-prefix-arg 4)) 403 (call-interactively 'xref-find-definitions))) 404 405 (setq-default olivetti-body-width 80) 406 407 (load "view.el") 408 (define-key evil-motion-state-map (kbd "C-d") 'View-scroll-page-forward) 409 (define-key evil-motion-state-map (kbd "C-u") 'View-scroll-page-backward) 410 411 (spacemacs/set-leader-keys 412 "Ju" 'jb55/unhighlight-line 413 "J]" 'jb55/forward-page-recenter-top 414 "J[" 'jb55/backward-page-recenter-top 415 416 "wc" 'olivetti-mode 417 "xb" 'jb55/link-hint-download 418 "Jd" 'jb55/xref-find-def 419 "jd" 'dumb-jump-go 420 "jD" 'dumb-jump-go-prompt 421 "is" 'company-yasnippet 422 "aTn" 'twittering-update-status-interactive 423 "aTu" 'twittering-user-timeline 424 "aTm" 'twittering-mentions-timeline 425 ) 426 427 (defun notmuch-switch-to-home () 428 (setq message-signature-file "~/.signature") 429 (setq notmuch-command "notmuch") 430 (setq notmuch-poll-script "notmuch-update-personal") 431 ;;(setq notmuch-saved-searches notmuch-saved-searches-home) 432 ) 433 434 ;; (defun notmuch-switch-to-work () 435 ;; (interactive) 436 ;; (setq message-signature-file "~/.signature-work") 437 ;; (setq notmuch-command "notmuch-work") 438 ;; (setq notmuch-command "notmuch-work") 439 ;; (setq notmuch-poll-script "fetch-work-mail") 440 ;; (setq notmuch-saved-searches notmuch-saved-searches-work)) 441 442 (notmuch-switch-to-home) 443 444 (defun jb55/make-org-path (file) 445 (concat (file-name-as-directory jb55/org-path) file)) 446 447 (defun task-body (label) 448 (concat "* " label " %?\n %i\n %a")) 449 450 (setq todo-task (task-body "TODO")) 451 452 (setq org-capture-templates 453 `(("t" "Task" entry (file+headline ,(jb55/make-org-path "tasks.org") "Unorganized") 454 ,todo-task) 455 ("n" "Notes" entry (file+headline ,(jb55/make-org-path "notes.org") "Notes") 456 ,(task-body "NOTE")) 457 ("w" "Razor task" entry (file+headline "~/projects/razorcx/doc/org/todo.org" "Current") 458 ,todo-task) 459 ("o" "Openstamp task" entry (file+headline "~/projects/openstamp/openstamp-server/todo.org" "Current") 460 ,todo-task) 461 )) 462 463 (setq org-agenda-custom-commands 464 '(("w" "Work review" 465 ((agenda "" ((org-agenda-ndays 7) 466 (org-agenda-repeating-timestamp-show-all nil) 467 (org-agenda-start-on-weekday nil) 468 )) 469 (tags-todo "+sprint&-waiting") 470 (tags-todo "+payments&-waiting") 471 (tags-todo "+waiting") 472 ) 473 ((org-agenda-category-filter-preset '("+work")))) 474 ("h" "Home review" 475 ((agenda "" ((org-agenda-ndays 7) 476 (org-agenda-repeating-timestamp-show-all nil) 477 (org-agenda-start-on-weekday nil) 478 )) 479 (tags-todo "vanessa") 480 (tags-todo "razor") 481 (tags "tinker") 482 (tags "errand")) 483 ((org-agenda-tag-filter-preset '("-work")) 484 (org-agenda-category-filter-preset '("-work")) 485 (org-agenda-repeating-timestamp-show-all nil) 486 )) 487 ("hu" "Unscheduled" search "-SCHEDULED & -DEADLINE") 488 ("g" . "GTD contexts") 489 ("gr" "Razor" tags-todo "razor") 490 ("gt" "Tinker" tags-todo "tinker") 491 ("gp" "polyadvent" tags-todo "polyadvent") 492 ("G" "GTD Block Agenda" 493 ((tags-todo "polyadvent") 494 ) 495 nil) 496 )) 497 498 ;; fixes tramp slowness 499 (setq projectile-mode-line "Projectile") 500 (defadvice projectile-project-root (around ignore-remote first activate) 501 (unless (file-remote-p default-directory) ad-do-it)) 502 503 (setq fci-rule-character-color "#202020") 504 (setq fci-rule-color "gray10") 505 (setq haskell-hoogle-command nil) 506 (setq haskell-hoogle-url "http://localhost:8080/?hoogle=%s") 507 ;; (setq haskell-process-type (quote ghci)) 508 509 ) 510 511 (defun dotspacemacs/emacs-custom-settings () 512 "Emacs custom settings. 513 This is an auto-generated function, do not modify its content directly, use 514 Emacs customize menu instead. 515 This function is called at the very end of Spacemacs initialization." 516 (custom-set-variables 517 ;; custom-set-variables was added by Custom. 518 ;; If you edit it by hand, you could mess it up, so be careful. 519 ;; Your init file should contain only one such instance. 520 ;; If there is more than one, they won't work right. 521 '(vc-follow-symlinks t)) 522 (custom-set-faces 523 ;; custom-set-faces was added by Custom. 524 ;; If you edit it by hand, you could mess it up, so be careful. 525 ;; Your init file should contain only one such instance. 526 ;; If there is more than one, they won't work right. 527 ) 528 )