-
Notifications
You must be signed in to change notification settings - Fork 10
/
init.el
1424 lines (1235 loc) · 49 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
113
114
115
116
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
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
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; -*- lexical-binding: t -*-
(defvar package-archives)
(defvar package-archive-contents)
(defvar my:disabled-packages nil)
(defvar my:backup-directory
(expand-file-name (concat user-emacs-directory "backups/"))
"Directory storing all backups and auto-save files.
Must end with a trailing slash.")
;;; Bootstrap
(setq package-archives '(("sunrise" . "http://joseito.republika.pl/sunrise-commander/")
("elpa" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(load "~/.emacs.d/pre-startup.el" 'noerror)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
;;; User package
(require 'use-package)
(defmacro user-package (name &rest args)
"Wrapper over `use-package'.
Disables all packages that are member of the
`my:disabled-packages' list by injecting membership into
`use-package' :if keyword ."
(declare (indent 1))
(when (not (memq name my:disabled-packages))
`(use-package ,name ,@args)))
(defconst user-package-font-lock-keywords
'(("(\\(user-package\\)\\_>[ \t']*\\(\\sw+\\)?"
(1 font-lock-keyword-face)
(2 font-lock-constant-face nil t))))
(font-lock-add-keywords 'emacs-lisp-mode user-package-font-lock-keywords)
;;; Environment
(let ((bindir (expand-file-name "~/bin")))
(setenv "PATH" (concat bindir ":" (getenv "PATH")))
(add-to-list 'exec-path bindir))
;;; Install python.el development version
(add-to-list 'load-path user-emacs-directory)
(defun my:ensure-python.el (&optional branch overwrite)
"Install python.el from BRANCH.
After the first install happens the file is not overwritten again
unless the optional argument OVERWRITE is non-nil. When called
interactively python.el will always be overwritten with the
latest version."
(interactive
(list
(completing-read "Install python.el from branch: "
(list "master" "emacs-24")
nil t)
t))
(let* ((branch (or branch "master"))
(url (format
(concat "http://git.savannah.gnu.org/cgit/emacs.git/plain"
"/lisp/progmodes/python.el?h=%s") branch))
(destination (expand-file-name "python.el" user-emacs-directory))
(write (or (not (file-exists-p destination)) overwrite)))
(when write
(with-current-buffer
(url-retrieve-synchronously url)
(delete-region (point-min) (1+ url-http-end-of-headers))
(write-file destination))
(byte-compile-file destination t)
destination)))
(my:ensure-python.el)
;;; Packages and config
(user-package ace-jump-mode
:if (not noninteractive)
:bind (("C-c SPC" . ace-jump-mode)
("C-c C-SPC" . ace-jump-mode-pop-mark))
:ensure ace-jump-mode
:config
(progn
(setq ace-jump-mode-case-fold t)
(ace-jump-mode-enable-mark-sync)
(setq ace-jump-mode-submode-list
'(ace-jump-word-mode ace-jump-char-mode ace-jump-line-mode))))
(user-package ag
:if (not noninteractive)
:ensure ag)
(user-package alert
:ensure alert
:config (setq alert-default-style 'libnotify))
(user-package auto-complete
:if (not noninteractive)
:ensure auto-complete
:diminish auto-complete-mode
:config (progn
(require 'auto-complete-config)
(ac-config-default)
(setq-default ac-sources '(ac-source-yasnippet
ac-source-filename
ac-source-abbrev
ac-source-dictionary
ac-source-words-in-same-mode-buffers))
(global-auto-complete-mode 1)))
(user-package backup-walker
:ensure backup-walker)
(user-package browse-url
:config (setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "firefox"))
(user-package clojure-mode
:if (not noninteractive)
:ensure clojure-mode
:config
(progn
(user-package cider
:ensure cider
:diminish cider-mode)
(user-package ac-nrepl
:ensure ac-nrepl)
(user-package align-cljlet
:ensure align-cljlet)
(user-package clojure-cheatsheet
:ensure clojure-cheatsheet)
(user-package clj-refactor
:ensure clj-refactor)
(user-package slamhound
:ensure slamhound)
(setq
cider-lein-command (executable-find "lein")
cider-popup-stacktraces t
cider-repl-mode-hook #'subword-mode
nrepl-hide-special-buffers t)
(add-to-list 'same-window-buffer-names "*nrepl*")
(add-hook 'clojure-mode-hook #'cider-mode)
(add-hook 'clojure-mode-hook #'(lambda ()
(cljr-add-keybindings-with-prefix "C-c")
(clj-refactor-mode 1)))
(add-hook 'cider-mode-hook #'cider-turn-on-eldoc-mode)
(add-hook 'cider-repl-mode-hook #'ac-nrepl-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes #'cider-mode))))
(user-package css-mode
:if (not noninteractive)
:ensure css-mode
:config (setq css-indent-offset 2))
(user-package cus-theme
:config
(progn
(user-package helm-themes
:ensure helm-themes)
(defun my:load-random-theme (&optional msg)
"Load a random theme."
(interactive "p")
(let ((success))
(while (not success)
(let* ((themes (custom-available-themes))
(random-theme
(progn
(random t)
(nth (random (length themes)) themes))))
(condition-case err
(progn
(helm-themes--load-theme (symbol-name random-theme))
(setq success t))
(error
(message "Failed to load %s. Retrying..." random-theme)))
(when (and success msg)
(message "Loaded theme %s" random-theme))))))
(user-package ample-theme
:ensure ample-theme
:defer t)
(user-package color-theme-sanityinc-solarized
:ensure color-theme-sanityinc-solarized
:defer t)
(user-package color-theme-sanityinc-tomorrow
:ensure color-theme-sanityinc-tomorrow
:defer t)
(user-package cyberpunk-theme
:ensure cyberpunk-theme
:defer t)
(user-package leuven-theme
:ensure leuven-theme
:defer t)
(user-package monokai-theme
:ensure monokai-theme
:defer t)
(user-package zenburn-theme
:ensure zenburn-theme
:defer t)))
(user-package deft
:if (not noninteractive)
:ensure deft
:config (progn
(setq
deft-extension "org"
deft-directory "~/Org/deft/"
deft-text-mode 'org-mode)))
(user-package dired-details
:if (not noninteractive)
:ensure dired-details
:config (progn
(dired-details-install)))
(user-package eldoc
:config
(progn
(add-hook 'prog-mode-hook #'turn-on-eldoc-mode)))
(user-package emerge
:config (setq emerge-diff-ok-lines-regexp
(concat "^\\(" "[0-9,]+[acd][0-9,]+\C-m?$" "\\|[<>] "
"\\|---" "\\|.*Warning *:" "\\|.*No +newline"
"\\|.*missing +newline" "\\|^\C-m?$" "\\)")
emerge-diff3-ok-lines-regexp
(concat "^\\([1-3]:\\|====\\| \\|.*Warning *:\\|"
".*No newline\\|.*missing newline\\|^\C-m$\\)")))
(user-package emms
:if (not noninteractive)
:ensure emms
:bind ("C-x C-m" . my:emms)
:defer t
:config
(progn
(user-package emms-info-mediainfo
:ensure emms-info-mediainfo)
(emms-devel)
(emms-default-players)
(defun my:emms ()
"Same as `emms' but allow creating an empty playlist."
(interactive)
(and (or (null emms-playlist-buffer)
(not (buffer-live-p emms-playlist-buffer)))
(setq emms-playlist-buffer (emms-playlist-new)))
(emms-playlist-mode-go))
;; add what i mean
(defun my:emms-awim (filename &optional arg)
"Adds the FILENAME specified, whatever it is.
It will expand wildcards. With ARG clear the playlist before
adding files."
(interactive
(let* ((fname (car (find-file-read-args "Add what? " nil)))
(dirpart (file-name-directory fname))
(fnames
(or
(and dirpart (string-match "[*]$" fname)
(file-expand-wildcards fname))
(and (file-exists-p fname) (list fname)))))
(list fnames
current-prefix-arg)))
(when arg
(emms-stop)
(emms-playlist-clear))
(dolist (fname filename)
(cond
((file-directory-p fname)
(emms-add-directory-tree fname))
((file-exists-p fname)
(emms-add-file fname))))
(when arg
(goto-char (point-min))
(emms-playlist-mode-play-current-track)))
;; Stolen and adapted from TWB
(defun my:emms-info-track-description (track)
"Return a description of the current track."
(if (not (eq (emms-track-type track) 'file))
(emms-track-simple-description track)
(let* ((ptot (emms-track-get track 'info-playing-time))
(pmin (or
(emms-track-get track 'info-playing-time-min)
(and ptot (/ ptot 60)) 0))
(psec (or
(emms-track-get track 'info-playing-time-sec)
(and ptot (% ptot 60)) 0))
(tracknumber (string-to-number
(or (emms-track-get track 'info-tracknumber) "0")))
(artist (or (emms-track-get track 'info-artist) "unknown"))
(title (or (emms-track-get track 'info-title)
(file-name-nondirectory (emms-track-get track 'name)))))
(format "%02d. %s - %s [%02d:%02d]" tracknumber artist title pmin psec))))
(setq
emms-info-asynchronously t
emms-info-functions '(emms-info-mediainfo)
emms-mode-line-format " %s "
emms-player-mplayer-parameters '("-slave" "-quiet" "-really-quiet" "-af" "scaletempo")
emms-repeat-playlist t
emms-show-format "NP: %s"
emms-track-description-function 'my:emms-info-track-description
later-do-interval 0.0001)
(emms-mode-line-disable)
(emms-playing-time-enable-display)
(bind-key "A" 'my:emms-awim emms-playlist-mode-map)
(bind-key "S" 'emms-streams emms-playlist-mode-map)
(bind-key "h" 'describe-mode emms-playlist-mode-map)
(bind-key "H" 'describe-mode emms-playlist-mode-map)
(bind-key "?" 'emms-shuffle emms-playlist-mode-map)
(bind-key "g" 'emms-cache-sync emms-playlist-mode-map)
(bind-key "SPC" 'emms-pause emms-playlist-mode-map)
(bind-key "q" 'emms emms-stream-mode-map)
(bind-key "Q" 'emms emms-stream-mode-map)))
(user-package expand-region
:if (not noninteractive)
:bind (("C-M-SPC" . er/expand-region)
("C-M-@" . er/expand-region))
:ensure expand-region)
(user-package files
:config
(progn
(setq auto-save-file-name-transforms `((".*" ,my:backup-directory t))
auto-save-list-file-prefix my:backup-directory
backup-directory-alist `(("." . ,my:backup-directory))
auto-save-default t
auto-save-interval 200
auto-save-timeout 20
backup-by-copying t
delete-by-moving-to-trash t
delete-old-versions t
kept-new-versions 20
kept-old-versions 0
make-backup-files t
version-control t)
(defun force-backup-of-buffer ()
"Reset `buffer-backed-up' to nil."
(setq buffer-backed-up nil))
;; Always create backups on save:
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(add-hook 'before-save-hook #'force-backup-of-buffer)))
(user-package god-mode
:if (not noninteractive)
:ensure god-mode
:config
(progn
(defun my:god-toggle-on-overwrite ()
"Toggle god-mode on overwrite-mode."
(if (bound-and-true-p overwrite-mode)
(god-local-mode-pause)
(god-local-mode-resume)))
(defun god-gnus-mode-p ()
"Return non-nil if major-mode is a gnus mode."
(string-match-p "^gnus-.*-mode$" (symbol-name major-mode)))
(defun vc-mode-p ()
"Return non-nil if major-mode is a vc mode."
(string-match-p "^vc-.*-mode$" (symbol-name major-mode)))
(defun my:god-update-cursor-enabled ()
(setq cursor-type 'hollow))
(defun my:god-update-cursor-disabled ()
(setq cursor-type 'box))
(defun my:god-update-cursor ()
(if (and god-global-mode god-local-mode)
(my:god-update-cursor-enabled)
(my:god-update-cursor-disabled)))
(mapc (lambda (mode)
(add-to-list 'god-exempt-major-modes mode))
'(git-commit-mode log-edit-mode rcirc-mode))
(mapc (lambda (mode)
(add-to-list 'god-exempt-predicates mode))
'(god-gnus-mode-p vc-mode-p))
(add-hook 'god-mode-enabled-hook #'my:god-update-cursor-enabled)
(add-hook 'god-mode-disabled-hook #'my:god-update-cursor-disabled)
(add-hook 'overwrite-mode-hook #'my:god-toggle-on-overwrite)
(defadvice select-window (after my:god-update activate)
"Trigger cursor changes for god mode after selecting a window."
(my:god-update-cursor))
(bind-key "<escape>" 'god-mode-all)
(bind-key "i" 'god-local-mode god-local-mode-map)))
(user-package helm
:if (not noninteractive)
:ensure helm
:config
(progn
(bind-key "<RET>" #'helm-maybe-exit-minibuffer helm-map)
(bind-key "C-i" #'helm-execute-persistent-action helm-map)
(bind-key "C-j" #'helm-maybe-exit-minibuffer helm-map)
(bind-key "C-x b" #'helm-mini)
(bind-key "C-x C-f" #'helm-find-files)
(bind-key "C-z" #'helm-select-action helm-map)
(bind-key "M-y" #'helm-show-kill-ring)
(setq helm-buffers-fuzzy-matching t
helm-ff-auto-update-initial-value t
helm-ff-file-name-history-use-recentf t
helm-ff-search-library-in-sexp t
helm-ff-skip-boring-files t
helm-move-to-line-cycle-in-source t
helm-scroll-amount 8
helm-split-window-in-side-p t)
(helm-mode 1)
(user-package helm-swoop
:ensure helm-swoop)
(bind-key "C-x M-i" #'helm-multi-swoop)
(bind-key "M-I" #'helm-swoop-back-to-last-point)
(bind-key "M-i" #'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
(bind-key "M-i" #'helm-swoop)
(bind-key "M-i" #'helm-swoop-from-isearch isearch-mode-map)
(setq helm-multi-swoop-edit-save t
helm-swoop-speed-or-color t
helm-swoop-split-direction #'split-window-horizontally
helm-swoop-split-with-multiple-windows nil
helm-swoop-use-line-number-face t)))
(user-package ido
:if (not noninteractive)
:config
(progn
(user-package ido-vertical-mode
:ensure ido-vertical-mode)
(user-package flx
:ensure flx)
(user-package flx-ido
:ensure flx-ido)
(setq ido-enable-flex-matching t
ido-use-faces nil
flx-ido-use-faces t)
(ido-mode 1)
(ido-everywhere 1)
(ido-vertical-mode 1)
(flx-ido-mode 1)))
(user-package flycheck
:ensure flycheck
:config
(progn
;; Add virtualenv support for checkers
(defadvice flycheck-checker-executable
(around python-flycheck-check-executable (checker)
activate compile)
"`flycheck-checker-executable' with virtualenv support."
(if (eq major-mode 'python-mode)
(let* ((process-environment (python-shell-calculate-process-environment))
(exec-path (python-shell-calculate-exec-path)))
ad-do-it)
ad-do-it))
(defadvice flycheck-start-checker
(around python-flycheck-start-checker (checker callback)
activate compile)
"`flycheck-start-checker' with virtualenv support."
(if (eq major-mode 'python-mode)
(let* ((process-environment (python-shell-calculate-process-environment))
(exec-path (python-shell-calculate-exec-path)))
ad-do-it)
ad-do-it))
(setq flycheck-mode-line-lighter " ")
(global-flycheck-mode 1)
(user-package helm-flycheck
:ensure helm-flycheck)
(bind-key "C-c ! !" #'helm-flycheck flycheck-mode-map)))
(user-package gist
:if (not noninteractive)
:ensure gist)
(user-package git-commit-mode
:if (not noninteractive)
:ensure git-commit-mode)
(user-package git-rebase-mode
:if (not noninteractive)
:ensure git-rebase-mode)
(user-package gitconfig-mode
:if (not noninteractive)
:ensure gitconfig-mode)
(user-package gitignore-mode
:if (not noninteractive)
:ensure gitignore-mode)
(user-package hl-line
:if (not noninteractive)
:config (global-hl-line-mode))
(user-package ibuffer
:if (not noninteractive)
:bind ("C-x C-b" . ibuffer)
:config
(progn
(user-package ibuffer-rcirc
:ensure ibuffer-rcirc)
(user-package ibuffer-tramp
:ensure ibuffer-tramp)
(user-package ibuffer-vc
:ensure ibuffer-vc)
(defun ibuffer-combine-filter-groups (&rest filter-groups)
"Return a command that's the combination of all given FILTER-GROUPS."
(lambda ()
(interactive)
(let ((accum)
(ibuffer-update-fn
(symbol-function #'ibuffer-update)))
(fset #'ibuffer-update (symbol-function #'ignore))
(mapc (lambda (filter-fn)
(let (ibuffer-filter-groups)
(funcall filter-fn)
(setq accum (append accum ibuffer-filter-groups nil))))
filter-groups)
(setq ibuffer-filter-groups accum)
(fset #'ibuffer-update ibuffer-update-fn)
(ibuffer-update nil t))))
(defmacro define-ibuffer-combined-filter-groups (name &rest filter-groups)
"Return a command that's the combination of all given FILTER-GROUPS."
`(fset (intern (symbol-name ',name))
(ibuffer-combine-filter-groups
,@filter-groups)))
(defun ibuffer-vc-include-if-file-has-buffer (file)
"Exclude buffers without associated file from vc grouping."
(get-file-buffer file))
(setq ibuffer-vc-include-function #'ibuffer-vc-include-if-file-has-buffer)
(defun ibuffer-set-filter-groups-by-visiting-file-p (&rest filter-groups)
"Group all buffers with file."
(interactive)
(setq ibuffer-filter-groups
'(("Files"
(predicate . buffer-file-name))))
(ibuffer-update nil t))
(define-ibuffer-combined-filter-groups
ibuffer-set-filter-groups-combined
#'ibuffer-rcirc-set-filter-groups-by-server
#'ibuffer-vc-set-filter-groups-by-vc-root
#'ibuffer-tramp-set-filter-groups-by-tramp-connection
#'ibuffer-set-filter-groups-by-visiting-file-p)
(bind-key "s c" #'ibuffer-do-sort-by-vc-status ibuffer-mode-map)
(bind-key "s r" #'ibuffer-do-sort-by-rcirc-activity-status ibuffer-mode-map)
(bind-key "1" #'ibuffer-set-filter-groups-combined ibuffer-mode-map)
(bind-key "2" #'ibuffer-set-filter-groups-by-mode ibuffer-mode-map)
(setq ibuffer-formats
'((mark modified read-only
vc-status-mini rcirc-activity-status-one-char " "
(name 18 18 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" "
filename-and-process)))
(add-hook 'ibuffer-hook
(lambda ()
(ibuffer-set-filter-groups-combined)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))))
(user-package js
:if (not noninteractive)
:config
(progn
(user-package jquery-doc
:ensure jquery-doc)
(add-hook 'js-mode-hook 'jquery-doc-setup)))
(user-package lisp-mode
:if (not noninteractive)
:config
(progn
(bind-key "C-c e b" 'eval-buffer lisp-mode-shared-map)
(bind-key "C-c e c" 'cancel-debug-on-entry lisp-mode-shared-map)
(bind-key "C-c e d" 'debug-on-entry lisp-mode-shared-map)
(bind-key "C-c e e" 'toggle-debug-on-error lisp-mode-shared-map)
(bind-key "C-c e f" 'emacs-lisp-byte-compile-and-load lisp-mode-shared-map)
(bind-key "C-c e l" 'find-library lisp-mode-shared-map)
(bind-key "C-c e r" 'eval-region lisp-mode-shared-map)))
(user-package magit
:if (not noninteractive)
:bind ("C-x g" . magit-status)
:ensure magit
:config
(progn
(defun magit-diff-toggle-whitespace ()
(interactive)
(if (member "-w" magit-diff-options)
(magit-diff-dont-ignore-whitespace)
(magit-diff-ignore-whitespace)))
(defun magit-diff-ignore-whitespace ()
(interactive)
(add-to-list 'magit-diff-options "-w")
(magit-refresh))
(defun magit-diff-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options (remove "-w" magit-diff-options))
(magit-refresh))
(bind-key "W" 'magit-diff-toggle-whitespace magit-status-mode-map)))
(user-package markdown-mode
:if (not noninteractive)
:ensure markdown-mode)
(user-package menu-bar
:bind ("M-k" . kill-this-buffer)
:config (menu-bar-mode -1))
(user-package gnus
:if (not noninteractive)
:bind ("<f2>" . gnus)
:config
(progn
(setq gnus-home-directory "~/.emacs.d/gnus"
gnus-inhibit-startup-message t
gnus-init-file "~/.emacs.d/gnus-init")
(user-package bbdb
:ensure bbdb
:config
(progn
(setq bbdb-complete-name-full-completion t
bbdb-file "~/.emacs.d/gnus/bbdb.db"
bbdb-mail-user-agent 'gnus-user-agent
bbdb-mua-pop-up 'horiz
bbdb-pop-up-layout 'pop-up-multi-line
bbdb-pop-up-window-size 0.5
bbdb-complete-mail-allow-cycling t)
(bbdb-initialize 'gnus)))
(user-package message
:config (setq
message-kill-buffer-on-exit t
message-send-mail-function 'message-send-mail-with-sendmail
message-send-mail-partially-limit nil
message-sendmail-envelope-from 'header))
(user-package sendmail
:config (setq sendmail-program (executable-find "msmtp")))
(user-package gnus-art)
(user-package nnmairix
:config
(progn
(defvar my:nnmairix-call-mairix-binary-folder "~/Maildir/mairix")
(defadvice nnmairix-call-mairix-binary
(around my:nnmairix-call-mairix-binary
(command folder searchquery threads)
activate compile)
"Fix folder path for local imap."
(setq folder (expand-file-name folder my:nnmairix-call-mairix-binary-folder))
ad-do-it)))
(setq gnus-novice-user t
gnus-interactive-exit nil
gnus-large-newsgroup 2000
gnus-permanently-visible-groups ".*INBOX"
gnus-prompt-before-saving t
gnus-thread-hide-subtree t
gnus-thread-sort-functions '(gnus-thread-sort-by-number)
gnus-treat-display-smileys nil
gnus-treat-strip-cr t
mm-attachment-override-types (cons "image/.*"
mm-attachment-override-types)
;; I don't use news servers, speed up a bit.
gnus-read-active-file nil
gnus-save-newsrc-file nil
gnus-read-newsrc-file nil
gnus-check-new-newsgroups nil)
(defvar my:gnus-archive-folder nil
"The archive folder for this group.
Intended to be set via `gnus-parameters'.")
(defvar my:gnus-followup-folder nil
"The follow up folder for this group.
Intended to be set via `gnus-parameters'.")
(defvar my:gnus-hold-folder nil
"The hold folder for this group.
Intended to be set via `gnus-parameters'.")
(defvar my:gnus-trash-folder nil
"The archive trash for this group.
Intended to be set via `gnus-parameters'.")
(defun my:gnus-summary-archive (&optional n)
"Move the current article to the archive folder.
Uses the `my:gnus-archive-folder' value to detect the folder.
Optional argument N works the same as in
`gnus-summary-move-article'."
(interactive "P")
(gnus-summary-move-article n my:gnus-archive-folder))
(defun my:gnus-summary-followup (&optional n)
"Move the current article to the follow up folder.
Uses the `my:gnus-followup-folder' value to detect the folder.
Optional argument N works the same as in
`gnus-summary-move-article'."
(interactive "P")
(gnus-summary-move-article n my:gnus-followup-folder))
(defun my:gnus-summary-hold (&optional n)
"Move the current article to the hold folder.
Uses the `my:gnus-hold-folder' value to detect the folder.
Optional argument N works the same as in
`gnus-summary-move-article'."
(interactive "P")
(gnus-summary-move-article n my:gnus-hold-folder))
(defun my:gnus-summary-trash (&optional n)
"Move the current article to the trash folder.
Uses the `my:gnus-trash-folder' value to detect the folder.
Optional argument N works the same as in
`gnus-summary-move-article'."
(interactive "P")
(gnus-summary-move-article n my:gnus-trash-folder))
(defvar my:gnus-group-sync-programs nil
"List of programs (with switches) executed for syncing email.")
(defvar my:gnus-group-sync-running-processes 0
"Internal counter for executed sync processes.")
(defvar my:gnus-group-sync-buffer-name "*mailsync*"
"Buffer name for sync processes to use for output.")
(defvar my:gnus-group-sync-window nil
"Window used to show the sync progress.")
(defun my:gnus-group-sync-sentinel (process signal)
"Sentinel for sync processes."
(when (memq (process-status process) '(exit signal))
(message "%S: %s."
(mapconcat 'identity (process-command process) " ")
(substring signal 0 -1))
(setq my:gnus-group-sync-running-processes
(1- my:gnus-group-sync-running-processes))
(when (and (zerop my:gnus-group-sync-running-processes)
(window-live-p my:gnus-group-sync-window))
(delete-window my:gnus-group-sync-window)
(when (buffer-live-p (get-buffer gnus-group-buffer))
(gnus-group-get-new-news))
(message "Sync finished."))))
;; Shamelessly stolen from mu4e.
(defun my:gnus-group-sync-make-window (buf height)
"Create a temporary window for BUF with HEIGHT.
The window is set at the bottom of the screen."
(let ((win
(split-window
(frame-root-window)
(- (window-height (frame-root-window)) height))))
(set-window-buffer win buf)
(set-window-dedicated-p win t)
win))
(defun my:gnus-group-sync (&optional nosync)
"Sync all group emails using external programs.
External programs are defined in `my:gnus-group-sync-programs'.
With optional argument NOSYNC, call `gnus-group-get-new-news'
instead and do not execute any external program."
(interactive "P")
(if nosync
(when (buffer-live-p (get-buffer gnus-group-buffer))
(gnus-group-get-new-news))
(gnus-group-get-new-news)
(message "Syncing groups...")
(when (not (zerop my:gnus-group-sync-running-processes))
(user-error "Syncing already in progress..."))
(let ((buf (current-buffer)))
(dolist (command my:gnus-group-sync-programs)
(let* ((_ (split-string-and-unquote command))
(program (car _))
(args (cdr _))
(process (apply #'start-process
program
my:gnus-group-sync-buffer-name
program
args)))
(setq my:gnus-group-sync-running-processes
(1+ my:gnus-group-sync-running-processes))
(set-process-sentinel process #'my:gnus-group-sync-sentinel)))
(when (not (window-live-p my:gnus-group-sync-window))
(setq my:gnus-group-sync-window
(my:gnus-group-sync-make-window my:gnus-group-sync-buffer-name 8))))))
(defun gnus-group-set-keys-hook ()
(local-set-key "g" #'my:gnus-group-sync))
(defun gnus-summary-set-keys-hook ()
(local-set-key (kbd "S-<tab>") 'gnus-summary-prev-unread-article)
(local-set-key (kbd "<tab>") 'gnus-summary-next-unread-article)
(local-set-key "n" 'gnus-summary-next-article)
(local-set-key "p" 'gnus-summary-prev-article)
(local-set-key "!" 'gnus-summary-put-mark-as-ticked-next)
(local-set-key "d" 'gnus-summary-put-mark-as-expirable-next)
(local-set-key "u" 'gnus-summary-clear-mark-forward)
(local-set-key "U" 'gnus-summary-unmark-all-processable)
(local-set-key "c" 'gnus-summary-mail-other-window)
(local-set-key "F" 'gnus-summary-mail-forward)
(local-set-key "r" 'gnus-summary-reply-with-original)
(local-set-key "R" 'gnus-summary-reply-to-list-with-original)
(local-set-key "a" 'my:gnus-summary-archive)
(local-set-key "d" 'my:gnus-summary-trash)
(local-set-key "f" 'my:gnus-summary-followup)
(local-set-key "h" 'my:gnus-summary-hold)
(local-set-key "D" 'gnus-summary-delete-article)
(local-set-key "m" 'gnus-summary-mark-as-processable)
(local-set-key "g" 'gnus-summary-rescan-group)
(local-set-key "?" 'gnus-info-find-node)
(local-set-key "va" 'gnus-summary-save-parts)
(local-set-key "vv" 'gnus-article-view-part)
(local-set-key "$f" 'gnus-summary-sort-by-author)
(local-set-key "$a" 'gnus-summary-sort-by-original)
(local-set-key "$d" 'gnus-summary-sort-by-date)
(local-set-key "$s" 'gnus-summary-sort-by-subject)
(local-set-key "$z" 'gnus-summary-sort-by-chars)
(local-set-key "$e" 'gnus-summary-sort-by-score))
(add-hook 'gnus-group-mode-hook #'gnus-group-set-keys-hook)
(add-hook 'gnus-summary-mode-hook #'gnus-summary-set-keys-hook)))
(user-package multiple-cursors
:bind (("M-m" . mc/mark-more-like-this-extended)
("M-p" . mc/mark-all-in-region)
("M-n" . mc/mark-all-like-this)
("C-S-c C-S-c" . mc/edit-lines)
("C-S-c C-e" . mc/edit-ends-of-lines)
("C-S-c C-a" . mc/edit-beginnings-of-lines))
:defines (multiple-cursors-mode
mc--read-char
multiple-cursors-mode
mc--read-quoted-char)
:ensure multiple-cursors
:config
(progn
(bind-key "f" 'mc/mmlte--right mc/mark-more-like-this-extended-keymap)
(bind-key "b" 'mc/mmlte--left mc/mark-more-like-this-extended-keymap)
(bind-key "n" 'mc/mmlte--down mc/mark-more-like-this-extended-keymap)
(bind-key "p" 'mc/mmlte--up mc/mark-more-like-this-extended-keymap)))
(user-package multi-web-mode
:if (not noninteractive)
:ensure multi-web-mode
:config (progn
(setq mweb-default-major-mode 'html-mode)
(setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
(js-mode "<script +\\(type=\"text/javascript\"\\|language=\"javascript\"\\)[^>]*>" "</script>")
(css-mode "<style +type=\"text/css\"[^>]*>" "</style>")))
(setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
(multi-web-global-mode 1)))
(user-package nginx-mode
:ensure nginx-mode)
(user-package org
:ensure org
:config
(progn
(user-package org-present
:ensure org-present)
(setq org-src-fontify-natively t)
(setq org-export-html-coding-system 'utf-8)))
(user-package page
:bind (("C-M-}" . forward-page)
("C-M-{" . backward-page)))
(user-package paren
:config (show-paren-mode 1))
(user-package php-mode
:if (not noninteractive)
:ensure php-mode)
(user-package powerline
:if (not noninteractive)
:ensure powerline
:config (powerline-default-theme))
(user-package projectile
:if (not noninteractive)
:diminish projectile-mode
:ensure projectile
:config (projectile-global-mode 1))
(user-package python
:config
(progn
(user-package jedi
:ensure jedi)
(setq jedi:complete-on-dot t)
(remove-hook 'python-mode-hook 'wisent-python-default-setup)
(add-hook 'python-mode-hook 'jedi:setup)))
(user-package python-django
:if (not noninteractive)
:bind ("C-x j" . python-django-open-project)
:ensure python-django)
(user-package repeat
:if (not noninteractive)
:bind ("C-z" . repeat))
(user-package rainbow-mode
:if (not noninteractive)
:ensure rainbow-mode
:config (progn
(mapc (lambda (mode)
(add-to-list 'rainbow-r-colors-major-mode-list mode))
'(css-mode emacs-lisp-mode lisp-interaction-mode))
(add-hook 'prog-mode-hook #'rainbow-turn-on)))
(user-package rainbow-delimiters
:if (not noninteractive)
:ensure rainbow-delimiters
:config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
(user-package region-bindings-mode
:if (not noninteractive)
:ensure region-bindings-mode
:config (progn
(bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map)
(bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map)
(bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map)
(bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map)
(bind-key "b" 'mc/skip-to-previous-like-this region-bindings-mode-map)
(bind-key "f" 'mc/skip-to-next-like-this region-bindings-mode-map)
(bind-key "P" 'mc/unmark-previous-like-this region-bindings-mode-map)
(bind-key "N" 'mc/unmark-next-like-this region-bindings-mode-map)
(bind-key "u" 'er/contract-region region-bindings-mode-map)
(setq region-bindings-mode-disabled-modes '(term-mode))
(setq region-bindings-mode-disable-predicates
(list (lambda () buffer-read-only)))
(region-bindings-mode-enable)))
(user-package rcirc
:config
(progn
(user-package rcirc-alertify
:ensure rcirc-alertify)
(rcirc-alertify-enable)
(setq rcirc-log-flag t)
(setq rcirc-time-format "%Y-%m-%d %H:%M ")
(rcirc-track-minor-mode -1)
;; Based on http://www.emacswiki.org/emacs/rcircAll
(defun-rcirc-command all (input)
"Run the arguments as a command for all connections."
(interactive "s")
(mapc (lambda (process)
(with-current-buffer (process-buffer process)
(goto-char (point-max))
(insert "/" input)
(rcirc-send-input)))
(rcirc-process-list)))))
(user-package savehist
:config (progn
(savehist-mode 1)))
(user-package scroll-bar
:config (scroll-bar-mode -1))
(user-package simple
:config