.emacs 53 KB
Newer Older
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                          ;;
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
3 4 5
;;           Torstein Krause Johansen's .emacs file                         ;;
;;                                                                          ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 7 8 9 10 11 12

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Initialise the emacs packages in case any of them overrides
;; built-in Emacs packages.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(package-initialize)

13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;; Emacs package management
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 17 18
(setq package-archives '(("melpa" . "http://melpa.org/packages/")
                         ("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "http://marmalade-repo.org/packages/")))
19

20
;; Add ELPA packages to the loadpp path
21 22 23
(let ((default-directory "~/.emacs.d/elpa"))
  (normal-top-level-add-subdirs-to-load-path))

24 25 26 27 28 29 30 31 32 33
;; Ensure use-package is installed and loaded
(condition-case nil
    (require 'use-package)
  (file-error
   (require 'package)
   (package-initialize)
   (package-refresh-contents)
   (package-install 'use-package)
   (require 'use-package)))

34 35 36
;; Let use-package install all packages mentioned if they're not
;; already installed.
(setq use-package-always-ensure t)
37

38 39 40 41 42 43
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Put all Emacs customize variables & faces in its own file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
44 45 46
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Edit text areas in Chrome browsers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 48 49 50 51
(when (locate-library "edit-server")
  (require 'edit-server)
  (setq edit-server-new-frame nil)
  (edit-server-start))

52
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
53
;; Minibuffer
54
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

;; Enhanced M-x
(use-package counsel
  :bind
  (("M-x" . counsel-M-x)))

;; IDO
(use-package ido
  :init
  (setq ido-everywhere nil
        ido-enable-flex-matching t
        ido-create-new-buffer 'always
        ido-file-extensions-order '(".java" ".js" ".el" ".xml")
        ido-use-filename-at-point 'guess
        ido-use-faces t)

  :config
  (ido-mode 'buffer)

  :bind ("C-x b" . ido-switch-buffer)
  )

;; Improved flex matching
(use-package flx-ido)

;; Vertical completion menu
(use-package ido-vertical-mode
  :init
  (setq ido-vertical-indicator ">>"
        ido-vertical-show-count nil
        ido-vertical-define-keys 'C-n-C-p-up-and-down)
  :config
  (ido-vertical-mode)
  (ido-vertical-mode nil))

;; If not using ido-vertical-mode, make the minibuff stay still,
;; i.e. never change height, set this to nil.
;; (setq resize-mini-windows 'grow-only)

;; IDO support pretty much everwhere, including eclim-java-implement
(use-package ido-completing-read+
  :config
  (ido-ubiquitous-mode))

;; Sub word support
(add-hook 'minibuffer-setup-hook 'subword-mode)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Improve Emacs' internal garbage collection
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun my-minibuffer-setup-hook ()
  (setq gc-cons-threshold most-positive-fixnum))

(defun my-minibuffer-exit-hook ()
  (setq gc-cons-threshold 800000))

(add-hook 'minibuffer-setup-hook #'my-minibuffer-setup-hook)
(add-hook 'minibuffer-exit-hook #'my-minibuffer-exit-hook)
113

114
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
115 116
;; Mode line settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176

(defun tkj-mode-line-simple()
  (interactive)
  (setq-default mode-line-format '("%b %* (%l,%c)")))

(defun tkj-mode-line-pretty()
  (interactive)
  ;; Taken from https://github.com/gonsie/dotfiles/blob/master/emacs/theme.el
  ;; use setq-default to set it for /all/ modes
  (setq-default mode-line-format
                (list
                 ;; the buffer name; the file name as a tool tip
                 '(:eval (propertize " %b "
                                     'face
                                     (let ((face (buffer-modified-p)))
                                       (if face 'font-lock-warning-face
                                         'font-lock-type-face))
                                     'help-echo (buffer-file-name)))
                 ;; line and column
                 " (" ;; '%02' to set to 2 chars at least; prevents flickering
                 (propertize "%02l" 'face 'font-lock-keyword-face) ","
                 (propertize "%02c" 'face 'font-lock-keyword-face)
                 ") "

                 ;; relative position, size of file
                 " ["
                 (propertize "%p" 'face 'font-lock-constant-face) ;; % above top
                 "/"
                 (propertize "%I" 'face 'font-lock-constant-face) ;; size
                 "] "

                 ;; version control
                 '(:eval (propertize (substring vc-mode 5)
                                     'face 'font-lock-comment-face))

                 ;; spaces to align right
                 '(:eval (propertize
                          " " 'display
                          `((space :align-to (- (+ right right-fringe right-margin)
                                                ,(+ 3 (string-width mode-name)))))))

                 ;; the current major mode
                 (propertize " %m " 'face 'font-lock-string-face)
                 ;;minor-mode-alist
                 ))

  (set-face-attribute 'mode-line nil
                      :background "#353644"
                      :foreground "white"
                      :box '(:line-width 1 :color "#353644")
                      :overline nil
                      :underline nil)

  (set-face-attribute 'mode-line-inactive nil
                      :background "#565063"
                      :foreground "white"
                      :box '(:line-width 1 :color "#565063")
                      :overline nil
                      :underline nil)
  )
177

178 179 180 181 182 183
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Show paren mode, built-in from Emacs 24.x
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(show-paren-mode t)
(setq show-paren-style 'expression)

184
(use-package paren)
185 186
(set-face-background 'show-paren-match (face-background 'default))
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
187

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
188 189 190 191 192 193 194 195 196 197 198 199 200
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setting the general load path for Emacs. This load path is for
;; packages that only have one .el file and hence reside in a
;; directory with other smaller modes.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq load-path
      (append (list (expand-file-name "/usr/local/emacs/")
                    "/usr/share/emacs/site-lisp/w3m"
                    "/usr/share/emacs/site-lisp/mu4e"
                    "/usr/share/emacs/site-lisp/global"
                    "/usr/local/src/varnish/varnish-tools/emacs")
              load-path))

201
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
202
;; saves the buffer/split configuration, makes it un/re-doable.
203
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
204
(winner-mode 1)
205 206
(global-set-key (kbd "<C-left>") 'winner-undo)
(global-set-key (kbd "<C-right>") 'winner-redo)
207

208 209 210 211 212 213 214 215 216
;; navigate between visible buffers (windows in emacs speak)
(defun other-window-backward (&optional n)
  (interactive "p")
  (if n
      (other-window (- n))
    (other-frame -1)))
(global-set-key "\C-x\C-n" 'other-window)
(global-set-key "\C-x\C-p" 'other-window-backward)

217 218 219 220
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Shortcuts in all modes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(global-set-key "\M- " 'hippie-expand)
221
(global-set-key "\M-r" 'join-line)
222
;; minimising Emacs way too many times without wanting to.
223
(global-unset-key "\C-z")
224 225 226 227
;; don't write backslashed to indicate continuous lines
(set-display-table-slot standard-display-table 'wrap ?\ )
;; Treat 'y' or <CR> as yes, 'n' as no.
(fset 'yes-or-no-p 'y-or-n-p)
228
(global-set-key (kbd "<f1>") 'magit-status)
229
(global-set-key (kbd "<XF86MyComputer>") 'magit-status)
230

231 232 233
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs open grep and find
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
234
(global-set-key "\C-\M-f" 'find-file-at-point)
235
(global-set-key "\C-cn" 'find-dired)
236
(global-set-key "\C-cN" 'grep-find)
237

238
(use-package grep)
239
(setq grep-find-ignored-directories
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
      (append
       (list
        ".git"
        ".hg"
        ".idea"
        ".project"
        ".settings"
        ".svn"
        "bootstrap*"
        "pyenv"
        "target"
        )
       grep-find-ignored-directories))

(setq grep-find-ignored-files
      (append
       (list
        "*.blob"
258 259
        "*.gz"
        "*.jar"
260 261 262
        "*.xd"
        "TAGS"
        "dependency-reduced-pom.xml"
263
        "projectile.cache"
264 265 266 267 268
        "workbench.xmi"
        )
       grep-find-ignored-files))

(setq grep-find-command
269
      "find ~/src/content-engine -name \"*.java\" | xargs grep -n -i -e ")
270

271
(use-package ag
272 273
  :init
  (setq ag-arguments (list "--word-regexp" "--smart-case"))
274 275
  )

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
276
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
277 278 279
;; Prefer UTF 8, but don't override current encoding if specified
;; (unless you specify a write hook).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
280
(prefer-coding-system 'utf-8-unix)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
281

282
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
283
;; White space
284
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
285
(setq tab-width 2)
286
(setq-default indent-tabs-mode nil)
287

288
;; ws-butler cleans up whitespace only on the lines you've edited,
289 290 291
;; keeping messy colleagues happy ;-) Important that it doesn't clean
;; the whitespace on currrent line, otherwise, eclim leaves messy
;; code behind.
292 293 294 295 296
(use-package ws-butler
  :init
  (setq ws-butler-keep-whitespace-before-point nil)
  :config
  (ws-butler-global-mode))
297

298 299
(defun tkj-indent-and-fix-whitespace()
  (interactive)
300
  (delete-trailing-whitespace)
301 302 303 304
  (untabify (point-min) (point-max))
  (indent-region (point-min) (point-max)))
(global-set-key "\C-\M-\\" 'tkj-indent-and-fix-whitespace)

305
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
306
;; Spell checking
307
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
308 309 310 311 312 313 314 315
(use-package ispell
  :init
  (setq ispell-program-name "aspell"
        ispell-list-command "list"
        ispell-dictionary "british"
        flyspell-auto-correct-binding (kbd "<S-f12>")))

(use-package flycheck)
316

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
317 318 319
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tag lookup/auto completion based on GNU Global
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
320
(use-package gtags)
321
(setq xref-prompt-for-identifier nil)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
322

323
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
324
;; Pure text settings
325 326 327
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'text-mode-hook
          '(lambda ()
328
             (flyspell-mode)
329
             (git-gutter+-mode)
330
             (auto-fill-mode 1)))
331 332
(setq longlines-show-hard-newlines t)

333 334 335 336 337
(defun tkj-insert-left-arrow()
  (interactive)
  (insert "←"))
(defun tkj-insert-right-arrow()
  (interactive)
338
  (insert "→"))
339 340 341 342 343 344 345
(defun tkj-insert-up-arrow()
  (interactive)
  (insert "↑"))
(defun tkj-insert-down-arrow()
  (interactive)
  (insert "↓"))

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Shortcuts available in all modes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Making the Mac cmd or Windows key useful, simply letting it act as
;; as its Alt cousin when pressed in combination with my most used
;; combinations (yes, I have re-mapped it in xmodmap, but when
;; changing keymaps too often, it goes totally astray and I sometimes
;; just must give in to the mightyness of the Super key).
(global-set-key [ (super backspace) ] 'backward-kill-word)
(global-set-key [ (super b) ] 'backward-word)
(global-set-key [ (super c) ] 'capitalize-word)
(global-set-key [ (super f) ] 'forward-word)
(global-set-key [ (super l) ] 'downcase-word)
(global-set-key [ (super u) ] 'upcase-word)
(global-set-key [ (super v) ] 'scroll-down)
(global-set-key [ (super w) ] 'kill-ring-save)
(global-set-key [ (super x) ] 'execute-extended-command)

(global-unset-key "\C-x\C-c") ;; quitting too often without wanting to
(global-set-key "\C-x\C-c" 'compile) ;; imenu
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
367
(global-set-key (kbd "<C-S-f10>") 'recompile)
368
(global-set-key (kbd "<C-tab>") 'completion-at-point)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
369

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
370 371 372 373 374 375 376 377 378 379
;; newline and indent (like other editors, even vi, do).
(global-set-key  "\C-m" 'newline-and-indent)

(define-key query-replace-map [return] 'act)
(define-key query-replace-map [?\C-m] 'act)

;; Make Emacs wrap long lines visually, but not actually (i.e. no
;; extra line breaks are inserted.
(global-visual-line-mode 1)

380
;; Automatically reload files was modified by external program
381
(global-set-key  [ (f5) ] 'revert-buffer)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
382
(global-auto-revert-mode 1)
383 384
(setq revert-without-query (list "\\.png$" "\\.svg$")
      auto-revert-verbose nil)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
385

386 387 388 389 390
;; Give visual hint where the cursor is when switching buffers.
(use-package beacon
  :config
  (beacon-mode 1))

391
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
392
;; Compile buffer
393
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
(use-package compile
  :init
  (setq compilation-ask-about-save nil
        compilation-scroll-output 'next-error
        ;; Don't stop on info or warnings.
        compilation-skip-threshold 2)
  )

;; Taken from https://emacs.stackexchange.com/questions/31493/print-elapsed-time-in-compilation-buffer/56130#56130
(make-variable-buffer-local 'my-compilation-start-time)

(add-hook 'compilation-start-hook #'my-compilation-start-hook)
(defun my-compilation-start-hook (proc)
  (setq my-compilation-start-time (current-time)))

(add-hook 'compilation-finish-functions #'my-compilation-finish-function)
(defun my-compilation-finish-function (buf why)
  (let* ((elapsed  (time-subtract nil my-compilation-start-time))
         (msg (format "Compilation took: %s" (format-time-string "%T.%N" elapsed t))))
    (save-excursion (goto-char (point-max)) (insert msg))
    (message "Compilation %s: %s" (string-trim-right why) msg)))
415

416 417 418 419 420
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Editing VC log messages
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'log-edit-hook (lambda () (flyspell-mode 1)))

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
421 422 423
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Multiple, real time replace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
424
(use-package multiple-cursors)
425 426 427
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
428
(global-set-key (kbd "C-c C->") 'mc/mark-all-like-this-dwim)
429
(global-set-key (kbd "C-c C-'") 'mc/mark-all-like-this-in-defun)
430

431 432 433
(use-package expand-region
  :bind
  ("C-=" . 'er/expand-region))
434

435
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
436
;; ivy, counsel and swiper. Mostly minibuffer and navigation
437
;; enhancements. Using smex for last recently used sorting.
438
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
439
(use-package smex)
440

441 442 443
(use-package ivy
  :init
  (setq ivy-re-builders-alist '((t . ivy--regex-fuzzy))
444
        ivy-height 20
445
        ivy-initial-inputs-alist nil)
446
  )
447

448 449 450 451
(use-package ivy-posframe
  :init
  (setq ivy-posframe-display-functions-alist
        '((complete-symbol . ivy-posframe-display-at-point)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
452 453
          (counsel-M-x     . ivy-posframe-display-at-frame-center)
          (t               . ivy-posframe-display-at-frame-center)))
454
  (ivy-posframe-mode 0))
455 456 457 458 459

(use-package ivy-rich
  :init
  (ivy-rich-mode 1))

460 461
(use-package counsel
  :bind
462
  ("C-."   . 'counsel-imenu)
463 464
  ("C-c '" . 'counsel-git-grep)
  ("C-c ," . 'counsel-imenu)
465 466
  ("C-h f" . 'counsel-describe-function)
  ("C-h v" . 'counsel-describe-variable)
467
  ("C-x b" . 'counsel-switch-buffer)
468
  )
469
(global-set-key (kbd "C-s") 'isearch-forward)
470
(global-set-key (kbd "C-'") 'swiper-isearch-thing-at-point)
471

472 473 474 475 476
(use-package counsel-projectile
  :bind
  ("C-c p f" . 'counsel-projectile-find-file)
  )

477 478 479
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Buffers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
480 481
;; Make C-x C-b maximise the buffer list window, this saves two
;; additional shortcuts from the normal behaviour.
482 483 484 485 486 487 488 489 490
(use-package helm
  :init
  (defun tkj-list-buffers()
    (interactive)
    (let ((helm-full-frame t))
      (helm-mini)))

  :bind
  ("C-x C-b" . 'tkj-list-buffers))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
491

492 493 494 495
(defun close-all-buffers ()
  (interactive)
  (mapc 'kill-buffer (buffer-list)))

496
;; buffer names and mini buffer
497
(use-package uniquify
498
  :ensure nil
499 500 501 502 503
  :init
  (setq uniquify-buffer-name-style 'forward
        uniquify-separator ":"
        uniquify-strip-common-suffix nil
        read-file-name-completion-ignore-case t))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
504

505 506 507
;; Auto scroll the compilation window
(setq compilation-scroll-output t)

508 509
;; Scroll up and down while keeping the cursor where it is.
(defun help/scroll-up-one-line ()
510
  (interactive)
511 512
  (scroll-down 1))
(defun help/scroll-down-one-line ()
513
  (interactive)
514
  (scroll-up 1))
515 516
(global-set-key (kbd "M-p") 'help/scroll-down-one-line)
(global-set-key (kbd "M-n") 'help/scroll-up-one-line)
517

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
518
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
519
;; Mail & news
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
520
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
(require 'mu4e)

;; Create org notes with links to Email messages
(require 'org-mu4e)
(define-key mu4e-headers-mode-map (kbd "C-c c") 'org-mu4e-store-and-capture)
(define-key mu4e-view-mode-map    (kbd "C-c c") 'org-mu4e-store-and-capture)

;; Bookmarks
(add-to-list 'mu4e-bookmarks
             (make-mu4e-bookmark
              :name  "Flagged messages (🌟 in GMail)"
              :query "flag:flagged"
              :key ?f))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Name and email
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq user-full-name "Torstein Krause Johansen"
      user-mail-address "[email protected]")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mail (and news), common to both Gnus and VM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq gnus-agent-directory "~/mail/agent"
      gnus-article-save-directory "~/mail"
      gnus-cache-directory "~/mail/cache"
      gnus-directory "~/mail"
      gnus-dribble-directory "~/mail/dribble"
      gnus-local-organization "Escenic"
      mail-default-directory "~/mail"
      mail-from-style 'angles
      mail-interactive nil
      mail-self-blind t
      message-directory "~/mail"
      )

(setq mu4e-maildir "~/mail"
      mu4e-attachment-dir  "~/tmp"
      mu4e-get-mail-command "offlineimap"
      mu4e-debug nil
      mu4e-use-fancy-chars t
      ;; don't save messages to Sent Messages, Gmail/IMAP will take
      ;; care of this
      mu4e-sent-messages-behavior 'trash

      mu4e-view-show-images nil

      ;; Easier to read HTML email in dark themes
      shr-color-visible-luminance-min 80

      mu4e-compose-signature t

      ;; See C-h v mu4e-header-info for more
      mu4e-headers-fields
      '( (:date          .  12)
         (:maildir       .  20)
         (:from          .  22)
         (:subject       .  nil))

      ;; common SMTP settings for all accounts
      message-send-mail-function 'smtpmail-send-it

      ;; Make GPG work with emacs daemon (by default, Emacs will
      ;; attempt and fail to connect to the GPG agent and then fail
      ;; the GPG alltogether.
      epa-pinentry-mode 'loopback)

;; Navigate links in rich text email by Tab/Shift + Tab
(add-hook 'mu4e-view-mode-hook
          (lambda()
            (local-set-key (kbd "<tab>") 'shr-next-link)
            (local-set-key (kbd "<backtab>") 'shr-previous-link)))

594 595 596 597 598
;; View actions
(add-to-list 'mu4e-view-actions
             '("display in browser" . mu4e-action-view-in-browser) t)


599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
(defun tkj-load-mu4e-escenic()
  (interactive)
  (setq  mu4e-maildir-shortcuts
         '(
           ("/escenic/inbox" . ?i)
           ("/escenic/jira" . ?j)
           ("/escenic/build" . ?e)
           ("/escenic/wiki" . ?w)
           )
         user-mail-address "[email protected]"
         smtpmail-smtp-server "smtp.gmail.com"
         smtpmail-smtp-service 587
         smtpmail-stream-type 'starttls
         message-signature-file "~/.signature-escenic"
         )
  )
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629

(defun tkj-load-mu4e-stibodx()
  (interactive)
  (setq  mu4e-maildir-shortcuts
         '(
           ("/stibodx/INBOX" . ?i)
           )
         user-mail-address "[email protected]"
         smtpmail-smtp-server "localhost"
         smtpmail-smtp-service 1025
         smtpmail-stream-type 'plain
         message-signature-file "~/.signature-stibodx"
         )
  )

630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
(defun tkj-load-mu4e-gmail()
  (interactive)
  (setq mu4e-maildir-shortcuts
        '(
          ("/gmail/community" . ?c)
          ("/gmail/inbox" . ?i)
          )
        user-mail-address "[email protected]"
        smtpmail-smtp-server "smtp.gmail.com.personal"
        smtpmail-smtp-service 587
        smtpmail-stream-type 'starttls
        message-signature-file "~/.signature-gmail"
        )
  )

(defun tkj-load-mu4e-gmailw()
  (interactive)
  (setq mu4e-maildir-shortcuts
        '(
          ("/gmailw/saas-alerts" . ?a)
          ("/gmailw/community" . ?c)
          ("/gmailw/developers-list" . ?d)
          ("/gmailw/engine-5-list" . ?e)
          ("/gmailw/vizrt-forum" . ?f)
          ("/gmailw/inbox" . ?i)
          ("/gmailw/jira" . ?j)
          ("/gmailw/p4" . ?p)
          ("/gmailw/saas" . ?s)
          ("/gmailw/twitter" . ?t)
          )
        user-mail-address "[email protected]"
        smtpmail-smtp-server "smtp.gmail.com.work"
        smtpmail-smtp-service 587
        smtpmail-stream-type 'starttls
        message-signature-file "~/.signature-escenic"
        )
  )

(defun tkj-highlight-message-hook()
  "Highlights messages, especially diffs."
  (interactive)
  (highlight-lines-matching-regexp "^ \\+.*" 'hi-green-b)
  (highlight-lines-matching-regexp "^ \\-.*" 'hi-red-b))
(add-hook 'mu4e-view-mode-hook 'tkj-highlight-message-hook)

;; use imagemagick, if available
(when (fboundp 'imagemagick-register-types)
  (imagemagick-register-types))

;; default profile
680
(tkj-load-mu4e-stibodx)
681

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
682
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
683
;; Reading & writing files
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
684
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
685
(load "~/.emacs.d/tkj-files.el")
686

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
687 688 689
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Auto complete
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
690 691
(use-package company
  :init
692 693
  (setq company-idle-delay 0.0
        company-minimum-prefix-length 1))
694
(global-company-mode 1)
695
(global-set-key (kbd "<C-return>") 'company-complete)
696
(use-package company-emoji)
697
(add-to-list 'company-backends 'company-emoji)
698

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
699 700 701
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CSS mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
702
(load "~/.emacs.d/tkj-css.el")
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
703

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
704 705 706 707 708
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; YAML
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package yaml-mode)

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
709 710 711 712 713
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Associate different modes with different file types.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq auto-mode-alist
      (append
714
       '(
715
         ("ChangeLog" . change-log-mode)
716 717 718
         ("Dockerfile" . dockerfile-mode)
         ("Pipfile" . conf-mode)
         ("\\.awk\\'" . awk-mode)
719
         ("\\.bashrc\\'" . sh-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
720
         ("\\.bib\\'" . bibtex-mode)
721
         ("\\.blockdiag\\'" . perl-mode)
722 723 724 725 726 727
         ("\\.c\\'" . c-mode)
         ("\\.cgi\\'" . python-mode)
         ("\\.conf\\'" . conf-mode)
         ("\\.config\\'" . conf-mode)
         ("\\.cpp\\'" . c++-mode)
         ("\\.css\\'" . css-mode)
728
         ("\\.diff\\'" . diff-mode)
729
         ("\\.dtd\\'" . sgml-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
730 731 732 733
         ("\\.ebk\\'" . nxml-mode)
         ("\\.el\\'"  . emacs-lisp-mode)
         ("\\.emacs\\'" . emacs-lisp-mode)
         ("\\.es$" . c++-mode)
734
         ("\\.feature\\'"  . feature-mode)
735
         ("\\.htm\\'" . html-mode)
736
         ("\\.html\\'" . web-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
737
         ("\\.idl\\'" . c++-mode)
738
         ("\\.ini\\'" . conf-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
739
         ("\\.java$" . java-mode)
740
         ("\\.jbk\\'" . nxml-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
741
         ("\\.js$" . js2-mode)
742
         ("\\.json$" . json-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
743 744
         ("\\.jsp$" . nxml-mode) ;; nxml-mode
         ("\\.jspf$" . nxml-mode) ;; nxml-mode
745
         ("\\.less\\'" . javascript-mode)
746
         ("\\.magik$" . python-mode)
747
         ("\\.md$" . markdown-mode)
748 749
         ("\\.odl\\'" . c++-mode)
         ("\\.org\\'" . org-mode)
750
         ("\\.patch\\'" . diff-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
751
         ("\\.pdf\\'" . doc-view-mode)
752 753
         ("\\.php\\'" . php-mode)
         ("\\.phtml\\'" . php-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
754
         ("\\.pl\\'" . perl-mode)
755
         ("\\.pp\\'" . ruby-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
756
         ("\\.properties.template\\'" . conf-mode)
757
         ("\\.properties\\'" . conf-mode)
758
         ("\\.puppet\\'" . puppet-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
759
         ("\\.py$" . python-mode)
760
         ("\\.py\\'" . python-mode)
761
         ("\\.sed\\'" . sh-mode)
762
         ("\\.service\\'" . ini-mode)
763
         ("\\.sh\\'" . sh-mode)
764
         ("\\.shtml\\'" . nxml-mode)
765
         ("\\.sl\\'" . json-mode)
766 767
         ("\\.sql\\'" . sql-mode)
         ("\\.targets$" . nxml-mode)
768
         ("\\.tex\\'" . latex-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
769 770
         ("\\.text\\'" . text-mode)
         ("\\.tld.*\\'" . nxml-mode)
771
         ("\\.toml\\'" . conf-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
772
         ("\\.txt\\'" . text-mode)
773
         ("\\.vcl\\'" . java-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
774 775 776 777 778 779
         ("\\.vm\\'" . emacs-lisp-mode)
         ("\\.wfcfg\\'" . perl-mode)
         ("\\.wsdd\\'" . nxml-mode)
         ("\\.xml$" . nxml-mode) ;; psgml-mode, nxml-mode
         ("\\.xsd$" . nxml-mode) ;; xsl-mode
         ("\\.xsl$" . nxml-mode) ;; xsl-mode
780
         ("\\.yaml\\'" . yaml-mode)
781
         ("\\.yml\\'" . yaml-mode)
782
         ("\\Makefile$" . makefile-mode)
783
         ("\\config\\'" . conf-mode)
784 785
         ("\\makefile$" . makefile-mode)
         ("config" . conf-mode)
786
         ("control" . conf-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
787
         ("github.*\\.txt$" . markdown-mode)
788
         ("pom.xml" . nxml-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
789
         ("tkj-p4-diff-buffer" . diff-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
790 791 792
         )))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
793
;; Hippe expansion
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
794
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
795
(autoload 'hippie-exp "hippie-exp" t)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
796

797
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
798
;; Markdown
799
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
800
(use-package emojify)
801
(add-hook 'markdown-mode-hook 'flyspell-mode)
802
(add-hook 'markdown-mode-hook 'emojify-mode)
803

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
804 805 806
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Yasnippets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
807 808 809 810 811
(use-package yasnippet
  :init
  (setq yas/root-directory '("~/.emacs.d/snippets"))

  :config
812 813 814 815
  (autoload 'yas/expand "yasnippet" t)
  (autoload 'yas/load-directory "yasnippet" t)
  (mapc 'yas/load-directory yas/root-directory)
  (yas-global-mode 1))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
816

817 818 819 820
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AWK
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'awk-mode-hook
821 822 823 824
          (lambda ()
            (setq indent-tabs-mode nil)
            (setq tab-width 2)
            (setq c-basic-offset 2)))
825

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
826 827 828
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Java
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
829 830 831 832
(defun tkj-insert-serial-version-uuid()
  (interactive)
  (insert "private static final long serialVersionUID = 1L;"))

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
833 834 835 836 837
(defun tkj-default-code-style-hook()
  (setq c-basic-offset 2
        c-label-offset 0
        tab-width 2
        indent-tabs-mode nil
838
        compile-command "mvn -q -o -f ~/src/content-engine/engine/engine-core/pom.xml test -DtrimStackTrace=false"
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
839 840 841
        require-final-newline nil))
(add-hook 'java-mode-hook 'tkj-default-code-style-hook)

842 843 844
(use-package flycheck
  :init
  (add-to-list 'display-buffer-alist
845 846 847 848 849 850
               `(,(rx bos "*Flycheck errors*" eos)
                 (display-buffer-reuse-window
                  display-buffer-in-side-window)
                 (side            . bottom)
                 (reusable-frames . visible)
                 (window-height   . 0.15))))
851

852
(use-package idle-highlight)
853

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
854 855
(defun my-java-mode-hook ()
  (auto-fill-mode)
856 857
  (flycheck-mode)
  (git-gutter+-mode)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
858
  (gtags-mode)
859
  (idle-highlight)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
860 861
  (subword-mode)
  (yas-minor-mode)
862
  (set-fringe-style '(8 . 0))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
863 864 865 866 867 868 869 870 871 872 873 874 875
  (define-key c-mode-base-map (kbd "C-M-j") 'tkj-insert-serial-version-uuid)
  (define-key c-mode-base-map (kbd "C-m") 'c-context-line-break)
  (define-key c-mode-base-map (kbd "S-<f7>") 'gtags-find-tag-from-here)

  ;; Fix indentation for anonymous classes
  (c-set-offset 'substatement-open 0)
  (if (assoc 'inexpr-class c-offsets-alist)
      (c-set-offset 'inexpr-class 0))

  ;; Indent arguments on the next line as indented body.
  (c-set-offset 'arglist-intro '++))
(add-hook 'java-mode-hook 'my-java-mode-hook)

876 877 878 879 880
(use-package projectile :ensure t)
(use-package yasnippet :ensure t)
(use-package lsp-mode :ensure t
  :bind (("\C-\M-b" . lsp-find-implementation)
         ("M-RET" . lsp-execute-code-action))
881 882 883
  :config
  (setq lsp-inhibit-message t
        lsp-eldoc-render-all nil
884
        lsp-enable-file-watchers nil
885 886 887 888 889 890 891 892
        lsp-highlight-symbol-at-point nil)

  ;; Performance tweaks, see
  ;; https://github.com/emacs-lsp/lsp-mode#performance
  (setq gc-cons-threshold 100000000)
  (setq read-process-output-max (* 1024 1024)) ;; 1mb
  (setq lsp-idle-delay 0.500)
  )
893

894 895
(use-package hydra :ensure t)
(use-package company-lsp :ensure t)
896 897 898
(use-package lsp-ui
  :ensure t
  :config
899 900 901 902
  (setq lsp-prefer-flymake nil
        lsp-ui-doc-delay 5.0
        lsp-ui-sideline-enable nil
        lsp-ui-sideline-show-symbol nil))
903

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
904
(use-package lsp-java
905
  :ensure t
906
  :init
907
  (setq lsp-java-vmargs
908 909
        (list
         "-noverify"
910
         "-Xmx2G"
911 912
         "-XX:+UseG1GC"
         "-XX:+UseStringDeduplication"
913
         "-javaagent:/home/torstein/.m2/repository/org/projectlombok/lombok/1.18.4/lombok-1.18.4.jar"
914
         )
915

916 917
        ;; Don't organise imports on save
        lsp-java-save-action-organize-imports nil
918 919 920

        ;; Currently (2019-04-24), dap-mode works best with Oracle
        ;; JDK, see https://github.com/emacs-lsp/dap-mode/issues/31
921 922
        ;;
        ;; lsp-java-java-path "~/.emacs.d/oracle-jdk-12.0.1/bin/java"
923
        lsp-java-java-path "/usr/lib/jvm/java-11-openjdk-amd64/bin/java"
924
        )
925 926

  :config
927
  (add-hook 'java-mode-hook #'lsp))
928

929 930 931 932 933
(use-package dap-mode
  :ensure t
  :after lsp-mode
  :config
  (dap-mode t)
934
  (dap-ui-mode t)
935 936
  (dap-tooltip-mode 1)
  (tooltip-mode 1)
937 938 939 940 941
  (dap-register-debug-template
   "localhost:5005"
   (list :type "java"
         :request "attach"
         :hostName "localhost"
942 943
         :port 5005))
  (dap-register-debug-template
944
   "10.186.38.171:5005"
945 946
   (list :type "java"
         :request "attach"
947
         :hostName "10.186.38.171"
948 949
         :port 5005))
  )
950 951 952 953

(use-package dap-java
  :ensure nil
  :after (lsp-java)
954 955 956 957 958 959 960 961

  ;; The :bind here makes use-package fail to lead the dap-java block!
  ;; :bind
  ;; (("C-c R" . dap-java-run-test-class)
  ;;  ("C-c d" . dap-java-debug-test-method)
  ;;  ("C-c r" . dap-java-run-test-method)
  ;;  )

962 963 964 965 966
  :config
  (global-set-key (kbd "<f7>") 'dap-step-in)
  (global-set-key (kbd "<f8>") 'dap-next)
  (global-set-key (kbd "<f9>") 'dap-continue)
  )
967

968 969 970 971 972
(use-package treemacs
  :init
  (add-hook 'treemacs-mode-hook
            (lambda () (treemacs-resize-icons 15))))

973 974 975 976 977 978 979 980
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Clipboard. Copy from terminal emacs to the X clipboard.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package xclip
  :ensure t
  :config
  (xclip-mode 1))

981 982 983
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Compilation mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
984
;; Convert shell escapes to  color
985
(add-hook 'compilation-filter-hook
986
          (lambda () (ansi-color-apply-on-region (point-min) (point-max))))
987

988 989 990 991 992
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SQL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'sql-interactive-mode-hook
          '(lambda ()
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
993
             (company-mode)))
994

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
995
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
996
;; Web browser
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
997
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
998
(setq browse-url-generic-program "/home/torstein/bin/firefox"
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
999 1000
      browse-url-browser-function 'browse-url-generic)

1001 1002 1003 1004 1005
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs behaviour
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq warning-suppress-types (quote ((undo discard-info))))

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; For some reason, being on different networks (as experienced in
;; Dhaka), the p4 integration made all file operation extremely slow,
;; hence the explicity loading here).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun tkj-load-p4()
  (interactive)
  (load "$HOME/.emacs.d/tkj-p4.el")
  (p4-opened))

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1016 1017 1018
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; VC related settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1019 1020 1021 1022 1023 1024 1025 1026 1027
(use-package vc
  :ensure nil
  :config
  (setq
   ;; Ignore white space when running annotate to see who
   ;; introduced actual code changes.
   vc-git-annotate-switches '("-w")
   ;; Follow symlinks when opening files.
   vc-follow-symlinks t))
1028

1029 1030 1031 1032 1033
(use-package git-gutter+
  :config
  ;; Move between local changes
  (global-set-key (kbd "M-<up>") 'git-gutter+-previous-hunk)
  (global-set-key (kbd "M-<down>") 'git-gutter+-next-hunk))
1034 1035

;; Customise the magit log view
1036 1037 1038 1039 1040
(use-package magit
  :config
  (setq magit-log-arguments '("-n256" "--graph" "--decorate" "--color")
        ;; Show diffs per word, looks nicer!
        magit-diff-refine-hunk t
1041

1042
        ;; Easy switching between all repositories I'm working on
1043
        magit-repository-directories
1044
        '(
1045 1046
          ("~/src/build")
          ("~/src/build-tools")
1047 1048 1049 1050 1051 1052
          ("~/src/content-engine")
          ("~/src/ece-scripts")
          ("~/src/skybert-net")
          ("~/src/sse-proxy")
          ("~/src/user-manager")
          )))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1053

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1054 1055 1056
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; XML
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1057
(load "$HOME/.emacs.d/tkj-xml.el")
1058
(load "$HOME/.emacs.d/tkj-web.el")
1059

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1060 1061 1062
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Javascript mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
(setq js2-basic-offset 2
      js2-indent-on-enter-key t
      js2-enter-indents-newline t
      js-indent-level 2
      )

(use-package tern
  :init
  (setq tern-explicit-port 35129

        ;; npm install tern
        tern-command '("~/node_modules/.bin/tern"))


  :config
  (use-package company-tern
    :ensure t
    :config
    (add-to-list 'company-backends 'company-tern)))

(use-package js2-mode
  :init
  (add-hook 'js2-mode-hook 'tern-mode)

  (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  )
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Unfill
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun unfill-paragraph ()
  (interactive)
  (let ((fill-column (point-max)))
    (fill-paragraph nil)))

(defun unfill-region ()
  (interactive)
  (let ((fill-column (point-max)))
    (fill-region (region-beginning) (region-end) nil)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Auto insert file templates
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1106
;; (load "~/.emacs.d/tkj-auto-insert.el")
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1107 1108 1109 1110 1111 1112 1113 1114 1115

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tidy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun tidy-buffer ()
  "Run Tidy HTML parser on current buffer."
  (interactive)
  (if (get-buffer "tidy-errs") (kill-buffer "tidy-errs"))
  (shell-command-on-region (point-min) (point-max)
1116
                           "tidy -f /tmp/tidy-errs -q -wrap 72" t)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1117 1118 1119 1120 1121 1122 1123 1124 1125
  (find-file-other-window "/tmp/tidy-errs")
  (other-window 1)
  (delete-file "/tmp/tidy-errs")
  (message "buffer tidy-ed"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Diff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq ediff-window-setup-function 'ediff-setup-windows-plain
1126
      ediff-split-window-function 'split-window-horizontally ;; !work
1127 1128
      ediff-diff-options "-w"
      smerge-command-prefix "\C-cv")
1129 1130
;; Restore window/buffers when you're finishd ediff-ing.
(add-hook 'ediff-after-quit-hook-internal 'winner-undo)
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1131 1132 1133 1134

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1135 1136 1137
(use-package org-compat :ensure nil)
(use-package org-list :ensure nil)
(use-package org-element :ensure nil)
1138 1139 1140
(use-package org-bullets
  :config
  (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
1141

1142 1143
(use-package org
  :init
1144 1145 1146 1147
  (setq remember-annotation-functions '(org-remember-annotation))
  (setq remember-handler-functions '(org-remember-handler))
  (add-hook 'remember-mode-hook 'org-remember-apply-template)

1148 1149
  (setq org-clock-persist 'history
        org-return-follows-link t
1150
        org-hide-emphasis-markers t
1151 1152 1153
        org-reveal-theme "blood" ;; serif
        org-reveal-root "http://skybert.net/reveal.js"
        org-todo-keywords '((sequence "TODO(t)" "STARTED(s)" "WAITING(w)" "PR(p)" "|" "MERGED(m)" "DONE(d)" "CANCELLED(c)" "DELEGATED(g)"))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1154
        org-agenda-files (list (concat "~/doc/scribbles/" (format-time-string "%Y")))
1155 1156
        org-blank-before-new-entry '((heading . always) (plain-list-item . auto))
        org-capture-templates
1157
        (quote (("t" "todo" entry (file "~/doc/scribbles/2020/work.org")
1158
                 "** TODO %?\n  SCHEDULED: %T\n%a\n")
1159 1160
                ("r" "review" entry (file "~/doc/scribbles/2020/work.org")
                 "** TODO Review %? :noreport:\n  SCHEDULED: %T\n%a\n")
1161
                ("u" "user" entry (file "~/doc/scribbles/2020/user.org")
1162
                 "** TODO %? \n  SCHEDULED: %T\n%a\n")
1163
                ("e" "ece" entry (file "~/doc/scribbles/2020/ece.org")
1164
                 "** TODO %? \n  SCHEDULED: %T\n%a\n")
1165
                ("c" "cloud" entry (file "~/doc/scribbles/2020/cloud.org")
1166
                 "** TODO %? \n  SCHEDULED: %T\n%a\n")
1167
                ("a" "adm" entry (file "~/doc/scribbles/2020/adm.org")
1168
                 "** TODO %? \n  SCHEDULED: %T\n%a\n")
1169
                ("b" "build" entry (file "~/doc/scribbles/2020/build.org")
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1170
                 "** TODO %? \n  SCHEDULED: %T\n%a\n")
1171
                ("z" "zipline" entry (file "~/doc/scribbles/2020/zipline.org")
1172 1173 1174 1175
                 "** TODO %?\n  SCHEDULED: %T\n%a\n")
                ("i" "idea" entry (file "~/doc/ideas.org")
                 "** TODO %?\n  SCHEDULED: %T\n%a\n")))
        )
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198

  ;; list style
  (font-lock-add-keywords 'org-mode
                          '(("^ *\\([-]\\) "
                             (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))

  ;; Different heading, different size, taken from
  ;; https://zzamboni.org/post/beautifying-org-mode-in-emacs/
  (let* ((variable-tuple
          (cond ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro"))
                ((x-list-fonts "Lucida Grande")   '(:font "Lucida Grande"))
                ((x-list-fonts "Verdana")         '(:font "Verdana"))
                ((x-family-fonts "Sans Serif")    '(:family "Sans Serif"))
                (nil (warn "Cannot find a Sans Serif Font.  Install Source Sans Pro."))))
         (base-font-color     (face-foreground 'default nil 'default))
         (headline           `(:inherit default :weight bold :foreground ,base-font-color)))

    (custom-theme-set-faces
     'user
     `(org-level-8 ((t (,@headline ,@variable-tuple))))
     `(org-level-7 ((t (,@headline ,@variable-tuple))))
     `(org-level-6 ((t (,@headline ,@variable-tuple))))
     `(org-level-5 ((t (,@headline ,@variable-tuple))))
1199 1200 1201 1202
     `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.0))))
     `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.1))))
     `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.25))))
     `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.5))))
1203 1204
     `(org-document-title ((t (,@headline ,@variable-tuple :height 2.0 :underline nil))))))

1205
  (org-clock-persistence-insinuate)
1206 1207 1208 1209

  :bind
  (("\C-ca" . org-agenda)
   ("\C-ct" . org-capture))
1210
  )
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1211

1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
;; Using org-present for presenting .org slides
(eval-after-load "org-present"
  '(progn
     (add-hook 'org-present-mode-hook
               (lambda ()
                 (org-present-big)
                 (org-display-inline-images)
                 (org-present-hide-cursor)
                 (org-present-read-only)))
     (add-hook 'org-present-mode-quit-hook
               (lambda ()
                 (org-present-small)
                 (org-remove-inline-images)
                 (org-present-show-cursor)
                 (org-present-read-write)))))
1227 1228 1229 1230 1231
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; date & time
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/tkj-time.el")

Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1232
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1233
;; Various packages & settings to get smart file name completion
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1234
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1235
(use-package projectile
1236
  :bind
1237
  (("C-c p f" . projectile-find-file))
1238 1239 1240 1241 1242 1243 1244
  :init
  (setq projectile-enable-caching t
        projectile-globally-ignored-file-suffixes
        '(
          "blob"
          "class"
          "classpath"
1245
          "gz"
1246 1247
          "iml"
          "ipr"
1248
          "jar"
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
          "pyc"
          "tkj"
          "war"
          "xd"
          "zip"
          )
        projectile-globally-ignored-files '("TAGS" "*~")
        projectile-tags-command "/usr/bin/ctags -Re -f \"%s\" %s"
        projectile-mode-line '(:eval (format " [%s]" (projectile-project-name)))
        )
  :config
  (projectile-global-mode)

  (setq projectile-globally-ignored-directories
        (append (list
1264 1265
                 ".pytest_cache"
                 "__pycache__"
1266
                 "build"
1267 1268 1269 1270 1271 1272 1273 1274 1275
                 "elpa"
                 "node_modules"
                 "output"
                 "reveal.js"
                 "semanticdb"
                 "target"
                 "venv"
                 )
                projectile-globally-ignored-directories))
1276 1277
  )

1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293
;; Show search hits of strings in current buffer
;; http://oremacs.com/2015/01/26/occur-dwim/
(defun occur-dwim ()
  "Call `occur' with a sane default."
  (interactive)
  (push (if (region-active-p)
            (buffer-substring-no-properties
             (region-beginning)
             (region-end))
          (let ((sym (thing-at-point 'symbol)))
            (when (stringp sym)
              (regexp-quote sym))))
        regexp-history)
  (call-interactively 'occur))
(global-set-key (kbd "M-s o") 'occur-dwim)

1294 1295 1296 1297 1298 1299 1300
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; imenu
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package imenu-list
  :ensure t
  :config
  (setq imenu-list-focus-after-activation t))
Torstein Krause Johansen's avatar
Torstein Krause Johansen committed
1301 1302 1303 1304

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Chat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1305 1306 1307
(use-package erc-colorize)
(use-package erc-image)
(use-package erc-tweet)
1308 1309 1310 1311 1312
(use-package erc
  :init
  (require 'erc-log)
  (require 'erc-autoaway)
  (require 'erc-replace)
1313

1314 1315
  (setq erc-default-server "irc.freenode.net"
        erc-default-nicks '("skybert")
1316 1317 1318 1319
        erc-log-channels-directory "~/.erc/logs"
        erc-log-write-after-send t
        erc-log-write-after-insert t
        erc-autoaway-idle-seconds 600
1320 1321

        ;; logging and timestamps on the left
1322 1323
        erc-enable-logging t
        erc-save-buffer-on-part t
1324
        erc-timestamp-only-if-changed-flag nil
1325
        erc-timestamp-format "%Y-%m-%d %H:%M "
1326 1327 1328
        erc-fill-prefix "      "
        erc-insert-timestamp-function 'erc-insert-timestamp-left

1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
        erc-track-exclude-types '("JOIN" "PART" "QUIT" "NICK" "MODE")
        erc-hide-list '("JOIN" "PART" "QUIT" "MODE")
        erc-replace-alist
        '(
          (":+1:" . "👍")
          (":laughing:" . "😂")
          (":slightly_smiling_face:" . "😃")
          (":smiley:" . "😃")
          (":wink:" . "😉")
          ))
  )
1340 1341 1342
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Python
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1343 1344
(use-package python
  :config
1345
  (setq python-indent 4)
1346 1347 1348 1349 1350 1351 1352 1353
  )

(add-hook 'python-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'yas-minor-mode)
(add-hook 'python-mode-hook 'eldoc-mode)

(use-package elpy
  :config
1354