-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
5401 lines (4576 loc) · 199 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
;;; init.el --- FP Emacs initialization file
;;
;; Copyright © 2016 Fabrice Popineau
;;
;; Author: Fabrice Popineau <[email protected]>
;; URL: https://github.com/fpopineau/emacs-init
;; Version: 1.0.0
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; License:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;; * Startup
(require 'edebug)
;; ** Environment
(when (eq system-type 'windows-nt)
;; (setenv "TEMP" "c:/Temp/")
;; (setenv "temp" "c:/Temp/")
;; (setenv "TMP" "c:/Temp/")
;; (setenv "TMPDIR" "c:/Temp/")
(setenv "HOME" "c:/Home/")
(setenv "SHELL" (expand-file-name "cmdproxy.exe" exec-directory))
;; PATH=/MingW64/bin:/c/Local/Miniconda3:/c/Local/Miniconda3/Scripts:/c/Local/Miniconda3/Library/bin:/usr/bin:/c/Local/TeXLive/bin/win32:/c/Local/CCL/current:/c/Local/SBCL/current:/c/Local/SumatraPDF:/c/Local/SwiProlog/bin:/c/Local/BibTeX2HTML:/c/Local/CUDA/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem
(setenv "PATH" (concat
"C:\\Local\\Anaconda3"
";C:\\Local\\Anaconda3\\Scripts"
";C:\\Local\\Anaconda3\\Library\\bin"
";C:\\Local\\MSys64\\MingW64\\bin"
";C:\\Local\\MSys64\\usr\\bin"
";C:\\Local\\TeXLive\\bin\\win32"
";C:\\Local\\Putty"
";C:\\Local\\CCL\\current"
";C:\\Local\\SBCL\\current"
";C:\\Local\\SumatraPDF"
";C:\\Local\\SwiProlog\\bin"
";C:\\Local\\BibTeX2HTML"
";C:\\Local\\CUDA\\bin"
";C:\\Local\\Pandoc"
";C:\\Windows\\System32"
";C:\\Windows"
";C:\\Windows\\System32\\Wbem"
;; ";C:\\Windows\\System32\\WindowsPowerShell\\v1.0"
;; ";C:\\Local\\Emacs\\bin"
;; ";c:\\Source\\Gnu\\Orig\\w3m-0.5.3"
;; ";C:\\Local\\Ruby193\\bin"
;; ";C:\\Local\\Bazaar"
;; ";C:\\Local\\Git\\bin"
;; ";C:\\Local\\StrawBerry\\perl\\bin"
;; ";C:\\Local\\ImageMagick-6.9.2-Q16\\"
;; ";C:\\Local\\GhostScript\\GS9.15\\bin\\"
;; ";C:\\Local\\Subversion\\bin"
;; ";C:\\Local\\OpenSSL-Win64"
;; ";c:\\Local\\OpenBLAS\\0.2.15\\bin"
;; ";c:\\Local\\FreeGLUT\\bin\\x64"
;; ";C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\amd64"
))
(setq exec-path (split-string (getenv "PATH") ";"))
(setenv "PYTHONPATH" "c:/Home/.python")
(setenv "TEXMFLOCAL" "$TEXMFROOT/texmf-local")
(setenv "SBCL_HOME" "c:/Local/SBCL/current/")
(setenv "OPENBLAS_NUM_THREADS" "4")
;; For TeXDocTk
(setenv "PDFVIEWER" "c:/Local/SumatraPDF/Sumatrapdf.exe"))
(when (eq system-type 'gnu/linux)
(require 'dbus)
(dbus-init-bus :system))
;; ** Init dynamic libraries
(dolist (type '(xpm jpeg png tiff gif imagemagick svg))
(init-image-library type))
;; ** Who am I?
(defvar current-user
(getenv
(if (equal system-type 'windows-nt) "USERNAME" "USER")))
(defvar fp-config-dir (file-name-directory (or load-file-name user-emacs-directory))
"The root dir of the Emacs FP configuration.")
(defvar fp-config-savefile-dir (expand-file-name "savefile" fp-config-dir)
"This folder stores all the automatically generated save/history-files.")
(unless (file-exists-p fp-config-savefile-dir)
(make-directory fp-config-savefile-dir))
;; ** setup packages
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
;; set package-user-dir to be relative to Prelude install path
(setq package-user-dir (expand-file-name "elpa" fp-config-dir))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
;; (setq use-package-always-ensure t)
(eval-when-compile
(require 'use-package))
(use-package diminish ;; if you use :diminish
:ensure t)
(use-package bind-key ;; if you use any :bind variant
:ensure t)
(setq emacs-debug nil)
(setq debug-on-error t)
;; Character encodings default to utf-8.
(prefer-coding-system 'utf-8)
(if (eq system-type 'windows-nt)
;; For Windows
(setq default-process-coding-system '(cp1252-dos . cp1252-unix))
;; For Unix
(set-language-environment 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-selection-coding-system 'utf-8))
;; Add coding systems for process that may require specific settings
(add-to-list 'process-coding-system-alist '("[pP][aA][nN][dD][oO][cC]" utf-8 . utf-8))
;; Always load newest byte code
(setq load-prefer-newer t)
;; reduce the frequency of garbage collection by making it happen on
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000)
;; warn when opening files bigger than 100MB
(setq large-file-warning-threshold 100000000)
(setq eval-expression-print-length nil)
(setq eval-expression-print-level nil)
;; FIXME
(setq enable-local-variables :all)
;; Nicer scrolling with mouse wheel/trackpad.
(unless (and (boundp 'mac-mouse-wheel-smooth-scroll) mac-mouse-wheel-smooth-scroll)
(global-set-key [wheel-down] (lambda () (interactive) (scroll-up-command 1)))
(global-set-key [wheel-up] (lambda () (interactive) (scroll-down-command 1)))
(global-set-key [double-wheel-down] (lambda () (interactive) (scroll-up-command 2)))
(global-set-key [double-wheel-up] (lambda () (interactive) (scroll-down-command 2)))
(global-set-key [triple-wheel-down] (lambda () (interactive) (scroll-up-command 4)))
(global-set-key [triple-wheel-up] (lambda () (interactive) (scroll-down-command 4))))
;; It seems that Windows 8.1 has made it very difficult to catch LWin and RWin keys
;; from an application. It seems the following AutoHotkey_L script
;; #IfWinActive ahk_exe emacs.exe
;; CapsLock::LCtrl
;; <+CapsLock::CapsLock
;; LCtrl::AppsKey
;; LWin::LWin
;; #IfWinActive
;; does what is needed to get hyper and super keys.
;; Make PC keyboard's Win key or other to type Super or Hyper, for emacs running on Windows.
(when (eq system-type 'windows-nt)
(setq w32-pass-lwindow-to-system nil
w32-pass-rwindow-to-system nil
w32-pass-apps-to-system nil
w32-lwindow-modifier 'hyper ; Left Windows key
w32-rwindow-modifier 'hyper ; Right Windows key
w32-apps-modifier 'super) ; Menu keyemacs lisp
(w32-register-hot-key [s-])
(w32-register-hot-key [h-])
;; Win32 !
;; As of Emacs 24.4, unicode filenames under NT should be honoured
;; (set-file-name-coding-system 'latin-1)
;; MS Windows clipboard is UTF-16LE
(set-clipboard-coding-system 'utf-16le-dos)
;; Fix a problem where it takes forever to read
;; the output of a process.
(setq w32-pipe-read-delay 0)
)
;; * Editor
;; Emacs modes typically provide a standard means to change the
;; indentation width -- eg. c-basic-offset: use that to adjust your
;; personal indentation width, while maintaining the style (and
;; meaning) of any files you load.
(setq-default indent-tabs-mode nil) ;; don't use tabs to indent
(setq-default tab-width 8) ;; but maintain correct appearance
;; Newline at end of file
(setq require-final-newline t)
;; delete the selection with a keypress
(delete-selection-mode t)
;; smart tab behavior - indent or complete
(setq tab-always-indent 'complete)
;;; Kill ring
(setq save-interprogram-paste-before-kill t)
;; * Backups
;; (setq backup-by-copying t)
(setq backup-by-copying-when-linked t)
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-list-file-prefix
(expand-file-name "auto-save-list/.saves-" fp-config-savefile-dir))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;; disable annoying blink-matching-paren
(setq blink-matching-paren nil)
;; * UI
;; the toolbar is just a waste of valuable screen estate
;; in a tty tool-bar-mode does not properly auto-load, and is
;; already disabled anyway
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
;; menu-bar is still useful sometimes
(menu-bar-mode +1)
; wrap lines
(global-visual-line-mode)
(diminish 'visual-line-mode)
(setq-default indicate-empty-lines t)
;; the blinking cursor is nothing, but an annoyance
(blink-cursor-mode -1)
;; disable the annoying bell ring
(setq ring-bell-function 'ignore)
;; disable startup screen
(setq inhibit-startup-screen t)
;; nice scrolling
(setq scroll-margin 0
scroll-conservatively 100000
scroll-preserve-screen-position 1)
;; disable scrollbars for windows
(scroll-bar-mode -1)
;; mode line settings
(line-number-mode t)
(column-number-mode t)
(size-indication-mode t)
;; enable y/n answers
(fset 'yes-or-no-p 'y-or-n-p)
;; more useful frame title, that show either a file or a
;; buffer name (if the buffer isn't visiting a file)
(setq frame-title-format
'("" invocation-name " - " (:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
(add-to-list 'default-frame-alist '(internal-border-width . 0))
;; (when (eq system-type 'windows-nt)
;; (add-to-list 'default-frame-alist `(font . "Consolas-10")))
(set-fringe-mode '(8 . 0))
;; * Keybindings
(use-package cua-base
:config
(setq cua-enable-cua-keys nil)
(cua-mode +1)
)
;; Align your code in a pretty way.
(global-set-key (kbd "C-x \\") 'align-regexp)
;; Font size
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
;; Window switching. (C-x o goes to the next window)
(global-set-key (kbd "C-x O") (lambda ()
(interactive)
(other-window -1))) ;; back one
;; A complementary binding to the apropos-command (C-h a)
(define-key 'help-command "A" 'apropos)
;; A quick major mode help with discover-my-major
(define-key 'help-command (kbd "C-m") 'discover-my-major)
(define-key 'help-command (kbd "C-f") 'find-function)
(define-key 'help-command (kbd "C-k") 'find-function-on-key)
(define-key 'help-command (kbd "C-v") 'find-variable)
(define-key 'help-command (kbd "C-l") 'find-library)
(define-key 'help-command (kbd "C-i") 'info-display-manual)
;; kill lines backward
(global-set-key (kbd "C-<backspace>") (lambda ()
(interactive)
(kill-line 0)
(indent-according-to-mode)))
;; replace buffer-menu with ibuffer
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; Activate occur easily inside isearch
(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
;; toggle menu-bar visibility
(global-set-key (kbd "<f12>") 'menu-bar-mode)
;; Start proced in a similar manner to dired
(unless (eq system-type 'darwin)
(global-set-key (kbd "C-x p") 'proced))
;; * Fonts
(when (eq system-type 'windows-nt)
(set-face-font 'default "Consolas-11")
(set-face-font 'variable-pitch "Segoe UI-11")
(set-face-font 'fixed-pitch "Consolas-11")
(custom-set-variables '(line-spacing 0.1))
)
(when (eq system-type 'gnu/linux)
(set-face-font 'default "Consolas-17")
(set-face-font 'variable-pitch "Segoe UI-17")
(set-face-font 'fixed-pitch "Consolas-17")
(custom-set-variables '(line-spacing 0.2))
)
;; ;; convert symbols like greek letter into its unicode character
(global-prettify-symbols-mode)
;; Enable emoji, and stop the UI from freezing when trying to display them.
(if (fboundp 'set-fontset-font)
(set-fontset-font t 'unicode "Segoe UI Emoji Normal" nil 'prepend))
(setq inhibit-compacting-font-caches t)
;; * Setup local packages
;; Fix load-path for those packages we mirror
(require 'cl)
(defvar *fp-config-packages-supplied-regexp*
"\\(lisp/org\\|elpa/slime-[0-9\.]+\\|elpa/org-mode-[0-9\.]+\\|elpa/org-ref-[0-9\.]+\\|elpa/org-reveal-[0-9\.]+\\|elpa/undo-tree-[0-9\.]+\\|elpa/ivy-[0-9\.]+\\|elpa/counsel-[0-9\.]+\\|elpa/swiper-[0-9\.]+\\)")
(defvar *fp-local-packages-directory* (expand-file-name "local" user-emacs-directory))
;; Remove packages maintained locally from load-path
(setq load-path
(remove-if '(lambda (s) (string-match *fp-config-packages-supplied-regexp* s) ) load-path))
;; Add the local packages to load-path
(mapcar #'(lambda (package)
(add-to-list 'load-path (expand-file-name package *fp-local-packages-directory*)))
'(
;; "magit/lisp"
"el-misc"
"font-lock-plus"
"org-mode/lisp"
"org-board"
"org-html-themes"
"org-protocol-capture-html"
"org-ref"
"org-reveal"
"ox-ipynb"
;; "pdf-tools/pdf-tools-0.70"
"ppd-sr-speedbar"
"spaceline"
;; "sly"
"slime"
;; "swiper"
"sumatra-forward"
;; "tablist"
"undo-tree"
))
;; http://emacs.stackexchange.com/a/26513/115
(defun modi/package-dependency-check-ignore (orig-ret)
"Remove the `black listed packages' from ORIG-RET.
Packages listed in the let-bound `pkg-black-list' will not be auto-installed
even if they are found as dependencies.
It is known that this advice is not effective when installed packages
asynchronously using `paradox'. Below is effective on synchronous
package installations."
(let ((pkg-black-list '(org slime swiper undo-tree org-ref org-reveal))
new-ret
pkg-name)
(dolist (pkg-struct orig-ret)
(setq pkg-name (package-desc-name pkg-struct))
(if (member pkg-name pkg-black-list)
(message (concat "Package `%s' will not be installed. "
"See `modi/package-dependency-check-ignore'.")
pkg-name)
;; (message "Package to be installed: %s" pkg-name)
(push pkg-struct new-ret)))
new-ret))
(advice-add 'package-compute-transaction :filter-return #'modi/package-dependency-check-ignore)
;; * Fixes
;; ** Remove ad-handle message
(setq ad-redefinition-action 'accept)
;; ** minibuffer
;; Minibuffer window expands vertically as necessary to hold the text that you put in the minibuffer
(setq resize-mini-windows t) ;; was grow-only
;; ** Emacs Lisp Mode
;; redefines the silly indent of keyword lists
;; before
;; (:foo bar
;; :baz qux)
;; after
;; (:foo bar
;; :baz qux)
(defun lisp-indent-function-kw (indent-point state)
"This function is the normal value of the variable `lisp-indent-function'.
The function `calculate-lisp-indent' calls this to determine
if the arguments of a Lisp function call should be indented specially.
INDENT-POINT is the position at which the line being indented begins.
Point is located at the point to indent under (for default indentation);
STATE is the `parse-partial-sexp' state for that position.
If the current line is in a call to a Lisp function that has a non-nil
property `lisp-indent-function' (or the deprecated `lisp-indent-hook'),
it specifies how to indent. The property value can be:
* `defun', meaning indent `defun'-style
\(this is also the case if there is no property and the function
has a name that begins with \"def\", and three or more arguments);
* an integer N, meaning indent the first N arguments specially
(like ordinary function arguments), and then indent any further
arguments like a body;
* a function to call that returns the indentation (or nil).
`lisp-indent-function' calls this function with the same two arguments
that it itself received.
This function returns either the indentation to use, or nil if the
Lisp function does not specify a special indentation."
(let ((normal-indent (current-column))
(orig-point (point)))
(goto-char (1+ (elt state 1)))
(parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
(cond
;; car of form doesn't seem to be a symbol, or is a keyword
((and (elt state 2)
(or (not (looking-at "\\sw\\|\\s_"))
(looking-at ":")))
(if (not (> (save-excursion (forward-line 1) (point))
calculate-lisp-indent-last-sexp))
(progn (goto-char calculate-lisp-indent-last-sexp)
(beginning-of-line)
(parse-partial-sexp (point)
calculate-lisp-indent-last-sexp 0 t)))
;; Indent under the list or under the first sexp on the same
;; line as calculate-lisp-indent-last-sexp. Note that first
;; thing on that line has to be complete sexp since we are
;; inside the innermost containing sexp.
(backward-prefix-chars)
(current-column))
((and (save-excursion
(goto-char indent-point)
(skip-syntax-forward " ")
(not (looking-at ":")))
(save-excursion
(goto-char orig-point)
(looking-at ":")))
(save-excursion
(goto-char (+ 2 (elt state 1)))
(current-column)))
(t
(let ((function (buffer-substring (point)
(progn (forward-sexp 1) (point))))
method)
(setq method (or (function-get (intern-soft function)
'lisp-indent-function)
(get (intern-soft function) 'lisp-indent-hook)))
(cond ((or (eq method 'defun)
(and (null method)
(> (length function) 3)
(string-match "\\`def" function)))
(lisp-indent-defform state indent-point))
((integerp method)
(lisp-indent-specform method state
indent-point normal-indent))
(method
(funcall method indent-point state))))))))
(eval-after-load "lisp-mode"
(lambda ()
(setq lisp-indent-function 'lisp-indent-function-kw)))
;; ** Doc View
(setq doc-view-odf->pdf-converter-program "c:/Program Files/LibreOffice 5/program/soffice.exe")
(setq doc-view-odf->pdf-converter-function #'doc-view-odf->pdf-converter-soffice)
;; * Utilities
(defmacro advise-commands (advice-name commands class &rest body)
"Apply advice named ADVICE-NAME to multiple COMMANDS.
The body of the advice is in BODY."
`(progn
,@(mapcar (lambda (command)
`(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate)
,@body))
commands)))
;; * ELPA Packages
;; ** custom settings
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)
;; ** abbrev
(use-package abbrev
:ensure nil
:pin manual
:config
(setq abbrev-file-name (expand-file-name "abbrev_defs" fp-config-savefile-dir))
;; abbrev config
(add-hook 'text-mode-hook 'abbrev-mode)
)
;; ** ace-window
(use-package ace-window
:ensure t
:config
(setq aw-keys '(?q ?s ?d ?f ?j ?k ?l ?m))
(ace-window-display-mode)
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0)))))
:bind (("C-o " . ace-window)
("s-w" . ace-window)))
;; ** ag
(use-package ag
:ensure t)
;; ** all-the-icons
(use-package all-the-icons-dired
:ensure t
:after (all-the-icons))
(use-package all-the-icons
:ensure t
:config
(require 'font-lock+)
)
;; ** auto-complete
(use-package auto-complete
:ensure t
:config
(setq ac-comphist-file (expand-file-name "ac-comphist.dat" fp-config-savefile-dir)))
;; ** auto-revert
;; revert buffers automatically when underlying files are changed externally
(use-package autorevert
:ensure nil
:pin manual
:config
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)
(setq auto-revert-use-notify t)
;; Possibly set files to ignore
;; (setq global-auto-revert-ignore-modes ())
(global-auto-revert-mode t)
)
;; ** avy
(use-package avy
:ensure t
:config
(setq avy-background t)
(setq avy-style 'at-full)
:diminish avy-mode
:bind (("C-x C-SPC" . avy-goto-char)
;; ("C-x C-x" . avy-goto-word-or-subword-1)
("C-c j" . avy-goto-word-or-subword-1)
("s-." . avy-goto-word-or-subword-1)
("C-x C-l" . avy-goto-line)))
;; ** anzu
;; anzu-mode enhances isearch & query-replace by showing total matches and current match position
(use-package anzu
:ensure t
:diminish anzu-mode
:config
(setq anzu-cons-mode-line-p nil)
(global-anzu-mode)
:bind
(("M-%" . anzu-query-replace)
("C-M-%" . anzu-query-replace-regexp)))
;; ** beacon
;; (use-package beacon
;; :ensure t
;; :config
;; (beacon-mode +1)
;; )
;; ** bookmark
(use-package bookmark
:ensure nil
:pin manual
:config
(setq bookmark-default-file (expand-file-name "bookmarks" fp-config-savefile-dir)
bookmark-save-flag 1)
)
;; ** bookmark+
;; (use-package bookmark+)
;; ** browse-kill-ring
;; smarter kill-ring navigation
(use-package browse-kill-ring
:ensure t
:config
(browse-kill-ring-default-keybindings)
(global-set-key (kbd "s-y") 'browse-kill-ring)
)
;; ** company mode
(use-package company
:ensure t
:diminish company-mode
:config
(add-hook 'after-init-hook 'global-company-mode)
(setq company-idle-delay 0)
(setq company-show-numbers t)
(setq company-minimum-prefix-length 3)
(delete 'company-capf company-backends)
(add-hook 'company-mode-hook 'company-statistics-mode))
(use-package company-statistics
:ensure t
:config
(setq company-statistics-file
(expand-file-name "company-statistics-file" fp-config-savefile-dir)))
;; ** crux
(use-package crux
:bind (([remap kill-whole-line] . crux-kill-whole-line)
("C-^" . crux-top-join-line))
:ensure t)
;; ** dash
(use-package dash
:ensure t)
;; ** dictionary
(use-package dictionary
:ensure t)
;; ** diff-hl
;; (use-package diff-hl
;; :ensure t
;; :config
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
;; (global-diff-hl-mode +1)
;; )
;; ** dired
(use-package dired
:ensure nil
:pin manual
:config
;; dired - reuse current buffer by pressing 'a'
(put 'dired-find-alternate-file 'disabled nil)
;; always delete and copy recursively
(setq dired-recursive-deletes 'always)
(setq dired-recursive-copies 'always)
;; if there is a dired buffer displayed in the next window, use its
;; current subdir, instead of the current subdir of this dired buffer
(setq dired-dwim-target t)
;; Don't use any ls.exe
(setq ls-lisp-use-insert-directory-program nil)
;; Sort the same way as Unix ls does
(setq ls-lisp-UCA-like-collation nil)
;; Use human readable sizes
(setq dired-listing-switches "-alh")
(setq dired-guess-shell-alist-user
'(; ("\\.pdf\\'" "start")
;; ("\\.pdf\\'" "c:/Local/SumatraPDF/SumatraPDF -reuse-instance")
("\\.pdf\\'" "start")
("\\.zip\\'" "start")
("\\.docx?\\'" "start")
("\\.xlsx?\\'" "start")
("\\.pptx?\\'" "start")
("\\.jpe?g\\'" "start")
("\\.png\\'" "start")
("\\.bmp\\'" "start")
("\\.html\\'" "start")
))
(defadvice dired-shell-stuff-it (around dired-execute-start-command)
"Use w32-shell-execute to execute `start' commands."
(if (string= (ad-get-arg 0) "start")
(dolist (file (ad-get-arg 1))
(w32-shell-execute nil (expand-file-name file default-directory)))
ad-do-it))
(ad-activate 'dired-shell-stuff-it)
;; Dired invokes dired-run-shell-command anyway, even when
;; the command as already been processed by advising
;; dired-shell-stuff-it. In this case the command is null.
;; We want to avoid any error message.
(defadvice dired-run-shell-command (around dired-ignore-null-command)
"Ignore null command in dired-run-shell-command."
(when (ad-get-arg 0)
ad-do-it))
(ad-activate 'dired-run-shell-command)
;; (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
(defun copy-buffer-file-name-as-kill (choice)
"Copy the buffer-file-name to the kill-ring"
(interactive "cCopy Buffer Name (F) Full, (D) Directory, (N) Name")
(let ((new-kill-string)
(name (if (eq major-mode 'dired-mode)
(dired-get-filename)
(or (buffer-file-name) ""))))
(cond ((eq choice ?f)
(setq new-kill-string name))
((eq choice ?d)
(setq new-kill-string (file-name-directory name)))
((eq choice ?n)
(setq new-kill-string (file-name-nondirectory name)))
(t (message "Quit")))
(when new-kill-string
(message "%s copied" new-kill-string)
(kill-new new-kill-string))))
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
)
;; ** dired+
(use-package dired+
:ensure t
:config
(global-dired-hide-details-mode -1)
)
;; ** dired-x
;; enable some really cool extensions like C-x C-j (dired-jump)
(use-package dired-x
:ensure nil
:pin manual)
;; ** discover-my-major
(use-package discover-my-major
:ensure t)
;; ** doc-view
;; (use-package doc-view
;; :config
;; (add-hook 'doc-view-mode-hook (lambda () (centered-cursor-mode -1)))
;; (define-key doc-view-mode-map (kbd "<right>") 'doc-view-next-page)
;; (define-key doc-view-mode-map (kbd "<left>") 'doc-view-previous-page)
;; (setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
;; (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
;; (global-set-key (kbd "C-<wheel-up>") 'doc-view-enlarge)
;; (global-set-key (kbd "C-<wheel-down>") 'doc-view-shrink)
;; (setq doc-view-continuous t))
;; ** easy-kill
(use-package easy-kill
:ensure t
:config
(global-set-key [remap kill-ring-save] 'easy-kill)
(global-set-key [remap mark-sexp] 'easy-mark)
)
;; ** ediff
(use-package ediff
:ensure nil
:pin manual
:config
(ediff-set-diff-options 'ediff-diff-options "--strip-trailing-cr")
(setq ediff-split-window-function 'split-window-horizontally)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
)
;; ** epl
(use-package epl
:ensure t)
;; ** expand-region
(use-package expand-region
:bind (("C-=" . er/expand-region))
:ensure t)
;; ** eyebrowse
;; (use-package eyebrowse
;; :diminish eyebrowse-mode
;; :config (progn
;; (define-key eyebrowse-mode-map (kbd "M-1") 'eyebrowse-switch-to-window-config-1)
;; (define-key eyebrowse-mode-map (kbd "M-2") 'eyebrowse-switch-to-window-config-2)
;; (define-key eyebrowse-mode-map (kbd "M-3") 'eyebrowse-switch-to-window-config-3)
;; (define-key eyebrowse-mode-map (kbd "M-4") 'eyebrowse-switch-to-window-config-4)
;; (define-key eyebrowse-mode-map (kbd "S-s-<right>") 'eyebrowse-next-window-config)
;; (define-key eyebrowse-mode-map (kbd "S-s-<left>") 'eyebrowse-prev-window-config)
;; (setq eyebrowse-new-workspace t)))
;; ** flycheck
(use-package flycheck
:ensure t)
;; ** flyspell
;; flyspell-mode does spell-checking on the fly as you type
(use-package flyspell
:ensure t
:config
(setenv "LANG" "en_US")
;; (setenv "DICPATH" (concat ".;" (expand-file-name "../etc/hunspell" exec-directory))) ;;
(setenv "DICPATH" "c:/Local/MSys64/mingw64/share/hunspell") ;;
(setq ispell-program-name "hunspell.exe"
ispell-dictionary "en_US"
ispell-extra-args '("--sug-mode=ultra"))
)
;; ** framemove
;; DEPRECATED, not available on ELPA anymore
;; (use-package framemove
;; :ensure t
;; :config
;; ;; FIXME: does this load windmove?
;; (setq framemove-hook-into-windmove t)
;; )
;; ** gist
(use-package gist
:ensure t)
;; ** git-timemachine
(use-package git-timemachine
:ensure t)
;; ** gitconfig-mode
(use-package gitconfig-mode
:ensure t)
;; ** gitignore-mode
(use-package gitignore-mode
:ensure t)
;; ** helpful
(use-package helpful
:ensure t)
;; ** FIXME git-gutter
;; (use-package git-gutter
;; :ensure t
;; :config
;; ;; If you enable global minor mode
;; ;; (global-git-gutter-mode t)
;; ;; If you would like to use git-gutter.el and linum-mode
;; (git-gutter:linum-setup)
;; ;; If you enable git-gutter-mode for some modes
;; ;; (add-hook 'ruby-mode-hook 'git-gutter-mode)
;; ;; (add-hook 'python-mode-hook 'git-gutter-mode)
;; (global-set-key (kbd "C-x C-g") 'git-gutter)
;; (global-set-key (kbd "C-x v =") 'git-gutter:popup-hunk)
;; ;; Jump to next/previous hunk
;; (global-set-key (kbd "C-x p") 'git-gutter:previous-hunk)
;; (global-set-key (kbd "C-x n") 'git-gutter:next-hunk)
;; ;; Stage current hunk
;; (global-set-key (kbd "C-x v s") 'git-gutter:stage-hunk)
;; ;; Revert current hunk
;; (global-set-key (kbd "C-x v r") 'git-gutter:revert-hunk)
;; ;; Mark current hunk
;; (global-set-key (kbd "C-x v SPC") #'git-gutter:mark-hunk)
;; )
;; ** god-mode
(use-package god-mode
:ensure t)
;; ** grizzl
;; (use-package grizzl
;; :ensure t)
;; ** guru-mode
(use-package guru-mode
:ensure t)
;; ** highlight-symbol
(use-package highlight-symbol
:ensure t)
;; ** hippie-exp
;; hippie expand is dabbrev expand on steroids
(use-package hippie-exp
:ensure t
:bind (("M-/" . hippie-expand))
:config
(setq hippie-expand-try-functions-list '(try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol)))
;; ** hl-line
(use-package hl-line
:ensure t
:config
(global-hl-line-mode +1))
;; ** htmlize
(use-package htmlize
:ensure t)
;; ** hungry-delete
;;; deletes all the whitespace when you hit backspace or delete
;; (use-package hungry-delete
;; :ensure t