-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs-snowflake
1231 lines (1086 loc) · 50.1 KB
/
.emacs-snowflake
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
;; -*- mode: Emacs-Lisp;-*-
;;; Installing emacs on Mac:
;;;
;;; - Recommend: https://github.com/daviderestivo/homebrew-emacs-head
;;; and install --with-cocoa for GUI, but it has some periodic
;;; flickering.
;;;
;;; - Alternative: https://github.com/railwaycat/homebrew-emacsmacport
;;;
;;; - Second alternative: https://emacsformacosx.com/ but also doesn't
;;; come with `emacs` terminal command.
;;;
;;; Current setup: emacs-mac copied the application from Cellar to
;;; /Applications, then copy its Contents/Emacs executable to
;;; /usr/local/bin/emacs for the terminal version because emacs-mac's
;;; default shell script for it is asynchronous and leads to
;;; unexpected git commit message behavior. emacs-head leads to
;;; crashes on loading.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Package setup ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Try to prevent weird "Error (bytecomp): Invalid read syntax: "#"'
;; (byte-recompile-directory (expand-file-name "~/.emacs.d") 0)
;; To prevent weird compile error, "defvar-1" (this is probably caused
;; by bad multi-versioning) you can also reinstall .emacs.d.
;; Emacs head 29.1 intermittently freezes during tramp shell session
;; with 100% CPU when overwriting a highlighted shell command.
;; Turning off flycheck + company didn't help.
(setq default-directory (getenv "HOME"))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(package-quickstart-refresh)
(setq use-package-always-ensure t)
(setq henryhu-packages
(list 'alert ; for slack
'browse-kill-ring
'company-flow
'counsel ; for ivy
'counsel-fd
'dashboard ; Depends on Emacs 25.3
'diminish
'dumb-jump
'el-get ; for slack
'emojify ; for slack
'filladapt
'ivy
'inf-ruby
'link-hint
'magit
'markdown-mode ; for markdown-follow-thing-at-point
'monokai-pro-theme ; for remote buffers
'move-text
'prettier-js
'python-docstring
'rg
'string-inflection
'scheme-complete
'sudo-edit ; for M-x sudo
'use-package
'web-mode
'yaml-mode))
(mapcar #'package-install henryhu-packages)
(load "~/.emacs.d/start-common-emacs")
;; Zenburn theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/zenburn-emacs")
(load-theme 'zenburn t)
;; (load-theme 'monokai-pro-ristretto t)
;; Possibly fixes some package-install: Bad Request errors
;; (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;; Set bash for M-x shell, M-x shell-command
(setq explicit-shell-file-name "/bin/bash")
(setenv "SHELL" "/bin/bash")
;; From https://emacs.stackexchange.com/questions/65080/stop-major-modes-from-overwriting-my-keybinding
(defvar my/keys-keymap (make-keymap)
"Keymap for my/keys-mode")
(define-minor-mode my/keys-mode
"Minor mode for my personal keybindings."
:init-value t
:global t
:keymap my/keys-keymap)
;; The keymaps in `emulation-mode-map-alists' take precedence over
;; `minor-mode-map-alist'
(add-to-list 'emulation-mode-map-alists
`((my/keys-mode . ,my/keys-keymap)))
;; End package setup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Window system settings ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Turn off Folding Mode. Must do this _before_ loading InfoLab-wide
;;; common-emacs file.
(setq folding-auto-start nil)
(display-time-mode 1)
;;; Turn off lockfiles. Leaves me vulnerable to getting work
;;; overwritten by separate instances of Emacs, but prevents bogus
;;; file lock messages when using a computer with a dynamic IP.
(setq create-lockfiles nil)
(add-to-list 'default-frame-alist '(fullscreen . maximized)) ;start emacs maximized
;; Enable mouse support
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(define-key my/keys-keymap (kbd "[mouse-4]") (lambda ()
(interactive)
(scroll-down 1)))
(define-key my/keys-keymap (kbd "[mouse-5]") (lambda ()
(interactive)
(scroll-up 1)))
(defun track-mouse (e))
(setq mouse-sel-mode t)
)
(use-package link-hint
:ensure t
:bind
("H-o" . link-hint-open-link-at-point)
("H-i" . link-hint-copy-link))
;; ...follow-thing... doesn't work in elisp comments
;; ...follow-link... doesn't work in shell
;; (define-key my/keys-keymap (kbd "H-o") 'markdown-follow-link-at-point)
(define-key my/keys-keymap (kbd "H-f") 'toggle-frame-maximized)
;; Solid, unblinking cursor
(blink-cursor-mode 0)
;; Change C-l default behavior
;; (setq recenter-positions '(middle top bottom))
;; Scroll page instead of point.
(define-key my/keys-keymap (kbd "C-c C-s C-s") 'scroll-lock-mode)
;; ;;;Set window height
;; (if (window-system)
;; (set-frame-height (selected-frame) 50))
(defun make-frame-vertical-on-right ()
"Assuming 3440 x 1440 screen (my LG monitor), create a new
frame on the right-hand monitor (switching to it), and maximize
it."
(interactive)
(let ((fudge 50))
(make-frame '(;; (name . "*frame")
(top . 0)
(left . (+ 3440 fudge))
;; (width . (text-pixels . 1080))
;; (height . (text-pixels . 1920))
)))
;; (toggle-frame-maximized)
)
(defun make-frame-vertical-on-left ()
"make new frame on left and maximize."
(interactive)
(make-frame '(;; (name . "*frame")
(top . 0)
(left . 0)
;; (width . (text-pixels . 1080))
;; (height . (text-pixels . 1920))
))
;; (toggle-frame-maximized)
)
(defun make-frame-vertical-on-top ()
"make new frame on top and maximize, assuming 3440 x 1440 centered-ish on top of the primary 1728 x 1117 monitor."
(interactive)
(let ((fudge 50))
(make-frame '(;; (name . "*frame")
(top . -1440)
(left . -1000)
;; (width . (text-pixels . 1080))
;; (height . (text-pixels . 1920))
)))
;; (toggle-frame-maximized)
)
(define-key my/keys-keymap (kbd "C-x 5 u") 'make-frame-vertical-on-left) ; make on top in a vertical monitor setup is same as on left
(define-key my/keys-keymap (kbd "C-x 5 r") 'make-frame-vertical-on-right)
(define-key my/keys-keymap (kbd "C-x 5 l") 'make-frame-vertical-on-left)
;;; Save session
(desktop-save-mode 1)
;; https://stackoverflow.com/questions/4053708/emacs-desktop-doesnt-remember-tramp-connections
;; "By default it is set to a regexp that matches TRAMP filenames. I
;; would have expected setting it to nil would have worked, but, alas,
;; it does not."
(setq desktop-buffers-not-to-save "^$")
(setq desktop-files-not-to-save "^$") ; I don't know the exact emacs version but this is the older name for the variable.
;;; But don't save frame/window configuration, just buffers (ex. for
;;; code search)
(setq desktop-restore-frames nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Horizontal scrolling setup ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar recenter-scroll-last-op nil
"Indicates the last recenter scroll operation performed.
Possible values: `top', `middle', `bottom', integer or float numbers.
(Left is top, middle is middle, and right is bottom.)
It can also be nil, which means the first value in `recenter-positions'.")
;; Scrolling horizontally. Scroll directions are sort of "backwards"
;; in that scroll-all-the-way-right corresponds to C-a instead of C-e.
(defun activate-horizontal-mode ()
(interactive)
;; IDK how to toggle this since toggle-horizontal-scroll-bar
;; requires arg. Just leave it on.
(horizontal-scroll-bar-mode)
;; Avoid hscroll when there are long lines, e.g., in test output.
(setq auto-hscroll-mode nil)
(toggle-truncate-lines))
(defun scroll-all-the-way-right ()
(interactive)
(scroll-right 1000000000)
(beginning-of-line))
(defun scroll-right-and-move-point ()
(interactive)
(scroll-right)
;; Don't use window-width since linum-mode doesn't update it.
(move-to-column (max 0 (- (current-column) (window-max-chars-per-line)))))
(defun scroll-left-and-move-point ()
(interactive)
(scroll-left)
;; Don't use window-width since linum-mode doesn't update it.
(move-to-column (+ (current-column) (window-max-chars-per-line))))
(defun my-horizontal-recenter ()
"make the point move like C-l in current window but horizontally"
(interactive)
;; Don't use window-width since linum-mode doesn't update it.
;; See
(cond
((equal truncate-lines t)
(setq recenter-scroll-last-op
(if (eq this-command last-command)
(car (or (cdr (member recenter-scroll-last-op recenter-positions))
recenter-positions))
(car recenter-positions)))
(let ((mid (/ (window-max-chars-per-line) 2))
(this-scroll-margin
(min (max 0 scroll-margin)
(truncate (/ (window-max-chars-per-line) 4.0))))
;; (line-len (save-excursion (end-of-line) (current-column)))
;; (cur-scroll (window-hscroll)))
(cur (current-column)))
(cond
((eq recenter-scroll-last-op 'top)
(set-window-hscroll (selected-window)
(- cur this-scroll-margin)))
((eq recenter-scroll-last-op 'middle)
(set-window-hscroll (selected-window)
(- cur mid)))
((eq recenter-scroll-last-op 'bottom)
(set-window-hscroll (selected-window)
(- cur (window-max-chars-per-line) (- this-scroll-margin)))))))))
(define-key my/keys-keymap (kbd "C-M-o") 'activate-horizontal-mode)
(put 'scroll-left 'disabled nil)
(put 'scroll-right 'disabled nil)
;; Overrides some keybindings that I don't use
(define-key my/keys-keymap (kbd "M-u") 'scroll-all-the-way-right)
(define-key my/keys-keymap (kbd "M-l") 'my-horizontal-recenter)
(define-key my/keys-keymap (kbd "M-i") 'scroll-right-and-move-point)
(define-key my/keys-keymap (kbd "M-o") 'scroll-left-and-move-point)
;; In wrap mode, go to previous logical line instead of visual line.
(define-key my/keys-keymap (kbd "C-S-p") 'previous-logical-line)
(define-key my/keys-keymap (kbd "C-S-n") 'next-logical-line)
;;; Start in fullscreen
(defun my-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen 'fullheight))
(defun my-non-fullscreen ()
(interactive)
(set-frame-parameter nil 'width 82)
(set-frame-parameter nil 'fullscreen 'fullheight))
(defun toggle-fullscreen ()
(interactive)
(if (eq (frame-parameter nil 'fullscreen) 'maximized) ;tests if already fullscreened
(my-non-fullscreen)
(my-fullscreen)))
(define-key my/keys-keymap (kbd "<f11>") 'toggle-fullscreen)
;;; (toggle-fullscreen)
;;; (toggle-fullscreen)
(toggle-fullscreen)
;;; Alias for zooming (C-x C-+)
(defun zoom-in ()
(interactive)
(text-scale-adjust 2))
(defun zoom-out ()
(interactive)
(text-scale-adjust -2))
;;; Make zooming global
;;; https://stackoverflow.com/questions/18783227/emacs-zoom-in-out-globally
;; Broken because new buffers are not zoomed in and zooming them in
;; causes everyone else to zoom in too
;; (defadvice text-scale-increase (around all-buffers (arg) activate)
;; (dolist (buffer (buffer-list))
;; (with-current-buffer buffer
;; ad-do-it)))
;;;Typed text replaces the selection
(delete-selection-mode 1)
;;; Autodetect bullets (- xxx) etc. when filling lines
(autoload 'turn-on-filladapt-mode "filladapt" "Turn on the glorious Filladapt mode.")
(defun asf-turn-on-filladapt ()
(unless (eq major-mode 'org-mode)
(turn-on-filladapt-mode)
(diminish 'filladapt-mode)))
;; Filladapt is old (but great!), so we can't turn it on just
;; everywhere. We have python-docstring-mode for python so it's mainly
;; markdown lists.
(mapc (lambda (hook)
(add-hook hook 'asf-turn-on-filladapt))
'(text-mode-hook
markdown-mode-hook
global-magit-file-mode-hook))
;;; Stefan Monnier <foo at acm.org>. It is the opposite of fill-paragraph
(defun unfill-paragraph (&optional region)
"Takes a multi-line paragraph and makes it into a single line of text."
(interactive (progn (barf-if-buffer-read-only) '(t)))
(let ((fill-column (point-max))
;; This would override `fill-column' if it's an integer.
(emacs-lisp-docstring-fill-column t))
(fill-paragraph nil region)))
(define-key global-map "\M-Q" 'unfill-paragraph)
;;;When point is on a paired character the other is highlighted at no delay
(setq show-paren-delay 0)
(show-paren-mode 1)
(put 'upcase-region 'disabled nil)
;;; EDiffs split with windows on left and right instead of top and bottom
(setq ediff-split-window-function (quote split-window-horizontally))
(define-key my/keys-keymap (kbd "C-x x x") 'exit-recursive-edit)
;;; Keep windows balanced -- allows C-x 3 C-x 3 to make 3 equal
;;; vertical windows https://stackoverflow.com/a/58136628
(advice-add 'split-window-right :after #'balance-windows)
;;; Can't rebalance after delete-window because it throws errors
;;; whenever deleting windows from completion actions etc.
;;; (advice-add 'delete-window :after #'balance-windows)
(tool-bar-mode -1)
(toggle-frame-maximized)
;; Enable line numbers globally
;; (global-linum-mode t) ; very slow for big files, esp. skip to file start
;; Enable line numbers in Emacs >26
;; (https://www.emacswiki.org/emacs/LineNumbers)
(require 'display-line-numbers)
(defcustom display-line-numbers-exempt-modes
'(vterm-mode eshell-mode shell-mode term-mode ansi-term-mode dashboard-mode)
"Major modes on which to disable line numbers."
:group 'display-line-numbers
:type 'list
:version "green")
(defun display-line-numbers--turn-on ()
"Turn on line numbers except for certain major modes.
Exempt major modes are defined in `display-line-numbers-exempt-modes'."
(unless (or (minibufferp)
(member major-mode display-line-numbers-exempt-modes))
(display-line-numbers-mode)))
(when (version<= "26.0.50" emacs-version )
(global-display-line-numbers-mode))
;; Prevent slowdown from major modes in files with longlines
;; Especially python-mode
;; https://emacs.stackexchange.com/questions/598/how-do-i-prevent-extremely-long-lines-making-emacs-slow
(add-hook
'find-file-hook
(defun my-find-file-care-about-long-lines ()
(save-excursion
(goto-char (point-min))
(when (and (not (eq major-mode 'image-mode))
(not (eq major-mode 'doc-view-mode))
(search-forward-regexp ".\\{4000\\}" 50000 t)
(y-or-n-p "Very long lines detected - continue without a major mode? "))
(fundamental-mode)))))
;; Prevent slow catchup when emacs is waiting on a fast but
;; high-output command in M-x shell.
;; (defun my-clear ()
;; (interactive)
;; (let ((comint-buffer-maximum-size 0))
;; (comint-truncate-buffer)))
;; (define-key my/keys-keymap (kbd "C-c C-w") 'my-clear)
;;; Prevent company from lowercasing autocompletions.
;; (setq company-dabbrev-downcase nil)
;; company is very frustratingly hangy for ssh tramp.
;; (company-mode 0)
;;; Use Ivy, especially for emoji
(ivy-mode)
(setq enable-recursive-minibuffers t)
;;; Good for matching unicode chars
;; (setq search-default-mode #'char-fold-to-regexp)
;;; Disabled because can't go backwards. If interested in restoring,
;;; try https://github.com/abo-abo/swiper/issues/1172.
;; (define-key my/keys-keymap "\C-r" 'swiper)
;; (define-key my/keys-keymap "\C-s" 'swiper)
;;; Disabled because interferes with C-c C-r C-g in Stripe section.
;; (define-key my/keys-keymap (kbd "C-c C-r") 'ivy-resume)
(define-key my/keys-keymap (kbd "M-x") 'counsel-M-x)
(define-key my/keys-keymap (kbd "C-x C-f") 'counsel-find-file)
(define-key my/keys-keymap (kbd "C-c g") 'counsel-git)
(define-key my/keys-keymap (kbd "C-c j") 'counsel-git-grep)
;; Rebound by comint-stfu
;; (define-key my/keys-keymap (kbd "C-c k") 'counsel-ag)
(define-key my/keys-keymap (kbd "C-x l") 'counsel-locate)
(define-key my/keys-keymap (kbd "C-S-o") 'counsel-rhythmbox)
(setq ivy-count-format "%d/%d ")
;;; ~/ is muscle memory, plus emacs autosaves have ~. See
;;; https://github.com/abo-abo/swiper/commit/83121769b411a49d1e58aab89e8c800810b223c0
;;; Tip: to go to local file during a TRAMP session, type ~/~/
(setq ivy-magic-tilde '())
;;; Match queries in any order "example for" matches "for example"
(setq ivy-re-builders-alist
'((t . ivy--regex-ignore-order)))
;; C-M-j (ivy-immediate-done) (overwritten by one of my macros so I
;; reset it to C-<return>. Exits with the current input instead
;; of the current candidate (like other commands). This is useful
;; e.g. when you call find-file to create a new file, but the
;; desired name matches an existing file. In that case, using C-j
;; would select that existing file, which isn't what you want -
;; use this command instead. tags: quote, literal
(define-key my/keys-keymap (kbd "C-<return>") 'ivy-immediate-done)
;; On second thought, idc. C-j is still most natural to me.
(define-key my/keys-keymap (kbd "C-j") 'ivy-immediate-done)
;; Using wd in shell (see .wd-history) messes up Emacs's current
;; working directory (used for find-file). Resync (aka M-<return>).
(define-key my/keys-keymap (kbd "C-x w d") 'shell-resync-dirs)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
;; Change startup splash screen to be more useful.
(use-package dashboard
:ensure t
:diminish dashboard-mode
:config
(setq dashboard-banner-logo-title "Welcome to emacs!")
;; (setq dashboard-startup-banner "/Users/henryhu/Pictures/lake.jpg")
(setq dashboard-items '((recents . 10)
(bookmarks . 10)))
(dashboard-setup-startup-hook)) ; Depends on emacs 25.3
;; Move line/region with M-up, M-down
(move-text-default-bindings)
;; ;; Try to get colors to display in M-x shell, e.g., in binding.pry
;; (add-to-list 'comint-output-filter-functions 'ansi-color-process-output)
;; (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; (add-hook 'shell-mode-hook ()
;; https://emacs.stackexchange.com/questions/21751/how-to-prevent-backspace-from-deleting-my-shell-prompt
(setq comint-prompt-read-only t)
;; ;; Try to get colors to display in M-x shell part 2 (thanks to Mike
;; ;; Hamrick)
;; (use-package xterm-color)
;; (setq compilation-environment '("TERM=xterm-256color"))
;; (setq compilation-read-command nil)
;; (setq compilation-scroll-output t)
;; (defun my/advice-compilation-filter (f proc string)
;; (funcall f proc (xterm-color-filter string)))
;; (advice-add 'compilation-filter :around #'my/advice-compilation-filter)
;; End Window system settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Common commands ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Insert string for the current time formatted like '2:34 PM'.
(defun now ()
(interactive) ; permit invocation in minibuffer
(insert (format-time-string "%D %-I:%M %p")))
;; Insert string for today's date nicely formatted in American style,
;; e.g. Sunday, September 17, 2000.
(defun today ()
(interactive) ; permit invocation in minibuffer
(insert (format-time-string "%A, %B %e, %Y")))
(defun rolldice ()
(interactive)
(shell-command "echo You rolled a $((1 + RANDOM % 6))\\! &"))
(defun show-file-name ()
"Show the full path file name in the minibuffer and kill it."
(interactive)
(kill-new (buffer-file-name))
(message (buffer-file-name)))
(defalias 'pwd 'show-file-name)
;; Consider nonexecutables in shell autocomplete
(setq shell-command-execonly nil)
;; https://www.emacswiki.org/emacs/IncrementNumber
(defun my-increment-number-decimal (&optional arg)
"Increment the number forward from point by 'arg'."
(interactive "p*")
(save-excursion
(save-match-data
(let (inc-by field-width answer)
(setq inc-by (if arg arg 1))
(skip-chars-backward "0123456789")
(when (re-search-forward "[0-9]+" nil t)
(setq field-width (- (match-end 0) (match-beginning 0)))
(setq answer (+ (string-to-number (match-string 0) 10) inc-by))
(when (< answer 0)
(setq answer (+ (expt 10 field-width) answer)))
(replace-match (format (concat "%0" (int-to-string field-width) "d")
answer)))))))
(define-key my/keys-keymap (kbd "C-c +") 'my-increment-number-decimal)
;; Enable super-merge mode better prefix binding
(setq smerge-command-prefix "\C-cs")
(define-key my/keys-keymap (kbd "C-c s s") #'smerge-mode)
(define-key my/keys-keymap (kbd "C-j") #'newline-and-indent)
;; Use browse-kill-ring
(define-key my/keys-keymap "\C-cy" '(lambda ()
(interactive)
(browse-kill-ring)))
;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun mv-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))
(defun rm-file-and-buffer (confirm)
"Removes both current buffer and file it's visiting."
(interactive "sEnter n to abort: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (equal "n" confirm)
(message "Aborted!")
(progn
(delete-file filename)
(kill-buffer))))))
;; Jump forward to the next argument in a function or item in a list,
;; and put it on a new line. To re-indent a function, use C-M-j till
;; you see the end-of-list, then use C-M-h once. If a comma is
;; already present at the end of the list, then use C-M-j instead of
;; C-M-h at the end of the list.
(fset 'newline-at-next-argument-or-item
[?\C-\M-s ?\\ ?\( ?\( ?\\ ?| ?, ?\\ ?| ?\\ ?\[ ?\\ ?\) return ?\C-j])
(define-key my/keys-keymap "\C-\M-j" 'newline-at-next-argument-or-item)
(fset 'newline-at-arglist-or-list-end
[?\C-\M-s ?\\ ?\( ?\) ?\\ ?| ?\\ ?\] ?\\ ?\) return ?\C-b ?\, ?\C-j ?\C-f])
(define-key my/keys-keymap "\C-\M-h" 'newline-at-arglist-or-list-end)
;; Used to continue search after M-x tags-search RET <term> RET
(define-key my/keys-keymap "\M-," 'tags-loop-continue)
(fset 'add-index-to-proper-noun
[?\C-\M-s ?\[ ?A ?- ?Z ?\] return ?\C-\M-f ?+ ?1])
;; (define-key my/keys-keymap "\C-\M-z" 'add-index-to-proper-noun)
(fset 'jump-to-texp
[?\C-s ?\[ return])
;; (define-key my/keys-keymap "\C-\M-x" 'jump-to-texp)
(fset 'astroparse-test-result-to-list-item
(kmacro-lambda-form [?\C-s ?\[ return ?\C-b ?\C- ?\C-a backspace ?\' ?\C-e ?\' ?, ?\C-n ?\C-a] 0 "%d"))
(define-key my/keys-keymap "\C-\M-z" 'astroparse-test-result-to-list-item)
(fset 'astroparse-mark-expected-fail-for-stanza
(kmacro-lambda-form [?\C-s ?d ?e ?f ? ?t ?e ?s ?t ?_ return ?\C-a ?\C- ?\C-n ?\M-w ?\C-p ?\C-p ?\C-e return backspace backspace ?@ ?u ?n ?i ?t ?t ?e ?s ?t ?. ?e ?x ?p ?e ?c ?t ?e ?d ?F ?a ?i ?l ?u ?r ?e ?\C-n ?\C-e return return return ?\C-y backspace ?\C-a tab tab ?\C-p ?\C-p tab ?s ?u ?p ?e ?r ?\( ?\) ?. ?\C-y ?\C- ?\C-r ?\( ?s ?e ?l ?f ?\) return ?\C-f ?\) ?\C-r ?d ?e ?f ? return ?\C- ?\C-s ?t ?e ?s ?t ?_ return ?\C-\M-b backspace ?\M-\\ ?\C-e ?\C-n ?\C-n ?\C-b ?\C-\M-b ?_ ?s ?t ?n backspace ?a ?n ?z ?a] 0 "%d"))
(define-key my/keys-keymap "\C-\M-c" 'astroparse-mark-expected-fail-for-stanza)
;; (fset 'insert-is-proper-at-end-of-next-test
;; (kmacro-lambda-form [?\C-s ?r ?e ?s ?u ?l ?t ? ?= ? return ?\C-p ?\C-p ?\C-e return ?\' ?\[ ? ?i ?s ?_ ?p ?r ?o ?p ?e ?r ? ?y ?e ?s ?\] ?\' ?, ?\C-a ?\C-s ?\[ return] 0 "%d"))
;; (define-key my/keys-keymap "\C-\M-c" 'insert-is-proper-at-end-of-next-test)
;; (fset 'indent-preceding-list-and-add-comma
;; (kmacro-lambda-form [?\C-b ?\C-\M-b ?\C-f ?\C-j ?\C-p ?\C-e ?\C-b ?\C-\M-f ?\C-b ?, ?\C-j ?\C-f ?\C-\M-b ?\C-\M-q ?\C-\M-f] 0 "%d"))
;; (define-key my/keys-keymap "\C-\M-c" 'indent-preceding-list-and-add-comma)
(define-key my/keys-keymap (kbd "M-$") #'shell)
(define-key my/keys-keymap (kbd "M-*") #'shell)
;;; In minibuffer and isearch use shift+enter for quoted return
;;; https://stackoverflow.com/questions/19757612/how-to-redefine-a-key-inside-a-minibuffer-mode-map
;;; Never worked
;; (defun insert-quoted-return+ ()
;; (interactive)
;; (setq unread-command-events
;; (listify-key-sequence
;; (kbd "C-q C-j"))))
;; (define-key minibuffer-local-isearch-map "S-RET" 'insert-quoted-return+)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Full width comment box ;;
;; from http://irreal.org/blog/?p=374 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun bjm-comment-box (b e)
(interactive "r")
(let ((e (copy-marker e t)))
(goto-char b)
(end-of-line)
(insert-char ? (- fill-column (current-column)))
(comment-box b e 1)
(goto-char e)
(set-marker e nil)))
(define-key my/keys-keymap (kbd "C-c b b") 'bjm-comment-box)
;; Eval-region similar to eval-sexp (overwriting find-file-read-only)
(define-key my/keys-keymap (kbd "C-x C-r") 'eval-region)
;; Write a commit message in emacs. To exit, do C-c C-c. Plays well
;; with Tramp.
(define-key my/keys-keymap (kbd "C-c c") 'magit-commit-create)
;; Beginnings of conversion to the magit cult
(define-key my/keys-keymap (kbd "C-c x") 'magit-commit-extend) ; --amend --no-edit
(define-key my/keys-keymap (kbd "C-c z") 'magit-commit-amend)
(define-key my/keys-keymap (kbd "C-c r") 'magit-rebase)
(define-key my/keys-keymap (kbd "C-c d") 'magit-diff)
(define-key my/keys-keymap (kbd "C-c t") 'magit-status)
(define-key my/keys-keymap (kbd "C-c m") 'magit-status)
;; (require 'ansi-color)
;; function for colorizing
;; Confuses m-x term.
;; (defun colorize-buffer ()
;; (interactive)
;; (toggle-read-only)
;; (ansi-color-apply-on-region (point-min) (point-max))
;; (toggle-read-only))
;; (define-key my/keys-keymap (kbd "C-c o") 'colorize-buffer)
;; https://www.emacswiki.org/emacs/BuildTags#toc4
(defun create-tags (dir-name glob)
"Create tags file."
(interactive "DDirectory: \nsName glob: ")
(eshell-command
(format "find %s -type f -name \"%s\" | etags -" dir-name glob)))
;; With a list of debug statements like backend-types.log open in one
;; buffer and a whoami run.py shell in another buffer, use
;; copy-paste-whoami-input-line to format the current line's sentence
;; and subjects into the Whoami shell, and move to the next line.
;; After doing so, without moving point, use
;; investigate-whoami-input-without-subject-substitutions to submit
;; the same query without the subject substitutions.
;; (fset 'copy-paste-whoami-input-line
;; [?\C-s ?\" return ?\C- ?\C-s ?\( ?\[ return ?\C-b ?\C-b ?\C-b ?\C-b ?\M-w ?\C-x ?o ?\C-y ? ?| ?| ? ?\C-x ?o ?\C-s ?\( ?\[ return ?\C- ?\C-s ?\] ?\) return ?\C-b ?\C-b ?\M-w ?\C-x ?o ?\C-y ?\C-p ?\C-p ?\C-p ?\C-\M-% ?\' ?, ? ?\' return ?& ?& return ?! ?\C-p ?\C-p ?\C-p ?\C-\M-% ?| ?| ? ?\' return ?| ?| ? return ?! ?\M-> backspace return ?\C-x ?o ?\C-n ?\C-a])
;; (fset 'investigate-whoami-input-without-subject-substitutions
;; [?\C-x ?o ?\C-r ?| ?| ?\C-r return ?\C- ?\C-r ?> ? return ?\C-f ?\C-f ?\M-w ?\M-> ?\C-y return ?\C-x ?o])
;; (define-key my/keys-keymap (kbd "C-c C-w") 'copy-paste-whoami-input-line)
;; (define-key my/keys-keymap (kbd "C-c C-s") 'investigate-whoami-input-without-subject-substitutions)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org mode ;;
;; from https://orgmode.org/worg/org-tutorials/orgtutorial_dto.html ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Slack integration ;;
;; from https://github.com/yuya373/emacs-slack ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Slack integration
;; (use-package slack
;; :commands (slack-start)
;; :init
;; (setq slack-buffer-emojify t)
;; (setq slack-prefer-current-team t)
;; :config
;; ;; (slack-register-team
;; ;; :name "infolab-csail"
;; ;; :default t
;; ;; ;; In ~/.authinfo:
;; ;; ;; machine infolab-csail.slack.com login [email protected] password XXX
;; ;; :token (auth-source-pick-first-password
;; ;; :host "infolab-csail.slack.com"
;; ;; :user "[email protected]")
;; ;; :full-and-display-names t)
;; (slack-register-team
;; :name "stripe"
;; :default t
;; :token (auth-source-pick-first-password
;; :host "stripe.slack.com"
;; :user "[email protected]")
;; :cookie (auth-source-pick-first-password
;; :host "stripe.slack.com"
;; :user "[email protected]^cookie")
;; :full-and-display-names t
;; :subscribed-channels '(("supint-private"))))
(use-package alert
:commands (alert)
:init
(setq alert-default-style 'notifier))
;; (global-set-key (kbd "C-c s") 'slack-start)
(define-key my/keys-keymap (kbd "C-c e") 'emojify-insert-emoji)
;; (defun setup-slack-keymaps ()
;; ;; Surprise! Rebind after slack init
;; (global-set-key (kbd "C-c s") 'slack-select-rooms)
;; (define-key slack-info-mode-map "\C-x\C-v" 'slack-room-update-messages)
;; (define-key slack-mode-map "\C-x\C-v" 'slack-room-update-messages)
;; (define-key slack-mode-map "\C-x\C-k" 'slack-buffer-kill)
;; (define-key slack-mode-map "\C-c\C-a" 'slack-message-add-reaction)
;; (define-key slack-mode-map "\C-c\C-r" 'slack-message-remove-reaction)
;; (define-key slack-mode-map "\C-c\C-s" 'slack-message-show-reaction-users)
;; (define-key slack-mode-map "\C-c\C-e" 'slack-message-edit)
;; (define-key slack-mode-map "\C-c\C-d" 'slack-message-delete)
;; (define-key slack-mode-map "\C-c\C-m" 'slack-message-embed-mention)
;; (define-key slack-mode-map "\C-c\C-c" 'slack-message-embed-channel)
;; (define-key slack-mode-map "\M-n" 'slack-buffer-goto-next-message)
;; (define-key slack-mode-map "\M-p" 'slack-buffer-goto-prev-message)
;; (define-key slack-mode-map "\C-c\C-u" 'slack-file-upload)
;; (define-key slack-edit-message-mode-map "\C-c\C-k" 'slack-message-cancel-edit)
;; (define-key slack-edit-message-mode-map "\C-c\C-m" 'slack-message-embed-mention)
;; (define-key slack-edit-message-mode-map "\C-c\C-ec" 'slack-message-embed-channel)
;; (define-key slack-mode-map "\C-c\C-u" 'slack-file-upload))
;; (advice-add 'slack-start :after #'setup-slack-keymaps)
;; End common commands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stripe specific settings ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Stripe emacs
(defvar devbox-machine "qa-mydev--0f8eba3dd88a1d793.northwest.stripe.io")
(defvar stripe-username "henryhu")
(load "~/.emacs.d/stripemacs.el")
;;;;;;;;;;;; DUMB JUMP CONFIG
(setq dumb-jump-default-project "~/code/")
(setq dumb-jump-force-searcher 'rg)
(setq dumb-jump-selector 'ivy) ;use ivy instead of popup if multiple matches
(setq dumb-jump-confirm-jump-to-modified-file nil) ; warn instead of confirm
(setq dumb-jump-disable-obsolete-warnings t)
;; Uses git grep unless not a git project. (obsolete with xref)
;; (setq dumb-jump-prefer-searcher 'rg)
;; Dumb jump mode overwrites C-M-q, just name each useful command
;; instead.
(define-key my/keys-keymap (kbd "M-.") #'dumb-jump-go)
(define-key my/keys-keymap (kbd "C-M-.") #'dumb-jump-back)
;; M-? is xref-find-references
;; (define-key my/keys-keymap (kbd "C-M-.") #'dumb-jump-go-prompt)
(define-key my/keys-keymap (kbd "C-M-,") #'dumb-jump-quick-look)
;;;;;;;;;;;; END DUMB JUMP CONFIG
;; Use fd to find files by name in a local context
(define-key my/keys-keymap (kbd "C-c C-f") #'counsel-fd-file-jump)
;; Prevent projectile errors for empty submodules without .gitmodules
(setq projectile-git-submodule-command "")
;; https://www.masteringemacs.org/article/searching-buffers-occur-mode
;; Occur is useful for searching open buffers for a term dumbly. For
;; example, after a dumb jump on a remote host it's faster to go to a
;; buffer with an existing term using occur than using dumb jump
;; again. Synergizes with desktop-save-mode.
;;
;; Tip: use M-g M-n, M-g M-p to to to next/previous matches without
;; switching to occur buffer. Also, M-x occur-edit-mode (also bound
;; to e) engages the edit mode in Occur.
(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))
;; Show 2 lines of context for occur.
(setq list-matching-lines-default-context-lines 2)
(defun get-buffers-matching-mode (mode)
"Returns a list of buffers where their major-mode is equal to MODE"
(let ((buffer-mode-matches '()))
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (eq mode major-mode)
(push buf buffer-mode-matches))))
buffer-mode-matches))
;;; https://oremacs.com/2015/01/26/occur-dwim/
(defun multi-occur-in-this-mode-dwim (search-query)
"Show all lines matching REGEXP in buffers with this major mode, dwim."
(interactive
(list (if (region-active-p)
;; Take region if exists.
(buffer-substring-no-properties
(region-beginning)
(region-end))
;; Otherwise default to symbol at point.
(read-string (format "Search in open buffers of type %s: " major-mode)
(let ((sym (thing-at-point 'symbol)))
(when (stringp sym)
(regexp-quote sym)))))))
(multi-occur (get-buffers-matching-mode major-mode) search-query))
(defun multi-occur-in-all-buffers-dwim (search-query)
"Show all lines matching REGEXP in all buffers, dwim."
(interactive
(list (if (region-active-p)
;; Take region if exists.
(buffer-substring-no-properties
(region-beginning)
(region-end))
;; Otherwise default to symbol at point.
(read-string (format "Search in all open buffers: " major-mode)
(let ((sym (thing-at-point 'symbol)))
(when (stringp sym)
(regexp-quote sym)))))))
(multi-occur (buffer-list) search-query))
(defun occur-multi-occur ()
"Starts multi-occur for the current search term on all buffers with the first matching buffer's major mode."
(interactive)
(multi-occur
(get-buffers-matching-mode (with-current-buffer (car (nth 2 occur-revert-arguments)) major-mode))
(car occur-revert-arguments)))
(define-key my/keys-keymap (kbd "M-s m") 'multi-occur-in-this-mode-dwim)
(define-key my/keys-keymap (kbd "M-s a") 'multi-occur-in-all-buffers-dwim)
;; In isearch, use C-o to begin occur.
(define-key isearch-mode-map (kbd "C-o") 'multi-occur-in-this-mode)
;; In an occur buffer, use 'm' to expand search to multiple files
(define-key occur-mode-map "m" 'occur-multi-occur)
;; cycle snake_case, camelCase, etc for ruby
(require 'string-inflection)
(define-key my/keys-keymap (kbd "C-c C-u") 'string-inflection-all-cycle)
(define-key my/keys-keymap (kbd "C-c u") 'string-inflection-all-cycle)
;; ;; Kill and replace the sexp at point, ending with the last yank at
;; ;; the top of the kill ring.
(fset 'replace-sexp-at-point [134217848 114 101 112 108 tab 114 backspace 115 101 120 112 tab return])
(define-key my/keys-keymap "\C-\M-y" 'replace-sexp-at-point)
;; Kill the line at point, change buffer, rg the line, and return
(fset 'move-line-into-other-buffer
[?\C-k ?\C-k ?\C-n ?\C-p ?\C-x ?o ?r ?g ? ?\C-y return ?\C-x ?o])
(define-key my/keys-keymap "\C-c\C-r\C-g" 'move-line-into-other-buffer)
;; End Stripe specific settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; BEGIN AUTOGEN (dashboard depends on Emacs 25.3) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("78e6be576f4a526d212d5f9a8798e5706990216e9be10174e3f3b015b8662e27" "fb83a50c80de36f23aea5919e50e1bccd565ca5bb646af95729dc8c5f926cbf3" "e3a1b1fb50e3908e80514de38acbac74be2eb2777fc896e44b54ce44308e5330" "b6269b0356ed8d9ed55b0dcea10b4e13227b89fd2af4452eee19ac88297b0f99" "b02eae4d22362a941751f690032ea30c7c78d8ca8a1212fdae9eecad28a3587f" "c8b83e7692e77f3e2e46c08177b673da6e41b307805cd1982da9e2ea2e90e6d7" "24168c7e083ca0bbc87c68d3139ef39f072488703dcdd82343b8cab71c0f62a7" "e4486d0ad184fb7511e391b6ecb8c4d7e5ab29e2d33bc65403e2315dbacaa4aa" default))
'(flycheck-javascript-flow-args nil)
'(flycheck-python-pycompile-executable "python3")
'(inhibit-startup-screen t)
'(package-selected-packages
'(php-mode fzf counsel-fd fd-dired monokai-pro-theme link-hint link restart-emacs google-this nano-theme gitignore-snippets gitignore-templates helm-gitignore string-inflection inf-ruby ivy emojify counsel markdown-preview-mode sudo-edit dirvish which-key auctex protobuf-mode thrift scala-mode package ein ansi-color sly-repl-ansi-color visual-regexp-steroids diminish filladapt pretty-symbols fira-code-mode emojify-logos package+ slack alert el-get auth-source-xoauth2 spell-fu csv csv-mode jupyter git-auto-commit-mode python-docstring exec-path-from-shell scheme-complete pdf-tools gh-md markdown-toc markdown-preview-eww markdown-mode+ flymd markdown-mode coffee-mode flycheck-package browse-kill-ring dashboard rg move-text dumb-jump robe yaml-mode web-mode use-package prettier-js magit)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:height 200 :family "Menlo")))))
;; end Autogen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Python settings ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lint in python
(load "~/.emacs.d/flycheck-pycodestyle.el")
(add-hook 'python-mode-hook (lambda () (flycheck-mode 1)))
;; Python docstrings fill-paragraph conforms to community convention
(add-hook 'python-mode-hook 'python-docstring-mode)
;; Keys for indentation
(define-key my/keys-keymap (kbd "C-.") #'python-indent-shift-right)
(define-key my/keys-keymap (kbd "C-,") #'python-indent-shift-left)
;; Treat word_word or wordWord as word boundaries
(global-subword-mode 1) ;; (subword-mode 1) doesn't treat wordWord as boundary
(defun ts ()
(interactive)
(astro "ts"))
(defun ai ()
(interactive)
(astro "ai"))
(defun local ()
(interactive)
(astro "local"))
(defun dev ()
(interactive)
(astro "dev"))
(defun dev-classic ()
(interactive)
(astro "dev-classic"))
(defun dev-python ()
(interactive)
(astro "dev-python"))
(defun dev-classic-python ()
(interactive)
(astro "dev-classic-python"))
(defun astro (cmd)
(interactive "sCmd (ts/ai) (try_spacy/astroparser_interactive): ")
;; Wish I knew how to start buffer with `astro` bash cmd. That
;; would go here.
(shell (concat "*" cmd "*")))
(defun kill-process-without-killing-buffer ()
(interactive)
(delete-process (get-buffer-process (current-buffer))))
(add-to-list 'auto-mode-alist '("\\.apm\\'" . ruby-mode))
;; End Python settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Scheme settings ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Prevent shebang on infolab .scm files from interfering with scheme-mode
(defun scheme-mode-for-bash ()
(interactive)
(if (and
(> (length (buffer-string)) 53)
(string-match
"exec csi .*"
(buffer-string)))
(scheme-mode)))
(add-hook 'sh-mode-hook 'scheme-mode-for-bash)
;; Scheme autocomplete
(autoload 'scheme-smart-complete "scheme-complete" nil t)
(eval-after-load 'scheme
'(define-key scheme-mode-map "\t" 'scheme-complete-or-indent))
;; Scheme eldoc
(autoload 'scheme-get-current-symbol-info "scheme-complete" nil t)
(add-hook 'scheme-mode-hook
(lambda ()
(make-local-variable 'eldoc-documentation-function)