-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.el
940 lines (894 loc) · 50.9 KB
/
bindings.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
;; -*- mode: Emacs-Lisp -*-
;; This is bindings loaded by user.el
(setq ns-function-modifier 'hyper) ; make Fn key do Hyper
;; (setq ns-function-modifier 'hyper) ; make Fn key do Hyper
(define-key input-decode-map [?\C-m] [C-m])
(global-set-key (kbd "<f8>") 'menu-bar-open)
(global-set-key (kbd "<f10>") 'toggle-frame-maximized)
(global-set-key (kbd "M-e") 'sentence-nav-forward)
(global-set-key (kbd "<escape> M-e") 'forward-sentence)
(global-set-key (kbd "<escape> M-a") 'backward-sentence)
(global-set-key (kbd "<escape> C-e") 'end-of-line)
(global-set-key (kbd "<escape> C-a") 'beginning-of-line)
(global-set-key (kbd "C-a") 'jj/beginning-or-indentation-of-visual-line-then-back-to-indentation-whole-line)
(global-set-key (kbd "C-e") 'jj/end-of-visual-line-then-to-end-of-line)
(global-set-key (kbd "M-=") 'count-words)
(global-set-key (kbd "M-E") 'sentence-nav-forward-end)
(global-set-key (kbd "M-a") 'sentence-nav-backward)
(global-set-key (kbd "M-A") 'sentence-nav-backward-end)
(global-set-key (kbd "<C-m>") 'exchange-point-and-mark)
(global-set-key (kbd "s-h") 'help-command)
(global-set-key (kbd "s-h k") 'helpful-key)
(global-set-key (kbd "s-h s-h") 'ns-do-hide-emacs)
(global-set-key (kbd "s-H") 'ns-do-hide-others)
(global-set-key (kbd "H-h") 'ns-do-hide-others)
(global-set-key (kbd "s-l") 'async-shell-command)
(global-set-key (kbd "C-M-{") 'previous-buffer)
(global-set-key (kbd "C-M-}") 'next-buffer)
(global-set-key (kbd "s-K") 'jj/kill-current-buffer-and-window)
(global-set-key (kbd "C-s-{") 'jj/previous-user-buffer)
(global-set-key (kbd "C-s-}") 'jj/next-user-buffer)
(global-set-key (kbd "C-M-f") 'sp-forward-sexp)
(global-set-key (kbd "C-M-b") 'sp-backward-sexp)
(global-set-key (kbd "C-M-d") 'sp-down-sexp)
(global-set-key (kbd "C-M-u") 'sp-backward-up-sexp)
(global-set-key (kbd "C-x C-S-o") 'jj/delete-blank-lines)
(global-set-key (kbd "C-x M-O") 'jj/collapse-blank-lines)
(global-set-key (kbd "C-x C") 'jj/save-buffers-kill-terminal)
(global-set-key [(super ?h)] 'help-command)
(global-set-key [(control ?h)] 'delete-backward-char)
(global-set-key (kbd "M-h") 'jj/delete-backward-word)
(global-set-key (kbd "M-s [") 'mark-paragraph)
(global-set-key (kbd "M-s {") 'mark-paragraph)
(global-set-key (kbd "M-s p") 'mark-paragraph)
(define-key org-mode-map (kbd "M-s M-p") 'org-mark-element)
(define-key org-mode-map (kbd "M-s p") 'org-mark-element)
(define-key org-mode-map (kbd "M-h") 'jj/delete-backward-word)
(global-set-key (kbd "C-x 2") 'split-window-vertically)
(global-set-key (kbd "C-x 3") 'split-window-horizontally)
(global-set-key (kbd "<C-s-left>") 'shrink-window-horizontally)
(global-set-key (kbd "<C-s-right>") 'enlarge-window-horizontally)
(global-set-key (kbd "<C-s-up>") 'shrink-window)
(global-set-key (kbd "<C-s-down>") 'enlarge-window)
(global-set-key (kbd "<escape> 9") 'insert-parentheses)
(global-set-key (kbd "<escape> SPC") 'jj/insert-space-in-front)
(global-set-key (kbd "M-S-SPC") 'jj/insert-space-in-front)
(global-set-key (kbd "<escape> 4") 'jj/insert-dollar-sign)
(global-set-key (kbd "<escape> d") 'jj/insert-dollar-sign)
(global-set-key (kbd "<escape> $") 'jj/insert-double-dollar-dollar-sign)
(global-set-key (kbd "<escape> [") 'jj/insert-brackets)
(global-set-key (kbd "<escape> =") 'org-strikethrough-region-or-point)
(global-set-key (kbd "<escape> +") 'org-strikethrough-region-or-point)
(global-set-key (kbd "<escape> {") 'jj/insert-brackets-alt)
(global-set-key (kbd "<escape> ]") 'jj/insert-brackets-alt)
(global-set-key (kbd "<escape> b") 'sp-splice-sexp)
(global-set-key (kbd "<escape> 0") 'sp-splice-sexp)
(global-set-key (kbd "<escape> -") 'sp-splice-sexp)
(global-set-key (kbd "<escape> a") 'sp-beginning-of-sexp)
(global-set-key (kbd "<escape> e") 'sp-end-of-sexp)
(global-set-key (kbd "<escape> z") 'repeat)
(global-set-key (kbd "<escape> \"") 'jj/insert-double-quotes)
(global-set-key (kbd "<escape> '") 'jj/insert-single-quotes)
(global-set-key (kbd "<escape> 6") 'jj/insert-upward-v-exponential)
(global-set-key (kbd "<escape> i") 'jj/insert-upward-v-exponential)
(global-set-key (kbd "C-v") 'evil-scroll-down)
(global-set-key (kbd "M-v") 'evil-scroll-up)
(global-set-key (kbd "<escape> C-v") 'evil-scroll-page-down)
(global-set-key (kbd "<escape> M-v") 'evil-scroll-page-up)
(global-set-key (kbd "C-S-v") 'evil-scroll-page-down)
(global-set-key (kbd "M-V") 'evil-scroll-page-up)
(global-set-key (kbd "<C-S-s-down>") 'evil-scroll-line-down)
(global-set-key (kbd "<C-S-s-up>") 'evil-scroll-line-up)
(global-set-key (kbd "<S-s-down>") 'jj/evil-scroll-down-15-lines)
(global-set-key (kbd "<S-s-up>") 'jj/evil-scroll-up-15-lines)
(global-set-key (kbd "<s-down>") 'evil-scroll-line-down)
(global-set-key (kbd "<s-up>") 'evil-scroll-line-up)
(global-set-key (kbd "C-x C-s") nil)
(global-set-key (kbd "<escape> s") 'save-buffer)
(global-set-key (kbd "<escape> S") 'save-some-buffers)
(global-set-key (kbd "M-g M") 'manual-entry)
(global-set-key (kbd "M-s-m") 'iconify-or-deiconify-frame)
(global-set-key (kbd "<escape> <backspace>") 'jj/delete-backward-bracket-pair)
(global-set-key (kbd "<escape> C-d") 'jj/delete-forward-bracket-pairs)
(global-set-key (kbd "<escape> M-h") 'jj/delete-backward-bracket-pair)
(global-set-key (kbd "<escape> s-h") 'Helper-describe-bindings)
(global-set-key (kbd "C-c M-j") 'counsel-org-goto-all)
(global-set-key (kbd "M-H") 'ivy-switch-buffer)
;; (define-key org-mode-map (kbd "<C-m>") 'exchange-point-and-mark)
;; unset C- and M- digit keys
;; set here because doesn't work in use-package (think because prefix defined by me)
(bind-key "o" #'poporg-dwim comment-map)
(bind-key "j" #'poporg-dwim comment-map)
(global-set-key (kbd "s-/ s-/") 'evilnc-comment-or-uncomment-lines)
(global-set-key (kbd "s-/ /") 'comment-or-uncomment-region)
(global-set-key (kbd "s-/ r") 'comment-or-uncomment-region)
(global-set-key (kbd "s-/ R") 'whole-line-or-region-uncomment-region)
(global-set-key (kbd "s-/ l") 'whole-line-or-region-comment-region)
(global-set-key (kbd "s-/ L") 'whole-line-or-region-uncomment-region)
(global-set-key (kbd "s-/ s") 'jj/comment-or-uncomment-sexp)
(global-set-key (kbd "s-/ S") 'jj/uncomment-sexp)
(global-set-key (kbd "s-/ u") 'whole-line-or-region-uncomment-region)
(global-set-key (kbd "s-/ p") 'evilnc-comment-or-uncomment-paragraphs)
(global-set-key (kbd "s-/ g") 'evilnc-comment-or-uncomment-to-the-line)
(global-set-key (kbd "s-/ k") 'comment-kill)
(global-set-key (kbd "s-/ d") 'comment-dwim)
(global-set-key (kbd "s-/ b") 'comment-box)
;; ("s-/ j" . poporg-dwim)
;; ("s-/ o" . poporg-dwim)
(define-key lispy-mode-map (kbd "s-/ <return>") 'lispy-comment)
(define-key lispy-mode-map (kbd "s-/ ;") 'lispy-comment)
(define-key lispy-mode-map (kbd "C-a") 'jj/lispy-move-beginning-of-visual-line)
(global-set-key (kbd "C-x C-;") 'evilnc-comment-or-uncomment-lines)
;; Zoom frm bindings
;; these are used instead of text-scale-adjust because much more versatile
;; (can toggle with ctrl+u between frame and buffer zooming)
(define-key ctl-x-map [(control ?+)] 'zoom-in/out)
(define-key ctl-x-map [(control ?-)] 'zoom-in/out)
(define-key ctl-x-map [(control ?=)] 'zoom-in/out)
(define-key ctl-x-map [(control ?0)] 'zoom-in/out)
(global-set-key [C-mouse-1] 'zoom-in)
(global-set-key [C-S-mouse-1] 'zoom-out)
(global-set-key [C-down-mouse-1] nil)
(global-set-key (if (boundp 'mouse-wheel-down-event) ; Emacs 22+
(vector (list 'control
mouse-wheel-down-event))
[C-mouse-wheel]) ; Emacs 20, 21
'zoom-in)
(global-set-key (if (boundp 'mouse-wheel-down-event) ; Emacs 22+
(vector (list 'control 'meta
mouse-wheel-down-event))
[C-M-mouse-wheel]) ; Emacs 20, 21
'zoom-all-frames-in)
(when (boundp 'mouse-wheel-up-event) ; Emacs 22+
(global-set-key (vector (list 'control
mouse-wheel-up-event))
'zoom-out)
(global-set-key (vector (list 'control 'meta
mouse-wheel-up-event))
'zoom-all-frames-out))
;; Match sublime bindings and s-maps
(global-set-key (kbd "M-t") 'jj/ivy-switch-buffer-use-virtual)
(global-set-key (kbd "M-T") 'jj/ivy-switch-buffer-use-virtual-full)
(global-set-key (kbd "s-b") 'ivy-switch-buffer)
;; PROJECTILE bindings
;; TODO: modify this or the noccur-dired function to directly take the hl-todo keywords regex
(global-set-key (kbd "H-p M-o") 'noccur-project)
(global-set-key (kbd "H-p H-o") 'noccur-project)
;;;;;;;;;; Counsel
(define-key commandpalette-map (kbd "s-e") 'turn-off-evil-mode)
(define-key commandpalette-map (kbd "s-P") 'counsel-M-x)
(define-key commandpalette-map (kbd "s-p") 'counsel-M-x)
(global-set-key (kbd "C-x B") 'org-switchb)
(define-key commandpalette-map (kbd "b") 'counsel-bookmark)
(define-key commandpalette-map (kbd "B") 'counsel-bookmarked-directory)
(define-key commandpalette-map (kbd "d") 'counsel-bookmarked-directory)
(define-key commandpalette-map (kbd "P") 'winner-undo)
;; (define-key commandpalette-map (kbd "p") 'winner-undo)
(define-key commandpalette-map (kbd "N") 'winner-redo)
(define-key commandpalette-map (kbd "n") 'winner-redo)
(define-key commandpalette-map (kbd "g a") 'counsel-ag)
(define-key commandpalette-map (kbd "g p") 'counsel-pt)
(define-key commandpalette-map (kbd "g r") 'counsel-rg)
(define-key commandpalette-map (kbd "a") 'counsel-rg)
(define-key commandpalette-map (kbd "A") 'jj/counsel-rg-hidden)
(define-key commandpalette-map (kbd "f") 'jj/counsel-find-name-everything)
(define-key commandpalette-map (kbd "g f") 'counsel-git)
(define-key commandpalette-map (kbd "g g") 'counsel-git-grep)
(define-key commandpalette-map (kbd "g o") 'ivy-org-jump-to-open-headline)
(global-set-key (kbd "C-c C-S-j") 'ivy-org-jump-to-open-headline)
(define-key commandpalette-map (kbd "r") 'counsel-recentf)
(define-key commandpalette-map (kbd "l") 'jj/emacs-lock-mode)
(define-key commandpalette-map (kbd "L") 'jj/emacs-lock-mode-all)
(define-key commandpalette-map (kbd "i") 'ivy-resume)
(define-key global-map (kbd "C-S-t") 'jj/find-open-last-killed-file)
(define-key global-map (kbd "s-T") 'jj/find-open-last-killed-file)
(define-key commandpalette-map (kbd "C-q") 'jj/toggle-window-dedicated)
(global-set-key (kbd "M-g M-d") 'dumb-jump-go)
(global-set-key (kbd "M-g M-b") 'dumb-jump-back)
(define-key commandpalette-map (kbd "v") 'jj/visible-mark-mode-enable)
(define-key commandpalette-map (kbd "s-v") 'jj/visible-mark-mode-enable)
(define-key commandpalette-map (kbd "V") 'jj/global-visible-mark-mode-enable)
;; Dumb jump map bindings
(define-key dumb-jump-map (kbd "j") 'dumb-jump-go)
(define-key dumb-jump-map (kbd "i") 'dumb-jump-go-prompt)
(define-key dumb-jump-map (kbd "l") 'dumb-jump-quick-look)
(define-key dumb-jump-map (kbd "o") 'dumb-jump-go-other-window)
(define-key dumb-jump-map (kbd "c") 'dumb-jump-go-current-window)
(define-key dumb-jump-map (kbd "b") 'dumb-jump-back)
(define-key dumb-jump-map (kbd "p") 'dumb-jump-back)
(define-key dumb-jump-map (kbd "x") 'dumb-jump-go-prefer-external)
(define-key dumb-jump-map (kbd "z") 'dumb-jump-go-prefer-external-other-window)
;; Tags and Gtags and Xref jump to definitions bindings
(global-set-key (kbd "M-.") 'xref-find-definitions)
(global-set-key (kbd "s-SPC .") 'xref-find-definitions-other-window)
(global-set-key (kbd "M-g .") 'helm-gtags-dwim)
(global-set-key (kbd "M-g C-j") 'helm-gtags-select)
(global-set-key (kbd "M-g j") 'helm-gtags-select)
(global-set-key (kbd "M-g M-,") 'helm-gtags-show-stack)
(global-set-key (kbd "M-g ,") 'helm-gtags-pop-stack)
(global-set-key (kbd "M-g b") 'helm-gtags-previous-history)
(global-set-key (kbd "M-g f") 'helm-gtags-next-history)
(global-set-key (kbd "M-g M-.") 'ggtags-find-tag-dwim)
(define-key tags-jump-map (kbd "g") 'counsel-gtags-dwim)
(define-key tags-jump-map (kbd "t") 'counsel-gtags-dwim)
(define-key tags-jump-map (kbd "r") 'counsel-gtags-find-reference)
(define-key tags-jump-map (kbd "r") 'counsel-gtags-find-reference)
(define-key tags-jump-map (kbd "o") 'helm-gtags-find-tag-other-window)
(define-key tags-jump-map (kbd "i") 'helm-gtags-tags-in-this-function)
(define-key tags-jump-map (kbd "j") 'helm-gtags-select)
(define-key tags-jump-map (kbd "c") 'helm-gtags-create-tags)
(define-key tags-jump-map (kbd "u") 'helm-gtags-update-tags)
(define-key tags-jump-map (kbd "U") 'ggtags-update-tags)
(define-key tags-jump-map (kbd "d") 'counsel-gtags-find-definition)
(define-key tags-jump-map (kbd "s") 'counsel-gtags-find-symbol)
(define-key tags-jump-map (kbd "b") 'counsel-gtags-go-backward)
(define-key tags-jump-map (kbd "f") 'counsel-gtags-go-forward)
;; Window bindings
(define-prefix-command 'cp-window-map)
(define-key commandpalette-map (kbd "w") 'cp-window-map)
(define-key commandpalette-map (kbd "w l") 'jj/toggle-window-dedicated)
(define-key commandpalette-map (kbd "w K") 'jj/other-window-kill-buffer)
(define-key commandpalette-map (kbd "w q") 'jj/quit-help-windows)
(define-key commandpalette-map (kbd "w 1") 'delete-other-windows)
(define-key commandpalette-map (kbd "2") 'jj/split-window-below-and-balance)
(define-key commandpalette-map (kbd "3") 'jj/split-window-right-and-balance)
(define-key commandpalette-map (kbd "w 2") 'jj/split-window-vertically)
(define-key commandpalette-map (kbd "w b") 'balance-windows)
(define-key commandpalette-map (kbd "w 3") 'jj/split-window-horizontally)
(define-key commandpalette-map (kbd "w 4") 'jj/split-window-4-delete-others)
(define-key commandpalette-map (kbd "w 5") 'jj/split-window-4-here)
(define-key commandpalette-map (kbd "w p") 'winner-undo)
(define-key commandpalette-map (kbd "w n") 'winner-redo)
(define-key commandpalette-map (kbd "w o") 'ivy-switch-buffer-other-window)
(define-key commandpalette-map (kbd "o") 'ivy-switch-buffer-other-window)
(define-key commandpalette-map (kbd "w t") 'jj/window-split-toggle-horizontal-vertical)
(define-key commandpalette-map (kbd "w d") 'delete-window)
(define-key commandpalette-map (kbd "0") 'delete-window)
(define-key commandpalette-map (kbd "-") 'ace-delete-window)
(define-key commandpalette-map (kbd "9") 'ace-delete-window)
;; also done with two C-u's into ace-window
(define-key commandpalette-map (kbd "w D") 'ace-delete-window)
(define-key commandpalette-map (kbd "D") 'ace-delete-window)
(define-key commandpalette-map (kbd "q") 'ace-delete-window)
(define-key commandpalette-map (kbd "C-q") 'ace-delete-window)
;; also done with one C-u into ace-window
(define-key commandpalette-map (kbd "w s") 'ace-swap-window)
(define-key commandpalette-map (kbd "w c") 'jj/visual-fill-column-center-text-toggle)
(define-key commandpalette-map (kbd "w s-w") 'delete-frame)
(define-key commandpalette-map (kbd "w s-k") 'delete-frame)
(define-key commandpalette-map (kbd "w s-d") 'delete-frame)
(define-key commandpalette-map (kbd "w s-n") 'make-frame)
(define-key commandpalette-map (kbd "w s-c") 'make-frame)
(define-key commandpalette-map (kbd "k") 'kill-current-buffer)
(define-key commandpalette-map (kbd "K") 'jj/kill-protected-buffer)
(global-set-key (kbd "C-x w") 'delete-window)
;; (global-set-key (kbd "C-x W") 'delete-other-windows)
(global-set-key (kbd "C-x o") 'ace-window)
(define-key commandpalette-map (kbd "w v") 'flip-frame)
(define-key commandpalette-map (kbd "w h") 'flop-frame)
(define-key commandpalette-map (kbd "w u") 'winner-undo)
(define-key commandpalette-map (kbd "w r") 'winner-redo)
(define-prefix-command 'cp-window-transpose-map)
(define-key commandpalette-map (kbd "w f") 'cp-window-transpose-map)
(define-key commandpalette-map (kbd "w f t") 'transpose-frame)
(define-key commandpalette-map (kbd "w f v") 'flip-frame)
(define-key commandpalette-map (kbd "w f d") 'delete-frame)
(global-set-key (kbd "s-n") 'clone-frame)
(define-key commandpalette-map (kbd "w f c") 'clone-frame)
(define-key commandpalette-map (kbd "w f n") 'make-frame)
(define-key commandpalette-map (kbd "w f 2") 'flip-frame)
(define-key commandpalette-map (kbd "w f h") 'flop-frame)
(define-key commandpalette-map (kbd "w f r") 'rotate-frame)
(global-set-key (kbd "C-x K") 'jj/other-window-kill-buffer)
(global-set-key (kbd "C-c q") 'jj/quit-help-windows)
; Set same binding as in sublime to take emacs full screen c-x 1
(global-set-key (kbd "M-s-<return>") 'jj/delete-other-windows-or-winner-undo-max-pane)
(global-set-key (kbd "C-M-s-<return>") 'jj/delete-other-windows-switch-other-buffer)
;; necessary to recognize the j and k keys correctly on emacs 26.1
(when (< emacs-major-version 27)
(global-set-key (kbd "<C-s-268632074>") 'previous-window-any-frame)
(global-set-key (kbd "<C-s-268632075>") 'next-window-any-frame))
(global-set-key (kbd "C-s-j") 'previous-window-any-frame)
(global-set-key (kbd "C-s-k") 'next-window-any-frame)
(global-set-key (kbd "s-'") 'ace-window)
(global-set-key (kbd "C-M-s-6") 'make-frame)
;; Input method and key binding configuration.
(global-set-key (kbd "M-s M-s") 'jj/swiper-symbol-at-point)
(global-set-key (kbd "M-s s") 'jj/counsel-grep-or-swiper-symbol-at-point)
;; (global-set-key (kbd "M-s M-.") 'jj/swiper-symbol-at-point)
(global-set-key (kbd "M-s w") 'jj/counsel-grep-or-swiper-word-at-point)
(global-set-key (kbd "M-s j") 'jj/counsel-grep-or-swiper-region)
(global-set-key (kbd "M-s M-w") 'jj/swiper-word-at-point)
(global-set-key (kbd "M-s M-e") 'eww-search-words)
(global-set-key (kbd "M-s M-m") 'manual-entry)
(global-set-key (kbd "M-s a") 'swiper-all)
;; Uses visueal regex steroids but for regular use vr/select-replace to select the engine
(global-set-key (kbd "M-s c") 'vr/mc-mark)
(global-set-key (kbd "M-s r") 'vr/replace)
(global-set-key (kbd "M-s q") 'vr/query-replace)
(global-set-key (kbd "C-M-s") 'vr/isearch-forward)
(global-set-key (kbd "C-M-r") 'vr/isearch-backward)
(global-set-key (kbd "C-r") 'jj/swiper-region)
(global-set-key (kbd "s-o") 'helm-occur)
;; (global-set-key (kbd "C-s") 'jj/counsel-grep-or-swiper-region)
(global-set-key (kbd "C-c s") 'swiper-all)
(eval-after-load "ivy"
'(progn
(define-key swiper-map (kbd "M-s-å") 'swiper-mc)
(define-key ivy-minibuffer-map (kbd "C-M-s") #'jj/counsel-rg-ignore-tests-swiper)
(define-key ivy-minibuffer-map (kbd "C-M-r") #'jj/counsel-rg-swiper)
(define-key ivy-minibuffer-map (kbd "M-y") 'ivy-next-line)
;; (define-key ivy-minibuffer-map (kbd "M-s m") 'ivy-restrict-to-matches)
(define-key ivy-minibuffer-map (kbd "C-d") 'delete-backward-char)
(define-key ivy-minibuffer-map (kbd "C-w") 'whole-line-or-region-kill-region)
(define-key ivy-minibuffer-map (kbd "C-c <C-m>") 'ivy-call)
))
;define-key commandpalette-map
(define-prefix-command 'ctrlz-map)
(global-set-key (kbd "C-z") 'ctrlz-map)
(define-key ctrlz-map (kbd "C-x") 'ace-jump-zap-to-char-dwim)
(define-key ctrlz-map (kbd "x") 'ace-jump-zap-to-char)
(define-key ctrlz-map (kbd "C-z") 'ace-jump-zap-up-to-char-dwim)
(define-key ctrlz-map (kbd "z") 'ace-jump-zap-up-to-char)
;; (global-set-key (kbd "C-z") 'ace-jump-zap-up-to-char-dwim)
(global-set-key (kbd "M-z") 'ace-jump-zap-to-char)
(global-set-key (kbd "M-Z") 'ace-jump-zap-up-to-char)
(global-set-key (kbd "M-\\") 'cycle-spacing)
;; (global-set-key (kbd "C-S-k") 'jj/backward-kill-line) ; Ctrl+Shift+k
;; (global-set-key (kbd "M-d") 'kill-word)
;; (global-set-key (kbd "<M-backspace>") 'backward-kill-word)
;; Replace putting kill word and other things on the kill ring
;; (global-set-key (kbd "C-M-k") #'jj/forward-kill-sexp-or-dir)
;; (global-set-key (kbd "<C-M-backspace>") #'jj/backward-kill-sexp-or-dir)
;; (global-set-key (read-kbd-macro "<C-M-backspace>") 'backward-kill-sexp)
;; (global-set-key (kbd "M-s-k") 'jj/delete-whole-line)
(define-key easy-kill-base-map (kbd "C-w") 'easy-kill-region)
(define-key easy-kill-base-map (kbd "k") 'easy-kill-region)
(define-key easy-kill-base-map (kbd "K") 'easy-kill-delete-region)
(define-key easy-kill-base-map (kbd "x") 'easy-kill-delete-region)
(define-key easy-kill-base-map (kbd "o") 'easy-kill-er-expand)
(define-key easy-kill-base-map (kbd "M-w") 'easy-kill-unhighlight)
(define-key easy-kill-base-map (kbd "j") 'easy-kill-unhighlight)
(define-key easy-kill-base-map (kbd "g") 'easy-kill-unhighlight)
(define-key easy-kill-base-map (kbd "n") 'easy-kill-expand)
(define-key easy-kill-base-map (kbd "p") 'easy-kill-shrink)
(define-key easy-kill-base-map (kbd "C-M-w") 'easy-kill-append)
(define-key easy-kill-base-map (kbd "A") 'easy-kill-append)
(define-key easy-kill-base-map (kbd "i") 'easy-kill-er-unexpand)
(define-key easy-kill-base-map (kbd "<backspace>") 'easy-kill-delete-region)
(define-key easy-kill-base-map (kbd "m") 'easy-kill-mark-region)
(define-key easy-kill-base-map (kbd "<C-m>") 'easy-kill-mark-region)
(global-set-key (kbd "<C-M-s-backspace>") 'whole-line-or-region-kill-region)
(global-set-key (kbd "C-M-k") 'jj/delete-sexp)
(global-set-key (kbd "M-K") 'kill-sexp)
(global-set-key (kbd "<escape> C-k") 'jj/kill-line)
(global-set-key (kbd "M-k") 'kill-sentence)
;; (global-set-key (kbd "<escape> M-k") 'kill-sentence)
(global-set-key (kbd "<escape> M-w") 'jj/kill-line-save)
(global-set-key (kbd "<escape> w") 'jj/kill-line-save)
(global-set-key (kbd "<escape> l") 'jj/kill-line)
(global-set-key (kbd "<escape> k") 'sp-kill-sexp)
(global-set-key (kbd "<escape> d") (lambda () (interactive) (sp-kill-sexp '(16))))
(global-set-key (kbd "<escape> M-k") (lambda () (interactive) (sp-kill-sexp '(16))))
(global-set-key (kbd "<escape> C-M-d") (lambda () (interactive) (sp-kill-sexp '(16))))
(global-set-key (kbd "<escape> K") (lambda () (interactive) (sp-kill-sexp 0)))
(global-set-key (kbd "<escape> C-M-k") 'kill-sexp)
(global-set-key (kbd "<escape> M-d") 'kill-word)
(global-set-key (kbd "<escape> <C-M-backspace>") 'backward-kill-sexp)
(global-set-key (kbd "<escape> M-t") 'hl-todo-occur)
(global-set-key (kbd "<escape> M-n") 'hl-todo-next)
(global-set-key (kbd "<escape> M-p") 'hl-todo-previous)
(global-set-key (kbd "<escape> t") 'hl-todo-occur)
(global-set-key (kbd "<escape> C-t") 'doom/ivy-tasks)
(global-set-key (kbd "<escape> T") 'hl-todo-insert-keyword)
(global-set-key (kbd "<C-s-backspace>") 'backward-kill-sexp)
(global-set-key (kbd "<escape> <C-backspace>") 'backward-kill-word)
(global-set-key (kbd "<escape> M-DEL") 'backward-kill-word)
(global-set-key (kbd "C-S-k") 'jj/delete-line) ; Ctrl+Shift+k
(global-set-key (read-kbd-macro "<s-backspace>") 'jj/delete-line-backward)
(global-set-key (read-kbd-macro "<escape> <s-backspace>") 'jj/kill-line-backward)
(global-set-key (kbd "M-d") 'jj/delete-word)
(global-set-key (kbd "<M-backspace>") 'jj/delete-backward-word)
;; (global-set-key (kbd "C-k") 'jj/delete-line)
(global-set-key (kbd "C-M-k") 'jj/delete-forward-sexp-or-dir)
(global-set-key (kbd "<C-M-backspace>") 'jj/delete-backward-sexp-or-dir)
(global-set-key (kbd "s-D") 'jj/duplicate-line-or-region)
(global-set-key (kbd "C-c d") 'jj/duplicate-line-or-region)
; (global-set-key (read-kbd-macro "<C-x j>") 'ess/org-show-just-me)
(define-key org-mode-map (kbd "C-x n o") 'jj/org-show-just-me)
(define-key org-mode-map (kbd "C-x n <tab>") 'jj/org-show-just-me)
(define-key text-mode-map (kbd "M-+") 'count-words)
(eval-after-load "tex"
'(progn
(define-key TeX-mode-map (kbd "M-+") 'count-words)))
(define-key org-mode-map (kbd "C-a") 'jj/org-beginning-of-line)
(define-key org-mode-map (kbd "C-e") 'jj/org-end-of-line)
(define-key org-mode-map (kbd "M-e") 'forward-sentence)
(define-key org-mode-map (kbd "M-E") 'jj/org-next-item-at-ident)
(define-key org-mode-map (kbd "M-a") 'backward-sentence)
(define-key org-mode-map (kbd "M-A") 'jj/org-previous-item-at-ident)
(define-key org-mode-map (kbd "C-M-e") 'jj/org-next-item-at-ident)
(define-key org-mode-map (kbd "C-M-a") 'jj/org-previous-item-at-ident)
;; (define-key org-mode-map (kbd "M-}") 'jj/org-forward-element-at-ident)
;; (define-key org-mode-map (kbd "M-{") 'jj/org-backward-element-at-ident)
(define-key org-mode-map (kbd "M-}") 'org-forward-element)
(define-key org-mode-map (kbd "M-{") 'org-backward-element)
(define-key org-mode-map (kbd "C-c k") 'org-metaright)
(define-key org-mode-map (kbd "C-c K") 'org-metaleft)
(define-key org-mode-map (kbd "C-c b k") 'org-metaright)
(define-key org-mode-map (kbd "C-c b j") 'org-metaleft)
(define-key org-agenda-mode-map (kbd "C-c C-S-j") 'ivy-org-jump-to-open-headline)
(define-key org-agenda-mode-map (kbd "C-c C-j") 'ivy-org-jump-to-open-headline)
(define-key org-agenda-mode-map (kbd "C-c M-j") 'counsel-org-goto-all)
(define-key org-agenda-mode-map (kbd "C-c j") 'counsel-org-goto-all)
(define-key org-agenda-mode-map (kbd "C-c J") 'ivy-org-jump-to-heading-in-directory)
(define-key org-agenda-mode-map (kbd "C-c R") 'jj/org-agenda-clockreport-mode-off)
(define-key org-agenda-mode-map (kbd "<escape> R") 'jj/org-agenda-clockreport-mode-off)
(define-key org-mode-map (kbd "C-c C-S-j") 'ivy-org-jump-to-open-headline)
(define-key org-mode-map (kbd "C-c C-j") 'ivy-org-jump-to-heading)
(define-key org-mode-map (kbd "C-c M-j") 'counsel-org-goto-all)
(define-key org-mode-map (kbd "C-c j") 'counsel-org-goto)
(define-key org-mode-map (kbd "C-c J") 'ivy-org-jump-to-heading-in-directory)
;(define-key org-mode-map (kbd "C-c i") 'org-do-demote)
;(define-key org-mode-map (kbd "C-c u") 'org-do-promote) 'org-indent-item 'org-outdent-item
;; (define-key org-mode-map (kbd "C-c i") 'org-shiftmetaright)
;; (define-key org-mode-map (kbd "C-c u") 'org-shiftmetaleft)
(define-key org-mode-map (kbd "C-c C-S-k") 'org-shiftmetaright)
(define-key org-mode-map (kbd "C-c C-S-j") 'org-shiftmetaleft)
(define-key org-mode-map (kbd "M-=") 'org-ctrl-c-minus)
(define-key org-mode-map (kbd "s-B") 'org-bold-region-or-point)
(define-key org-mode-map (kbd "s-I") 'org-italics-region-or-point)
(define-key org-mode-map (kbd "s-V") 'org-verbatim-region-or-point)
(define-key org-mode-map (kbd "s-C") 'org-code-region-or-point)
(define-key org-mode-map (kbd "<escape> ~") 'org-code-region-or-point)
(define-key org-mode-map (kbd "s-M") 'org-latex-math-region-or-point)
(define-key org-mode-map (kbd "C-c n") 'jj/org-move-headline-next-top-level)
(define-key org-mode-map (kbd "C-c m") 'jj/org-move-headline-next-second-level)
(define-key org-mode-map (kbd "C-c b b") 'jj/org-metaleft-next-line-previous-item)
(define-key org-mode-map (kbd "C-c b n") 'jj/org-metaleft-next-line-beginning-item)
(eval-after-load "latex"
'(progn
(define-key LaTeX-mode-map (kbd "M-e") 'forward-sentence)
(define-key LaTeX-mode-map (kbd "M-a") 'backward-sentence)
(define-key LaTeX-mode-map (kbd "C-c ~") 'jj/TeX-command-run-all-auto-save)
(define-key LaTeX-mode-map (kbd "C-c b") 'jj/TeX-LaTeX-auctex-latexmk-compile-view)
(define-key LaTeX-mode-map (kbd "C-c B") 'jj/TeX-LaTeX-auctex-xelatexmk-compile-view)
(define-key LaTeX-mode-map (kbd "C-c M-b") 'jj/TeX-LaTeX-auctex-lualatex-compile-view)
(define-key LaTeX-mode-map (kbd "C-c s-b") 'jj/TeX-LaTeX-auctex-latexmk-compile-view)
(define-key LaTeX-mode-map (kbd "<escape> B") 'jj/TeX-LaTeX-auctex-latexmk-compile-view)
(define-key LaTeX-mode-map (kbd "<escape> C-b") 'jj/TeX-LaTeX-auctex-latexmk-compile-view)
(define-key LaTeX-mode-map (kbd "<escape> C-B") 'jj/TeX-LaTeX-auctex-xelatexmk-compile-view)
(define-key LaTeX-mode-map (kbd "<escape> s-b") 'jj/TeX-LaTeX-auctex-latexmk-compile-view)
(define-key LaTeX-mode-map (kbd "C-c V") 'pdf-sync-forward-search)
(define-key LaTeX-mode-map (kbd "<escape> V") 'pdf-sync-forward-search)
(define-key LaTeX-mode-map (kbd "<escape> s-v") 'pdf-sync-forward-search)
(define-key LaTeX-mode-map (kbd "C-c j") 'counsel-semantic-or-imenu)
))
;; Moved into orgtbl-mode-hook
;; (define-key org-mode-map (kbd S-TAB") 'org-table-previous-field)
(add-hook 'orgtbl-mode-hook
(lambda ()
(define-key orgtbl-mode-map (kbd "S-TAB") 'org-table-previous-field)
(define-key orgtbl-mode-map (kbd "M-C-n") 'org-table-next-field)
(define-key orgtbl-mode-map (kbd "M-C-p") 'org-table-previous-field)
))
; First is Old binding if ; not set to return
(global-set-key (kbd "C-;") 'dabbrev-expand)
(global-set-key (kbd "s-RET") 'dabbrev-expand)
(global-set-key (kbd "s-<return>") 'dabbrev-expand)
;; Possibly change later so j goes to a menu doing counsel commands
(define-key lisp-mode-map (kbd "C-c C-j") 'counsel-imenu)
(define-key lisp-mode-map (kbd "C-c j") 'lispy-goto)
(define-key emacs-lisp-mode-map (kbd "C-c C-j") 'counsel-imenu)
(define-key emacs-lisp-mode-map (kbd "C-c j") 'lispy-goto)
(define-key python-mode-map (kbd "C-c C-j") 'counsel-imenu)
(define-key python-mode-map (kbd "C-c j") 'counsel-semantic-or-imenu)
(global-set-key (kbd "C-x C-r") 'jj/find-alternative-file-with-sudo)
(define-key python-mode-map (kbd "C-c b") 'python-black-buffer)
(define-key python-mode-map (kbd "C-c B") 'python-black-statement)
(define-key python-mode-map (kbd "C-c M-b") 'python-black-on-save-mode)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-S-s-e") 'mc/edit-lines)
(global-set-key (kbd "C-S-s-n") 'mc/mark-next-like-this)
(global-set-key (kbd "C-S-s-p") 'mc/mark-previous-like-this)
(define-key mc/keymap (kbd "<return>") nil)
(define-key mc/keymap (kbd "C-S-s-l") 'mc/unmark-next-like-this)
(define-key mc/keymap (kbd "C-S-s-h") 'mc/unmark-previous-like-this)
(define-key mc/keymap (kbd "C-S-s-j") 'mc/skip-to-previous-like-this)
(define-key mc/keymap (kbd "C-S-s-k") 'mc/skip-to-next-like-this)
(global-unset-key (kbd "C-S-<down-mouse-1>"))
(global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
;; Could make this to be a local key map
(global-set-key (kbd "M-s-a") 'mc/mark-all-like-this)
(global-set-key (kbd "M-s-å") 'mc/mark-all-like-this)
(global-set-key (kbd "C-x r 1") 'rectangle-number-lines)
;; Backup commands
(define-key mc/keymap (kbd "M-s n") 'mc/insert-numbers)
(define-key mc/keymap (kbd "M-s l") 'mc/insert-letters)
;; (define-key mc/keymap (kbd "m-s m-d") 'mc/mark-next-like-this)
;; (define-key mc/keymap (kbd "m-s m-d") 'mc/mark-next-like-this)
;; (define-key mc/keymap (kbd "m-s m-r") 'mc/mark-previous-like-this)
;; (define-key mc/keymap (kbd "m-s m-n") 'mc/unmark-next-like-this)
;; (define-key mc/keymap (kbd "m-s m-p") 'mc/unmark-previous-like-this)
;; (define-key mc/keymap (kbd "M-s M-s") 'mc/skip-to-next-like-this)
(global-set-key (kbd "S-s-SPC") 'er/expand-region)
(global-set-key (kbd "s-+") 'er/expand-region)
(global-set-key (kbd "s-_") 'er/contract-region)
(global-set-key (kbd "s-)") (lambda () (interactive) (er/expand-region 0)))
(global-set-key (kbd "C-~") 'tmm-menubar)
;; Setup copy and paste for s-c and s-v
(define-key org-mode-map (kbd "s-v") 'org-yank)
(global-set-key (kbd "s-v") 'yank)
(global-set-key (kbd "s-c") 'kill-ring-save)
(setq bmkp-jump-map-prefix-keys (list (kbd "s-p j")))
(setq bmkp-bookmark-map-prefix-keys (list (kbd "s-p p")))
(setq bmkp-jump-other-window-map-prefix-keys (list (kbd "s-p 4 j")))
;; (bmkp-set-map-prefix-key 'bmkp-jump-map-prefix-keys (list (kbd "s-p j")))
;; For avy which is similar to ace-jump
(define-prefix-command 'avy-jump-map)
(global-set-key (kbd "C-x j") 'avy-jump-map)
(global-set-key (kbd "C-x j l") 'avy-goto-line)
(global-set-key (kbd "C-x j p") 'avy-jump-to-paragraph)
(global-set-key (kbd "C-x j s") 'avy-jump-to-sentence)
(global-set-key (kbd "C-x j w") 'avy-jump-to-word-in-line)
(global-set-key (kbd "C-x j C-a") 'avy-goto-line)
(global-set-key (kbd "C-x j e") 'avy-goto-end-of-line)
(global-set-key (kbd "C-x j c") 'avy-goto-word-1)
(global-set-key (kbd "C-x j 2") 'avy-goto-char-2)
(global-set-key (kbd "C-x j C-e") 'avy-goto-end-of-line)
(global-set-key (kbd "C-x j t") 'avy-goto-char-timer)
(global-set-key (kbd "s-.") 'avy-goto-char-timer)
(global-set-key (kbd "C-q") 'repeat)
(global-set-key (kbd "C-S-q") 'quoted-insert)
(define-key spacebar-map (kbd "r") 'repeat)
(define-key spacebar-map (kbd "w") 'jj/weather-default-wttrin)
(define-key spacebar-map (kbd "W") 'jj/weather-wttrin)
(define-key spacebar-map (kbd "n") 'jj/new-empty-buffer)
(define-key spacebar-map (kbd "j") 'org-mark-ring-goto)
(define-key spacebar-map (kbd "p") 'org-mark-ring-push)
(define-key spacebar-map (kbd "d") 'org-capture)
(define-key spacebar-map (kbd "b") 'python-black-buffer)
(define-key spacebar-map (kbd "B") 'python-black-statement)
(define-key spacebar-map (kbd "s-b") 'python-black-on-save-mode)
(define-key spacebar-map (kbd "M-b") 'python-black-on-save-mode)
(define-key spacebar-map (kbd "C-SPC") 'org-mark-ring-push)
(define-key org-mode-map (kbd "C-x j h") 'ivy-org-jump-to-visible-headline)
(define-key org-mode-map (kbd "s-,") 'ivy-org-jump-to-visible-headline)
;; expand region overwrites the below hot key so added
(define-key org-mode-map (kbd "C-c g") 'org-mark-ring-goto)
(define-key org-mode-map (kbd "<C-M-return>") 'org-insert-heading-respect-content)
(define-key org-mode-map (kbd "<escape> <M-RET>") 'org-insert-todo-heading)
(define-key org-mode-map (kbd "<escape> <s-return>") 'org-insert-todo-heading-respect-content-top-priority)
(define-key org-mode-map (kbd "<C-M-S-return>") 'org-insert-todo-heading-respect-content-top-priority)
(define-key org-mode-map (kbd "<C-s-return>") 'org-insert-heading-after-current)
(define-key org-mode-map (kbd "<escape> <C-M-return>") 'jj/org-insert-heading-respect-content-and-delete-current-line)
(define-key org-mode-map (kbd "<escape> <return>") 'org-insert-heading)
(define-key org-mode-map (kbd "<escape> t") 'jj/org-show-todo-tree-then-remove-occur-highlights)
(define-key org-mode-map (kbd "<escape> o") 'org-occur)
(define-key org-mode-map (kbd "<escape> O") 'org-remove-occur-highlights)
(define-key org-mode-map (kbd "C-c C-g") 'org-mark-ring-goto)
(define-key dired-h-prefix-map (kbd "P") 'jj/dired-up-directory-follow-symlink-up)
(define-key dired-h-prefix-map (kbd "^") 'jj/dired-up-directory-follow-symlink-up)
;; (define-key dired-h-prefix-map (kbd "p") 'jj/dired-up-directory-follow-symlink-up)
(define-key dired-h-prefix-map (kbd "f") 'jj/dired-find-file-following-symlinks)
(define-key dired-h-prefix-map (kbd "a") 'jj/dired-find-alternate-file-following-symlinks)
(define-key dired-h-prefix-map (kbd "]") 'jj/dired-find-alternate-file-following-symlinks)
(define-key dired-h-prefix-map (kbd "v") 'jj/dired-view-file-following-symlinks)
(define-key dired-h-prefix-map (kbd "r") 'jj/dired-sort-toggle-reverse-switch)
(define-key dired-h-prefix-map (kbd "w") 'jj/dired-sort-add-classify-switch)
(define-key dired-h-prefix-map (kbd "W") 'jj/dired-sort-remove-classify-switch)
(define-key dired-h-prefix-map (kbd "s") 'jj/dired-cycle-switches)
(define-key dired-h-prefix-map (kbd "S") 'jj/dired-sort-by-size-switch-toggle)
(define-key dired-h-prefix-map (kbd "M-s") 'jj/dired-sort-choose)
(define-key dired-h-prefix-map (kbd "V") 'jj/dired-do-version)
(define-key dired-h-prefix-map (kbd "c") 'jj/dired-create-file-blank)
(define-key dired-h-prefix-map (kbd "C") 'jj/dired-create-file)
(define-key dired-h-prefix-map (kbd ",") 'beginning-of-buffer)
(define-key dired-h-prefix-map (kbd ".") 'end-of-buffer)
(define-key dired-h-prefix-map (kbd "p") 'peep-dired)
(define-key dired-h-prefix-map (kbd "m") 'dired-do-chmod)
(define-key dired-h-prefix-map (kbd "H") 'dired-do-hardlink)
(define-key dired-h-prefix-map (kbd "t") 'jj/dired-sort-by-time-switch-toggle)
(define-key dired-h-prefix-map (kbd "RET") 'jj/dired-advertised-find-file-following-symlinks)
(define-prefix-command 'dired-question-prefix-map)
(define-key dired-mode-map (kbd "1") 'beginning-of-buffer)
(define-key dired-mode-map (kbd "2") 'end-of-buffer)
(define-key dired-mode-map (kbd "3") 'jj/dired-beginning-of-subdir)
(define-key dired-mode-map (kbd "C-M-n") 'jj/dired-next-subdir)
(define-key dired-mode-map (kbd "C-M-p") 'jj/dired-prev-subdir)
(define-key dired-mode-map (kbd "M-n") 'jj/dired-next-subdir)
(define-key dired-mode-map (kbd "M-p") 'jj/dired-prev-subdir)
(define-key dired-mode-map (kbd "M-N") 'jj/dired-next-subdir)
(define-key dired-mode-map (kbd "M-P") 'jj/dired-prev-subdir)
(define-key dired-mode-map (kbd "C-M-u") 'jj/dired-tree-up)
(define-key dired-mode-map (kbd "C-M-d") 'jj/dired-tree-down)
(define-key dired-mode-map (kbd "M-#") 'jj/dired-hide-all-but-this-dir)
(define-key dired-mode-map (kbd "?") 'dired-question-prefix-map)
(define-key dired-mode-map (kbd "_") 'jj/dired-rename-space-to-underscore)
;; (define-key dired-mode-map (kbd "-") 'jj/dired-rename-space-to-hyphen)
(define-key dired-mode-map (kbd "<escape> -") 'jj/dired-rename-space-to-hyphen)
(define-key dired-mode-map (kbd "Q") 'jj/quit-window-kill)
(define-key help-mode-map (kbd "Q") 'jj/quit-window-kill)
(define-key image-mode-map (kbd "Q") 'jj/quit-window-kill)
(define-key dired-mode-map (kbd "X") 'dired-do-async-shell-command)
(define-key dired-mode-map (kbd "r") 'dired-toggle-read-only)
(define-key dired-mode-map (kbd "9") 'jj/dired-rename-hyphen-to-underscore)
(define-key dired-mode-map (kbd "0") 'jj/dired-rename-underscore-to-hyphen)
(define-key dired-mode-map (kbd "8") 'jj/dired-rename-hyphen-or-underscore-to-space)
(define-key dired-mode-map (kbd "C-S-SPC") 'jj/dired-rename-hyphen-or-underscore-to-space)
(define-key dired-question-prefix-map (kbd "?") 'dired-summary)
(define-key dired-mode-map (kbd "C-c M-o") 'dired-omit-switch)
(define-key dired-mode-map (kbd "C-c m") 'dired-do-chmod)
(define-key dired-mode-map (kbd "H") 'dired-do-chmod)
(define-key dired-mode-map (kbd "h O") 'dired-omit-switch)
(define-key dired-mode-map (kbd "h o") 'dired-omit-mode)
(define-key dired-mode-map (kbd "h 0") 'noccur-dired)
(global-set-key (kbd "C-c t") 'jj/open-iterm-terminal-here)
;; (add-hook 'dired-mode-hook (lambda () (dired-omit-mode 1)))
(eval-after-load "wdired"
'(progn
(define-key wdired-mode-map (kbd "<escape> C-g") 'wdired-abort-changes)
))
(define-prefix-command 'jj-flyspell-mode-map)
(global-set-key (kbd "M-s f") 'jj-flyspell-mode-map)
(eval-after-load "flyspell"
'(progn
(define-key flyspell-mode-map (kbd "s-RET") 'dabbrev-expand)
;; (define-key flyspell-mode-map (kbd "M-p") 'flyspell-auto-correct-previous-word)
(define-key flyspell-mode-map (kbd "C-.") 'flyspell-auto-correct-previous-word)
(define-key flyspell-mode-map (kbd "C-M-i") 'flyspell-correct-wrapper)
(define-key flyspell-mode-map (kbd "M-s f a") 'jj/ispell-append-current-and-sort)
(define-key flyspell-mode-map (kbd "M-s f w") 'ispell-word)
(define-key flyspell-mode-map (kbd "M-s f i") 'ispell)
(define-key flyspell-mode-map (kbd "M-s f p") 'flyspell-auto-correct-previous-word)
(define-key flyspell-mode-map (kbd "M-s f f") 'flyspell-correct-previous-word)
))
;; Archive-mode is arc-mode
(eval-after-load "arc-mode"
'(progn
(define-key archive-mode-map (kbd "U") 'archive-unmark-all-files)
(define-key archive-mode-map (kbd "<M-backspace>") 'archive-unmark-all-files)))
(eval-after-load "elpy"
'(progn
(define-key elpy-mode-map (kbd "C-c C-c") 'elpy-shell-send-region-or-buffer)
(add-hook 'elpy-mode-hook
(lambda ()
(define-key indent-rigidly-map (kbd "J") 'elpy-nav-indent-shift-left)
(define-key indent-rigidly-map (kbd "K") 'elpy-nav-indent-shift-right)
))
))
(eval-after-load "dired+"
'(progn
;; Think this can be replaced with browse-url-of-dired-file
;; (define-key dired-mode-map (kbd "z") 'browse-url-of-dired-file)
(define-key dired-mode-map (kbd "z")
(lambda () (interactive)
(let ((fn (dired-get-file-for-visit)))
(start-process "default-app" nil "open" fn))))
(define-key dired-mode-map (kbd "V")
(lambda () (interactive)
(let ((fn (dired-get-file-for-visit)))
(start-process "default-app" nil "open" "-g" fn))))
(define-key dired-mode-map (kbd "p") 'jj/dired-previous-line)
(define-key dired-mode-map (kbd "n") 'jj/dired-next-line)
;; (define-key dired-mode-map (kbd "C-p") 'jj/diredp-previous-line)
;; (define-key dired-mode-map (kbd "C-n") 'jj/diredp-next-line)
(define-key dired-mode-map (kbd "h z") 'diredp-compress-this-file)
(define-key dired-mode-map (kbd "h Z") 'jj/dired-do-compress-marked-files-to-zip)
(define-key dired-mode-map (kbd "C-c C-o") 'jj/show-in-path-finder)
(define-key dired-mode-map (kbd "P") 'dired-up-directory)
(define-key dired-mode-map (kbd "<M-backspace>") 'dired-unmark-all-files)
(define-key dired-mode-map (kbd "N") 'dired-view-file)
(define-key dired-mode-map (kbd "U") 'dired-unmark-all-marks)
(define-key dired-mode-map (kbd "[") 'jj/dired-go-up-directory-same-buffer)
(define-key dired-mode-map (kbd "]") 'dired-find-alternate-file)
(define-key dired-mode-map (kbd "RET") 'dired-advertised-find-file)
(define-key dired-mode-map (kbd "C-M-s-4") 'dired-kill-subdir)
(define-key dired-mode-map (kbd "'") 'jj/dired-kill-subdir)
(define-key dired-mode-map (kbd "\"") 'jj/dired-kill-tree)
(define-key dired-mode-map (kbd "_") 'jj/dired-rename-space-to-underscore)
(define-key dired-mode-map (kbd "-") 'scimax-dired-cycle-space-hyphen-underscore)
(define-key dired-mode-map (kbd "c") 'counsel-find-file)
(define-key dired-mode-map (kbd "C") 'dired-do-copy)
(define-key dired-mode-map (kbd "C-S-c") 'dired-async-do-copy)
(define-key dired-mode-map (kbd "K") 'jj/dired-kill-subdir-pop-mark)
(define-key dired-mode-map (kbd "h e") 'jj/counsel-find-name-everything)
;; if you are using ido,you'd better disable ido for dired
;; (define-key (cdr ido-minor-mode-map-entry) [remap dired] nil) ;in ido-setup-hook
;; Possibly change this to counsel-bookmark
(define-key dired-mode-map "b" 'counsel-bookmarked-directory)
(define-key dired-mode-map "B" 'counsel-bookmark)
(define-key dired-mode-map "<" 'dired)
(define-key dired-mode-map "\M-b" nil)
(define-key dired-mode-map "\C-\M-b" nil)
(define-key dired-mode-map (kbd "e") 'dired-copy-filename-as-kill)
;; FIXME Remove unused bindings
(define-key dired-mode-map (kbd "W") 'jj/dired-copy-filename-as-kill-absolute-path)
(define-key dired-mode-map (kbd "E") 'dired-toggle-read-only)
(define-key dired-mode-map (kbd ": w") 'jj/dired-copy-filename-as-kill-absolute-path)
(define-key dired-mode-map (kbd "/ t") 'dired-filter-mode)
(define-key dired-mode-map (kbd "/ O") 'dired-filter-mode)
(eval-after-load "dired-ranger"
'(progn
(define-key dired-mode-map (kbd "w") 'dired-ranger-copy)
;; (define-key dired-mode-map (kbd "E") 'dired-ranger-move)
(define-key dired-mode-map (kbd "h D") 'jj/dired-ranger-reset-copy-ring)
(define-key dired-mode-map (kbd "h b") 'dired-ranger-bookmark)
(define-key dired-mode-map (kbd "A") 'dired-ranger-bookmark)
(define-key dired-mode-map (kbd "a") 'dired-ranger-bookmark-visit)
(define-key dired-mode-map (kbd "M") 'dired-ranger-move)
;; Originally dired-do-chmod mapped to M
;; (define-key dired-mode-map (kbd "M") 'dired-do-chmod)
(define-key dired-mode-map (kbd "Y") 'dired-ranger-paste)))
(define-key dired-mode-map (kbd "M-i") 'diredp-dired-this-subdir)
(define-key dired-mode-map (kbd "M-I") 'diredp-insert-subdirs)
(define-key dired-mode-map (kbd "M-I") 'jj/dired-copy-filename-as-kill-absolute-path)
(defvar dired-narrow-filter-map
(let ((map (make-sparse-keymap)))
(define-key map "," 'dired-narrow)
(define-key map "r" 'dired-narrow-regexp)
(define-key map "f" 'dired-narrow-fuzzy)
map)
"Keymap used for filtering files.")
(define-key dired-mode-map (kbd ",") dired-narrow-filter-map)
))
;; (define-key global-map "\C-xfg" 'find-grep-dired)
;; (define-key global-map "\C-xfn" 'find-name-dired)
(define-key global-map "\C-xff" 'jj/counsel-find-name-everything)
(define-key global-map "\C-xfe" 'jj/counsel-find-name-everything)
;; (define-key global-map "\C-xfd" 'find-dired)
(define-key global-map (kbd "\C-xfa") 'counsel-ag)
(define-key global-map (kbd "\C-xfA") 'jj/counsel-ag-hidden)
(define-key global-map (kbd "\C-xfp") 'counsel-pt)
(define-key global-map (kbd "\C-xfr") 'counsel-rg)
(define-key global-map (kbd "\C-xfR") 'jj/counsel-rg-hidden)
(define-key global-map (kbd "\C-xf\C-r") 'jj/find-file-root)
(define-key global-map (kbd "\C-xfr") 'counsel-rg)
(define-key global-map (kbd "\C-xfh") 'counsel-git)
(define-key global-map (kbd "\C-xfg") 'counsel-git-grep)
(define-key global-map (kbd "\C-xf\C-f") 'counsel-git)
(define-key global-map (kbd "\C-xf\C-g") 'counsel-git-grep)
(define-key global-map (kbd "C-x f M-r") 'helm-rg)
(define-key global-map (kbd "C-x f M-a") 'helm-ag)
(define-key global-map (kbd "C-x f M-g") 'helm-grep-do-git-grep)
(define-key global-map (kbd "C-x f M-f") 'helm-find-files)
(define-key global-map (kbd "C-x f M-p") 'helm-projectile)
(define-key global-map (kbd "C-x f M-A") 'helm-projectile-ag)
(define-key global-map (kbd "C-x f M-R") 'helm-projectile-rg)
(define-key global-map (kbd "C-x f M-G") 'helm-projectile-grep)
(define-key global-map (kbd "\C-xfo") 'ivy-org-jump-to-open-headline)
(define-key global-map "\C-xg" 'magit-status)
;; (define-key global-map "\C-xg" 'jj/counsel-find-name-everything)
(eval-after-load "wgrep"
'(progn
(define-key wgrep-mode-map (kbd "C-c C-s") 'jj/wgrep-finish-edit-save-all-buffers)
))
(global-set-key (kbd "C-x C-d") 'jj/ivy-dired-recent-dirs)
(global-set-key (kbd "C-x s-d") 'list-directory)
(global-set-key (kbd "C-s-<tab>") 'jj/switch-to-previous-buffer)
(global-set-key (kbd "<escape> <tab>") 'switch-to-prev-buffer)
(global-set-key (kbd "s-p <tab>") 'switch-to-prev-buffer)
(global-set-key (kbd "C-S-<tab>") 'switch-to-prev-buffer)
(define-key process-menu-mode-map (kbd "C-k") 'jj/delete-kill-process-at-point)
(global-set-key (kbd "C-M-s-9") 'jj/goto-last-change-across-buffers)
;; (global-set-key (kbd "M-[") 'nice-jumper/backward)
;; (global-set-key (kbd "M-]") 'nice-jumper/forward)
(global-set-key (kbd "C-(") 'back-button-global-backward)
(global-set-key (kbd "C-)") 'back-button-global-forward)
(global-set-key (kbd "s-[") 'back-button-local-backward)
(global-set-key (kbd "s-]") 'back-button-local-forward)
(global-set-key [remap kill-ring-save] 'easy-kill)
(global-set-key [remap mark-sexp] 'easy-mark)
(global-set-key (kbd "M-@") 'easy-mark)
(define-key google-this-mode-submap "T" #'jj/google-this-background)
(define-key google-this-mode-submap "N" #'jj/google-this-noconfirm-background)
(define-key google-this-mode-submap "b" #'jj/google-this-noconfirm-background)
(define-key google-this-mode-submap "W" #'jj/google-this-word-background)
(define-key google-this-mode-submap "F" #'jj/google-this-forecast-background)
(define-key jj-eyebrowse-wg-map (kbd "C") 'wg-create-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "Y") 'wg-clone-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "R") 'wg-rename-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "M") 'jj/wg-workgroups-mode-switch)
(define-key jj-eyebrowse-wg-map (kbd "A") 'jj/wg-workgroups-mode-switch)
(define-key jj-eyebrowse-wg-map (kbd "B") 'wg-switch-to-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "K") 'wg-kill-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "S") 'wg-switch-to-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "P") 'wg-switch-to-previous-workgroup)
(define-key jj-eyebrowse-wg-map (kbd "<") 'wg-switch-to-workgroup-left)
(define-key jj-eyebrowse-wg-map (kbd ">") 'wg-switch-to-workgroup-right)
(define-key jj-eyebrowse-wg-map (kbd "C-d") 'desktop-change-dir)
(define-key jj-eyebrowse-wg-map (kbd "C-k") 'desktop-clear)
(define-key jj-eyebrowse-wg-map (kbd "C-K") 'desktop-remove)
(define-key jj-eyebrowse-wg-map (kbd "C-l") 'desktop-lazy-complete)
(define-key jj-eyebrowse-wg-map (kbd "C-f") 'desktop-read)
(define-key jj-eyebrowse-wg-map (kbd "C-s") 'desktop-save-in-desktop-dir)
(define-key jj-eyebrowse-wg-map (kbd "s-s") 'desktop-save)
(define-key jj-eyebrowse-wg-map (kbd "C-c") 'desktop-save)
(define-key image-mode-map (kbd "=") 'image-increase-size)
(define-key image-mode-map (kbd "_") 'image-decrease-size)
;; FIXME Read-only-mode not working correctly so the bindings below added
;; They were commented out of most recent view.el
(eval-after-load "view"
'(progn
(define-key view-mode-map "j" 'View-scroll-line-forward)
(define-key view-mode-map "k" 'View-scroll-line-backward)
(define-key view-mode-map "b" 'View-scroll-page-backward)
(define-key view-mode-map "f" 'View-scroll-page-forward)
(define-key view-mode-map "v" 'View-exit)
(define-key view-mode-map "K" 'View-quit)
)
)
(define-key pdf-view-mode-map (kbd "_") 'pdf-view-shrink)
;; (define-prefix-command 'pdf-view-mode-synctex-map)
;; (define-key pdf-view-mode-map (kbd "j") 'pdf-view-mode-synctex-map)
;; (define-key pdf-view-mode-synctex-map (kbd "j") 'pdf-isearch-sync-backward)
(define-key pdf-view-mode-map (kbd "j") 'pdf-isearch-sync-backward)
(global-set-key (kbd "s-h 0") 'xah-lookup-word-thesaurus)
(global-set-key (kbd "s-h )") 'xah-lookup-word-thesaurus-eww)
(global-set-key (kbd "s-h -") 'xah-lookup-word-power-thesaurus)
(global-set-key (kbd "s-h _") 'xah-lookup-word-power-thesaurus-eww)
(global-set-key (kbd "s-h 9") 'xah-lookup-word-definition)
(global-set-key (kbd "s-h (") 'xah-lookup-word-definition-eww)
(global-set-key (kbd "s-h 8") 'xah-lookup-word-dict-org)
(eval-after-load "magit-mode"
'(progn
(define-key magit-mode-map (kbd "Q") 'jj/magit-mode-kill-buffer)
(eval-after-load "magit-section"
'(progn
(define-key magit-mode-map (kbd "M-1") nil)
(define-key magit-mode-map (kbd "M-2") nil)
(define-key magit-mode-map (kbd "M-3") nil)
(define-key magit-mode-map (kbd "M-4") nil)
(define-key magit-mode-map (kbd "M-5") nil)
(define-key magit-mode-map (kbd "M-s-1") 'magit-section-show-level-1-all)
(define-key magit-mode-map (kbd "M-s-2") 'magit-section-show-level-2-all)
(define-key magit-mode-map (kbd "M-s-3") 'magit-section-show-level-3-all)
(define-key magit-mode-map (kbd "M-s-4") 'magit-section-show-level-4-all)
(define-key magit-mode-map (kbd "M-s-5") 'magit-section-show-level-5-all)
(define-key magit-mode-map "<escape> m" 'magit-toggle-margin)
(define-key magit-mode-map "<escape> M" 'magit-cycle-margin-style)
(defvar magit-mode-todos-map (make-sparse-keymap))
(define-key magit-mode-map (kbd "<escape> t") magit-mode-todos-map)
(define-key magit-mode-todos-map "u" 'magit-todos-update)
(define-key magit-mode-todos-map "l" 'magit-todos-list)
(define-key magit-mode-todos-map "h" 'helm-magit-todos)
(define-key magit-mode-todos-map "i" 'ivy-magit-todos)
(define-key magit-mode-todos-map "s" 'ivy-magit-todos)
(define-key magit-mode-todos-map "C-s" 'ivy-magit-todos)
(defvar magit-mode-todos-simple-map (make-sparse-keymap))
(define-key magit-mode-map (kbd "[") magit-mode-todos-simple-map)
(define-key magit-mode-todos-simple-map "u" 'magit-todos-update)
(define-key magit-mode-todos-simple-map "l" 'magit-todos-list)
(define-key magit-mode-todos-simple-map "h" 'helm-magit-todos)
(define-key magit-mode-todos-simple-map "t" 'magit-todos-mode)
(define-key magit-mode-todos-simple-map "i" 'ivy-magit-todos)
(define-key magit-mode-todos-simple-map "s" 'ivy-magit-todos)
(define-key magit-mode-todos-simple-map "C-s" 'ivy-magit-todos)
(define-key magit-mode-todos-simple-map "m" 'magit-toggle-margin)
(define-key magit-mode-todos-simple-map "M" 'magit-cycle-margin-style)
))
(eval-after-load "magit-diff"
'(progn
(define-key magit-mode-map (kbd "C-o") 'magit-diff-visit-file-other-frame)
(define-key magit-mode-map (kbd "<s-return>") 'magit-diff-visit-file-other-window)
(define-key magit-diff-mode-map (kbd "C-o") 'magit-diff-visit-file-other-frame)
(define-key magit-diff-mode-map (kbd "<s-return>") 'magit-diff-visit-file-other-window)
))))
(eval-after-load "simple"
'(progn
(bind-key "1" #'beginning-of-buffer messages-buffer-mode-map)
(bind-key "2" #'end-of-buffer messages-buffer-mode-map)
(bind-key "n" #'next-line messages-buffer-mode-map)
(bind-key "p" #'previous-line messages-buffer-mode-map)
(bind-key "i" #'evil-scroll-page-up messages-buffer-mode-map)
(bind-key "k" #'evil-scroll-page-down messages-buffer-mode-map)
))
(eval-after-load "indent"
'(progn
(global-set-key (kbd "C-M-]") 'indent-rigidly)
(global-set-key (kbd "M-|") 'indent-rigidly)
(define-key indent-rigidly-map (kbd "J") 'indent-rigidly-left-to-tab-stop)
(define-key indent-rigidly-map (kbd "K") 'indent-rigidly-right-to-tab-stop)
(define-key indent-rigidly-map (kbd "L") 'indent-rigidly-right)
(define-key indent-rigidly-map (kbd "H") 'indent-rigidly-left)
))