-
Notifications
You must be signed in to change notification settings - Fork 0
/
#.emacs1#
1024 lines (810 loc) · 36.4 KB
/
#.emacs1#
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
;;------------------------------------------------------------------------------------------
;; Package repositories
;;------------------------------------------------------------------------------------------
(package
-initialize)
(require 'package)
;; (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package
-initialize)
;;------------------------------------------------------------------------------------------
;; Basic
;;------------------------------------------------------------------------------------------
;; auto-fill-mode disable
(auto-fill-mode -1)
;; turn on auto-fill for text-mode
;; (add-hook 'text-mode-hook 'turn-on-auto-fill)
;; turn off auto-fill for org-mode
(add-hook 'matlab-mode-hook 'turn-off-auto-fill)
;; font size
;; (set-face-font 'default "Monaco-13")
;; Removing tutorial page
(setq inhibit-startup-message t)
;; cursor types
(setq-default cursor-type 'box)
;; (setq-default cursor-type 'bar)
;; (setq-default cursor-type 'hbar)
;; line number
(global-linum-mode t)
;; selection
(transient-mark-mode t)
;; whole selection
;; (define-key global-map (kbd "C-a") 'mark-whole-buffer)
;; tab size
(setq-default tab-width 2)
;; location view
(column-number-mode t)
(line-number-mode t)
;; Yes/NO - > y/n
(fset 'yes-or-no-p 'y-or-n-p)
;; ringing removing
(setq ring-bell-function 'ignore)
;; minibuffer histories
(savehist-mode 1)
;; window size
(add-to-list 'default-frame-alist '(height . 100))
(add-to-list 'default-frame-alist '(width . 200))
(set-frame-position (selected-frame) 0 0)
;; blanket
(show-paren-mode 1)
(setq show-paren-delay 0)
;;파일 편집 위치 기억
;; (require 'saveplace)
;; (setq-default save-place t)
;; (setq save-place-file "~/_places.sav")
;;최근 파일 접근
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 20) ; 최근 파일 목록 수
;;GUI 환경에서 줄 간격 조절
(setq-default line-spacing 1)
;;파일이 수정되었을 때 자동으로 다시 읽어들이도록 하는 설정
(global-auto-revert-mode t)
;;블럭 선택부분 색상 반전시키기
(setq-default transient-mark-mode t)
;; 탭 대신 공백 넣기
(setq-default indent-tabs-mode nil)
(defun set-default-programming-style ()
;; 엔터 입력시 들여쓰기
(local-set-key (kbd "<return>") 'newline-and-indent)
;; 탭키 입력시 영역지정되어 있으면 영역 들여쓰기. 영역없으면 탭키.
(local-set-key (kbd "<tab>") 'indent-block)
;; 들여쓰기 할 때 실제 탭문자 입력
(setq indent-tabs-mode t)
;; 탭 사이즈 4
(setq tab-width 4)
;; 줄번호 표시
(linum-mode 1)
)
;; backup files 위치 선정
(setq
backup-by-copying t ; don't clobber symlinks
backup-directory-alist
'(("." . "~/.saves/")) ; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t) ; use versioned backups
;; 기본 디렉토리 변경
(setq default-directory "~/projectFiles/")
;; 설정 파일
(global-set-key (kbd "<f10>") (lambda() (interactive)(find-file "~/.emacs")))
;;===========================================================================
;; 1. helm에 관한 코드들
;;===========================================================================
(require 'helm-config)
(require 'helm-grep)
(when (executable-find "curl")
(setq helm-google-suggest-use-curl-p t))
(setq
helm-scroll-amount 4 ; scroll 4 lines other window using M-<next>/M-<prior>
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
helm-split-window-in-side-p t ;; open helm buffer inside current window, not occupy whole other window
helm-candidate-number-limit 500 ; limit the number of displayed canidates
;; helm-ff-file-name-history-use-recentf t
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
helm-buffers-fuzzy-matching t ; fuzzy matching buffer names when non-nil
;; useful in helm-mini that lists buffers
)
(add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
(global-set-key (kbd "M-x") 'helm-M-x)
(add-hook 'helm-goto-line-before-hook 'helm-save-current-pos-to-mark-ring)
(require 'helm-swoop)
(helm-mode t)
(provide 'setup-helm)
(require 'helm-gtags)
(setq
helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t
helm-gtags-prefix-key "\C-cg"
helm-gtags-suggested-key-mapping t
)
;; Enable helm-gtags-mode in Dired so you can jump to any tag
;; when navigate project tree with Dired
(add-hook 'dired-mode-hook 'helm-gtags-mode)
;; Enable helm-gtags-mode in Eshell for the same reason as above
;; (add-hook 'eshell-mode-hook 'helm-gtags-mode)
;; Enable helm-gtags-mode in languages that GNU Global supports
(add-hook 'c-mode-hook 'helm-gtags-mode)
(add-hook 'c++-mode-hook 'helm-gtags-mode)
(add-hook 'java-mode-hook 'helm-gtags-mode)
(add-hook 'asm-mode-hook 'helm-gtags-mode)
(add-hook 'python-mode-hook 'helm-gtags-mode)
(provide 'setup-helm-gtags)
(projectile-mode +1)
(projectile-global-mode)
;;(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(require 'helm-projectile)
(global-set-key (kbd "C-x p") 'helm-projectile)
;;===========================================================================
;; cedet에 관한 코드들 (auto-complete, cc-mode, semantic...)(단어 자동완성 관련된 코드들)
;;===========================================================================
;; PACKAGE: auto-complete
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
;; PACKAGE: semantic
(require 'semantic)
;; (require 'semantic/ia) ;; interactive analysis
;; (require 'semantic/complete)
;; Semantic ON
(semantic-mode t)
;; semantic mode freezing probelm fixing code
;; https://github.com/syl20bnr/spacemacs/issues/7038#issuecomment-254980900
(eval-after-load 'semantic
(add-hook 'semantic-mode-hook
(lambda ()
(dolist (x (default-value 'completion-at-point-functions))
(when (string-prefix-p "semantic-" (symbol-name x))
(remove-hook 'completion-at-point-functions x))))
))
;; 선호하는 인코딩환경을 utf-8으로 설정합니다 (한글 문제)
;; 한글이 깨지는 경우
;; M-x revert-buffer-with-coding-system --> korea-iso-8bit 으로 설정해주면 정상적으로 보인다
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment "Korean")
(prefer-coding-system 'utf-8)
;;===========================================================================
;; python-mode & anaconda-mode
;;===========================================================================
;; (setq python-shell-interpreter "/anaconda3/bin/python")
;; (setq python-shell-interpreter-args "-m IPython --simple-prompt -i")
;; (setq flycheck-python-pycompile-executable "python3")
;; (setq doom-modeline-python-executable "python3")
;; (setq python-shell-interpreter "/anaconda3/bin/python")
;; (setq python-shell-interpreter-args "-m IPython --simple-prompt -i")
;; (setq flycheck-python-pycompile-executable "python3"
;; flycheck-python-pylint-executable "python3"
;; flycheck-python-flake8-executable "python3")
;; (setq doom-modeline-major-mode-icon nil
;; doom-modeline-persp-name t
;; doom-modeline-github t
;; doom-modeline-version t
;; doom-modeline-minor-modes t)
;; (minions-mode 1)
;; (setq persp-nil-name "#")
;; (setq minions-mode-line-lighter "◎")
;; (use-package python-mode
;; :mode ("\\.py\\'" . python-mode)
;; ("\\.wsgi$" . python-mode)
;; :interpreter ("python" . python-mode)
;; :init
;; (setq-default indent-tabs-mode nil)
;; :config
;; (setq python-indent-offset 4)
;; ;; TODO pyvenv
;; (setq flycheck-python-pycompile-executable
;; (or (executable-find "python")
;; (executable-find "/usr/bin/python")
;; (executable-find "/usr/local/bin/python")
;; "python"))
;; (setq flycheck-python-pylint-executable
;; (or (executable-find "pylint3")
;; (executable-find "/usr/bin/pylint3")
;; (executable-find "/usr/local/bin/pylint3")
;; "pyline"))
;; (setq flycheck-python-flake8-executable
;; (or (executable-find "flake8")
;; (executable-find "/usr/bin/flake8")
;; (executable-find "/usr/local/bin/flake8")
;; "flake8")))
;; (use-package anaconda-mode
;; :ensure t
;; :diminish anaconda-mode
;; :defer t
;; :init (progn
;; (add-hook 'python-mode-hook #'anaconda-mode)
;; (add-hook 'python-mode-hook #'anaconda-eldoc-mode)))
;; (use-package company-anaconda
;; :ensure t
;; :commands (company-anaconda)
;; :after company
;; :init (add-to-list 'company-backends #'company-anaconda))
;; (use-package nose
;; :commands (nosetests-one
;; nosetests-pdb-one
;; nosetests-all
;; nosetests-pdb-all
;; nosetests-module
;; nosetests-pdb-module
;; nosetests-suite
;; nosetests-pdb-suite)
;; :config
;; (progn
;; (add-to-list 'nose-project-root-files "setup.cfg")
;; (setq nose-use-verbose nil)))
;; (use-package pytest
;; :commands (pytest-one
;; pytest-pdb-one
;; pytest-all
;; pytest-pdb-all
;; pytest-module
;; pytest-pdb-module)
;; :config (add-to-list 'pytest-project-root-files "setup.cfg"))
;; (use-package pyenv-mode
;; :if (executable-find "TEST")
;; :commands (pyenv-mode-versions))
;; (use-package pyvenv
;; :defer t)
;;===========================================================================
;; org mode
;;===========================================================================
;; PACKAGE : org mode
;; DONE 시에 CLOSED timestamp를 사용하는 함수
;; PACKAGE: smartparens
;; (require 'smartparens-config)
;; (smartparens-global-mode t)
;; Alt + a 키로 괄호를 한 번에 지워주는 키를 설정합니다
;; (global-set-key (kbd "M-a") 'sp-splice-sexp)
;;(define-key c++-mode-map (kbd "M-a") 'sp-splice-sexp)
;; PACKAGE: comment-dwim
;; Alt + ' 키로 comment-dwim 명령어를 수행합니다
;; (global-set-key (kbd "M-'") 'comment-dwim)
;;===========================================================================
;; undo-tree
;;===========================================================================
(require 'undo-tree)
(global-undo-tree-mode)
(eval-after-load "undo-tree"
(lambda ()
(define-key undo-tree-map (kbd "C-r") nil)
(define-key undo-tree-map (kbd "C-?") nil)
;; C-? C-M-? C-/ 키로 org-agenda 명령을 수행합니다
(define-key undo-tree-map (kbd "C-?") 'org-agenda-list)
(define-key undo-tree-map (kbd "C-M-?") 'org-agenda)
(define-key undo-tree-map (kbd "C-/") 'org-todo-list)
;; C-_ 키로 font 크기를 특정 크기로 맞춰주는 함수 설정
(define-key undo-tree-map (kbd "C-_") 'set-frame-125)
))
;;===========================================================================
;; yasnippet
;;===========================================================================
;; Package: yasnippet
;; ~/.emacs.d/elpa/yasnippet-.../snippets 에 있는 파일들을 ~/.emacs.d/snippets 에 넣어야 정상적으로 동작합니다
(require 'yasnippet)
(yas-global-mode t)
(setq warning-suppress-types nil)
;; yasnippet에 elisp 함수를 쓰면 나타나는 경고문을 무시합니다
(add-to-list 'warning-suppress-types '(yasnippet backquote-change))
;;===========================================================================
;; anzu
;;===========================================================================
;; PACKAGE: anzu
(require 'anzu)
(global-anzu-mode)
;; M-% 키로 해당 buffer에서 특정 단어를 바꿉니다
(global-set-key (kbd "M-%") 'anzu-query-replace)
;; C-M-% 키로 정규표현식을 이용한 단어치환을 합니다
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
;; PACKAGE : flycheck
(require 'flycheck)
;; swiper
(require 'swiper)
(global-set-key (kbd "C-f") 'swiper-all)
;; PACKAGE: avy
(require 'avy)
;; PACKGE: eyebrowse
(require 'eyebrowse)
(eyebrowse-mode t)
;; C + 1,2,3을 누를때마다 워크스테이션을 생성한다
;;(setq eyebrowse-new-workspace t)
;;(setq eyebrowse-wrap-around t)
;;(setq eyebrowse-switch-back-and-forth t)
;;(setq eyebrowse-new-workspace nil)
;;(setq eyebrowse-mode-line-style (quote always))
;; PACKAGE: highlight-indentation
(require 'highlight-indentation)
;;(add-hook 'python-mode-hook 'highlight-indentation-mode)
;;(add-hook 'js2-mode-hook 'highlight-indentation-mode)
;; (set-face-font 'highlight-indentation-face "Monospace")
;; (set-face-background 'highlight-indentation-face "#0d0d0d")
;; (set-face-attribute 'highlight-indentation-face nil :height 54)
;; PACKAGE: iedit`
;; (require 'iedit)
;; ;; iedit mode가 시작되고 실행되는 코드
;; (eval-after-load "iedit"
;; (lambda()
;; ;; iedit 모드에서 `키로 선택 해제를 합니다 (default: M-;)
;; (define-key iedit-mode-keymap (kbd "`") 'iedit-toggle-selection)
;; ))
; PACKAGE: iedit
(require 'iedit)
;; iedit mode가 시작되고 실행되는 코드
(eval-after-load "iedit"
(lambda()
;; iedit 모드에서 `키로 선택 해제를 합니다 (default: M-;)
(define-key iedit-mode-keymap (kbd "q") 'iedit-toggle-selection)
(define-key iedit-mode-occurrence-keymap (kbd "q") 'iedit-toggle-selection)
))
;; Alt + [ 키로 선택된 단어를 iedit 일괄편집합니다
(global-set-key (kbd "M-[") 'iedit-mode)
;; 원래 C-; 가 iedit-mode로 키바인딩 되어있는 것을 해제합니다
;; (global-set-key (kbd "C-;") nil)
;; magit 패키지가 로딩되면 같이 실행되는 코드
(eval-after-load "magit"
(lambda ()
;; ed: 키바인딩 해제
(define-key magit-status-mode-map (kbd "C-w") nil)
(define-key magit-status-mode-map (kbd "M-3") nil)
(define-key magit-diff-mode-map (kbd "M-3") nil)
(define-key magit-process-mode-map (kbd "M-3") nil)
;; ed: j,k 키를 evil-mode의 vim 키바인딩으로 설정한다
(define-key magit-log-mode-map (kbd "j") 'evil-next-line)
(define-key magit-log-mode-map (kbd "k") 'evil-previous-line)
(define-key magit-log-mode-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-log-mode-map (kbd "C-d") 'evil-scroll-down)
(define-key magit-status-mode-map (kbd "j") 'evil-next-line)
(define-key magit-status-mode-map (kbd "k") 'evil-previous-line)
(define-key magit-status-mode-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-status-mode-map (kbd "C-d") 'evil-scroll-down)
(define-key magit-process-mode-map (kbd "j") 'evil-next-line)
(define-key magit-process-mode-map (kbd "k") 'evil-previous-line)
(define-key magit-process-mode-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-process-mode-map (kbd "C-d") 'evil-scroll-down)
(define-key magit-branch-section-map (kbd "k") 'evil-previous-line)
(define-key magit-branch-section-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-branch-section-map (kbd "C-d") 'evil-scroll-down)
(define-key magit-unstaged-section-map (kbd "k") 'evil-previous-line)
(define-key magit-unstaged-section-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-unstaged-section-map (kbd "C-d") 'evil-scroll-down)
(define-key magit-file-mode-map (kbd "k") 'evil-previous-line)
(define-key magit-file-mode-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-file-mode-map (kbd "C-d") 'evil-scroll-down)
(define-key magit-diff-mode-map (kbd "j") 'evil-next-line)
(define-key magit-diff-mode-map (kbd "k") 'evil-previous-line)
(define-key magit-diff-mode-map (kbd "C-u") 'evil-scroll-up)
(define-key magit-diff-mode-map (kbd "C-d") 'evil-scroll-down)
;; ] 키로 portal.opg 파일을 엽니다
;; (define-key magit-status-mode-map (kbd "{") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/portal.org")))
;; (define-key magit-diff-mode-map (kbd "{") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/portal.org")))
;; (define-key magit-process-mode-map (kbd "{") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/portal.org")))
;; ;; [ 키로 note.org 파일을 엽니다
;; (define-key magit-status-mode-map (kbd "[") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/note.org")))
;; (define-key magit-diff-mode-map (kbd "[") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/note.org")))
;; (define-key magit-process-mode-map (kbd "[") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/note.org")))
;; ;; } 키로 특정 pomodoro.org 파일을 엽니다
;; (define-key magit-status-mode-map (kbd "]") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/pomodoro.org")))
;; (define-key magit-diff-mode-map (kbd "]") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/pomodoro.org")))
;; (define-key magit-process-mode-map (kbd "]") (lambda() (interactive)(find-file "~/gitrepo_sync/ims_org/org_files/pomodoro.org")))
))
;;; 이맥스가 기본적으로 제공하는 Git 백엔드를 켜두면 매우 느려진다. magit만 쓴다.
(setq vc-handled-backends nil)
;; git merge 도중 conflict가 난 파일은 <<<< HEAD 같은 코드가 생기는데
;; 이 때 smerge-mode를 사용해서 conflict를 관리하는 함수
(global-set-key (kbd "C-c v") 'smerge-mode)
;; Alt + [ 키로 선택된 단어를 iedit 일괄편집합니다
(global-set-key (kbd "M-[") 'iedit-mode)
;; 원래 C-; 가 iedit-mode로 키바인딩 되어있는 것을 해제합니다
;; (global-set-key (kbd "C-;") nil)
;;------------------------------------------------------------------------------------------
;; ace window
;;------------------------------------------------------------------------------------------
;; Add ace-window hotkey.
(global-set-key (kbd "M-p") 'ace-window)
;; Set window resize hotkeys.
(global-set-key (kbd "S-C-f") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-b") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-p") 'shrink-window)
(global-set-key (kbd "S-C-n") 'enlarge-window)
;;------------------------------------------------------------------------------------------
;; matlab
;;------------------------------------------------------------------------------------------
;; (add-hook
;; 'matlab-shell-mode-hook
;; (lambda()
;; (define-key matlab-shell-mode-map (kbd "TAB")
;; 'matlab-shell-tab)))
(setq matlab-shell-command "/Applications/MATLAB_R2019a.app/bin/matlab")
(setq matlab-shell-command-switches (list "-nodesktop"))
;; (condition-case nil
;; (require 'company)
;; (error nil))
;; (eval-when-compile (require 'cl))
;; (require 'matlab)
;; ;; the following code is mostly taken from matlab.el, (C) Eric M. Ludlam
;; (defun company-matlab-shell-tab ()
;; "Send [TAB] to the currently running matlab process and retrieve completion."
;; (goto-char (point-max))
;; (let ((inhibit-field-text-motion t))
;; (beginning-of-line))
;; (re-search-forward comint-prompt-regexp)
;; (let* ((lastcmd (buffer-substring (point) (matlab-point-at-eol)))
;; (tempcmd lastcmd)
;; (completions nil)
;; (limitpos nil))
;; ;; search for character which limits completion, and limit command to it
;; (setq limitpos
;; (if (string-match ".*\\([( /[,;=']\\)" lastcmd)
;; (1+ (match-beginning 1))
;; 0))
;; (setq lastcmd (substring lastcmd limitpos))
;; ;; Whack the old command so we can insert it back later.
;; (delete-region (+ (point) limitpos) (matlab-point-at-eol))
;; ;; double every single quote
;; (while (string-match "[^']\\('\\)\\($\\|[^']\\)" tempcmd)
;; (setq tempcmd (replace-match "''" t t tempcmd 1)))
;; ;; collect the list
;; (setq completions (matlab-shell-completion-list tempcmd))
;; (goto-char (point-max))
;; (insert lastcmd)
;; completions))
;; (defun company-matlab-shell-grab-symbol ()
;; (when (string= (buffer-name (current-buffer)) (concat "*" matlab-shell-buffer-name "*"))
;; (save-excursion
;; (goto-char (point-max))
;; (let ((inhibit-field-text-motion t))
;; (beginning-of-line))
;; (re-search-forward comint-prompt-regexp)
;; (let* ((lastcmd (buffer-substring (point) (matlab-point-at-eol)))
;; limitpos)
;; (setq limitpos
;; (if (string-match ".*\\([( /[,;=']\\)" lastcmd)
;; (1+ (match-beginning 1))
;; 0))
;; (substring-no-properties lastcmd limitpos)))))
;; (defun company-matlab-shell-get-completions ()
;; (when (string= (buffer-name (current-buffer)) (concat "*" matlab-shell-buffer-name "*"))
;; (mapcar 'car (company-matlab-shell-tab))))
;; ;;;###autoload
;; (defun company-matlab-shell (command &optional arg &rest ignored)
;; "A `company-mode' completion back-end for Matlab-Shell."
;; (interactive (list 'interactive))
;; (case command
;; ('interactive (company-begin-backend 'company-matlab-shell))
;; ('prefix (company-matlab-shell-grab-symbol))
;; ('candidates (company-matlab-shell-get-completions))
;; ('sorted t)))
;; (provide 'company-matlab-shell)
;; ;;; company-matlab-shell.el ends here
;; ;;(global-set-key (kbd "M-;") #'endless/comment-line-or-region)
;; ;;(add-hook 'matlab-mode-hook (lamba () (local-set-key "\M-;" nil)))
;; (defun endless/comment-line-or-region (n)
;; "Comment or uncomment current line and proceed to the next line.
;; With positive prefix, apply to N lines including current one.
;; With negative prefix, apply to -N lines above.
;; If region is active, apply to active region instead."
;; (interactive "p")
;; (if (use-region-p)
;; (comment-or-uncomment-region
;; (region-beginning) (region-end))
;; (let ((range
;; (list (line-beginning-position)
;; (goto-char (line-end-position n)))))
;; (comment-or-uncomment-region
;; (apply #'min range)
;; (apply #'max range)))
;; (forward-line 1)
;; (back-to-indentation)))
;; ;; Unbind the M-; key from `matlab-mode-map'
;; ;; `with-eval-after-load' will work in emacs 24.4 and newer versions
;; (with-eval-after-load 'matlab
;; (define-key matlab-mode-map (kbd "M-;") nil))
;; ;; For emacs 24.3 and older versions use `eval-after-load' instead
;; ;; of `with-eval-after-load'. Note that `eval-after-load' accepts
;; ;; only a single quoted form.
;; ;; (eval-after-load 'matlab
;; ;; '(define-key matlab-mode-map (kbd "M-;") nil))
;; ;; Define the M-; binding globally
;; ;; This binding will be effective in any major-mode that does not
;; ;; have that major-mode-specific M-; binding
;; (global-set-key (kbd "M-;") #'endless/comment-line-or-region)
;; comment
(defun endless/comment-line-or-region (n)
"Comment or uncomment current line and proceed to the next line.
With positive prefix, apply to N lines including current one.
With negative prefix, apply to -N lines above.
If region is active, apply to active region instead."
(interactive "p")
(if (use-region-p)
(comment-or-uncomment-region
(region-beginning) (region-end))
(let ((range
(list (line-beginning-position)
(goto-char (line-end-position n)))))
(comment-or-uncomment-region
(apply #'min range)
(apply #'max range)))
(forward-line 1)
(back-to-indentation)))
;; Unbind the M-; key from `matlab-mode-map'
;; `with-eval-after-load' will work in emacs 24.4 and newer versions
(with-eval-after-load 'matlab
(define-key matlab-mode-map (kbd "M-;") nil))
;; For emacs 24.3 and older versions use `eval-after-load' instead
;; of `with-eval-after-load'. Note that `eval-after-load' accepts
;; only a single quoted form.
;; (eval-after-load 'matlab
;; '(define-key matlab-mode-map (kbd "M-;") nil))
;; Define the M-; binding globally
;; This binding will be effective in any major-mode that does not
;; have that major-mode-specific M-; binding
(global-set-key (kbd "M-;") #'endless/comment-line-or-region)
;;------------------------------------------------------------------------------------------
;; pyenv-mode
;;------------------------------------------------------------------------------------------
;; (use-package pyvenv
;; :ensure t
;; :init
;; (setenv "WORKON_HOME" "/home/NAME/anaconda/envs")
;; (pyvenv-mode 1)
;; (pyvenv-tracking-mode 1))
;; (defun ssbb-pyenv-hook ()
;; "Automatically activates pyenv version if .python-version file exists."
;; (f-traverse-upwards
;; (lambda (path)
;; (let ((pyenv-version-path (f-expand ".python-version" path)))
;; (if (f-exists? pyenv-version-path)
;; (pyenv-mode-set (s-trim (f-read-text pyenv-version-path 'utf-8))))))))
;; (add-hook 'find-file-hook 'ssbb-pyenv-hook)
;; (add-hook 'before-save-hook 'whitespace-cleanup)
;;------------------------------------------------------------------------------------------
;; whitespace
;;------------------------------------------------------------------------------------------
;; (progn
;; ;; Make whitespace-mode with very basic background coloring for whitespaces.
;; ;; http://ergoemacs.org/emacs/whitespace-mode.html
;; (setq whitespace-style (quote (face spaces tabs newline space-mark tab-mark newline-mark )))
;; ;; Make whitespace-mode and whitespace-newline-mode use “¶” for end of line char and “▷” for tab.
;; (setq whitespace-display-mappings
;; ;; all numbers are unicode codepoint in decimal. e.g. (insert-char 182 1)
;; '(
;; (space-mark 32 [183] [46]) ; SPACE 32 「 」, 183 MIDDLE DOT 「·」, 46 FULL STOP 「.」
;; (newline-mark 10 [182 10]) ; LINE FEED,
;; (tab-mark 9 [9655 9] [92 9]) ; tab
;; )))
;;======================================WONDOWS SETUP=========================================
;;====================================================================================
;; Basic Setup
;;====================================================================================
;; set basic directory
;; (setq default-directory "C:/Users/sehwan/Desktop/")
;; ;; Removing tutorial page
;; (setq inhibit-startup-message t)
;; ;; cursor types
;; (setq-default cursor-type 'box)
;; ;; (setq-default cursor-type 'bar)
;; ;; (setq-default cursor-type 'hbar)
;; ;; cursor line
;; ;; (global-hl-line-mode 1)
;; ;; line number
;; (global-linum-mode t)
;; ;; selection
;; (transient-mark-mode t)
;; whole selection
;; (define-key global-map (kbd "C-a") 'mark-whole-buffer)
;; tab size
;; (setq-default tab-width 2)
;; ;; location view
;; (column-number-mode t)
;; (line-number-mode t)
;; ;; Yes/NO - > y/n
;; (fset 'yes-or-no-p 'y-or-n-p)
;; ;; ringing removing
;; (setq ring-bell-function 'ignore)
;; ;; minibuffer histories
;; (savehist-mode 1)
;; ;; window size
;; (add-to-list 'default-frame-alist '(height . 40))
;; (add-to-list 'default-frame-alist '(width . 150))
;; (set-frame-position (selected-frame) 0 0)
;; ;; blanket
;; (show-paren-mode 1)
;; (setq show-paren-delay 0)
;; font size
;; (set-face-font 'default "Monaco-13")
;;====================================================================================
;; Repositories package
;;====================================================================================
;; (require 'package)
;; ;; (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
;; (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
;; (package
-initialize)
;;====================================================================================
;; Basic setup of repositoeis
;;====================================================================================
(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.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(column-number-mode t)
'(custom-enabled-themes (quote (misterioso)))
'(ecb-options-version "2.50")
'(global-whitespace-mode t)
'(package
-selected-packages
(quote
(treemacs flymake-php flycheck-pyflakes flymake-python-pyflakes projectile elpy flycheck-pycheckers format-all ipython-shell-send jedi python python-mode git magit ecb ace-window swiper flycheck php-mode org-pdfview multi-web-mode matlab-mode company-anaconda)))
'(show-paren-mode t))
(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.
'(whitespace-empty ((t (:foreground "firebrick" :background "SlateGray1"))))
'(whitespace-hspace ((t (:foreground "lightgray" :background "LemonChiffon3"))))
'(whitespace-indentation ((t (:foreground "firebrick" :background "beige"))))
'(whitespace-line ((t (:foreground "black" :background "red"))))
'(whitespace-newline ((t (:foreground "orange" :background "blue"))))
'(whitespace-space ((t (:bold t :foreground "gray75"))))
'(whitespace-space-after-tab ((t (:foreground "black" :background "green"))))
'(whitespace-space-before-tab ((t (:foreground "black" :background "DarkOrange"))))
'(whitespace-tab ((t (:foreground "blue" :background "white"))))
'(whitespace-trailing ((t (:foreground "red" :background "yellow")))))
;;====================================================================================
;; Repositories package
;;====================================================================================
;; (add-to-list 'load-path "~/.emacs.d/packages/matlab-emacs")
;; (load-library "matlab.el")
;; (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
;; (add-to-list
;; 'auto-mode-alist
;; '("\\.m$" . matlab-mode))
;; (setq matlab-indent-function t)
;; (setq matlab-shell-command "matlab")
;; (setq matlab-shell-command "C:/Program Files/MATLAB/R2018b/bin/matlab.exed")
;; (setq matlab-shell-command-switches '())
;; (setq matlab-shell-echoes nil)
;; ;; (setq matlab-shell-command "C:/Program Files/MATLAB/R2018b/bin/matlab.exe")
;; ;; (setq matlab-shell-command-switches (list "-nodesktop"))
;; ;; comment
;; (defun endless/comment-line-or-region (n)
;; "Comment or uncomment current line and proceed to the next line.
;; With positive prefix, apply to N lines including current one.
;; With negative prefix, apply to -N lines above.
;; If region is active, apply to active region instead."
;; (interactive "p")
;; (if (use-region-p)
;; (comment-or-uncomment-region
;; (region-beginning) (region-end))
;; (let ((range
;; (list (line-beginning-position)
;; (goto-char (line-end-position n)))))
;; (comment-or-uncomment-region
;; (apply #'min range)
;; (apply #'max range)))
;; (forward-line 1)
;; (back-to-indentation)))
;; ;; Unbind the M-; key from `matlab-mode-map'
;; ;; `with-eval-after-load' will work in emacs 24.4 and newer versions
;; (with-eval-after-load 'matlab
;; (define-key matlab-mode-map (kbd "M-;") nil))
;; ;; For emacs 24.3 and older versions use `eval-after-load' instead
;; ;; of `with-eval-after-load'. Note that `eval-after-load' accepts
;; ;; only a single quoted form.
;; ;; (eval-after-load 'matlab
;; ;; '(define-key matlab-mode-map (kbd "M-;") nil))
;; ;; Define the M-; binding globally
;; ;; This binding will be effective in any major-mode that does not
;; ;; have that major-mode-specific M-; binding
;; (global-set-key (kbd "M-;") #'endless/comment-line-or-region)
;;====================================================================================
;; whitespace mode
;;====================================================================================
(setq whitespace-display-mappings '(
(space-mark ?\ [?\u00B7] [?.])
(space-mark ?\xA0 [?\u00A4] [?_])
(newline-mark ?\n [?¶ ?\n])
(tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t])
))
;; lines lines-tail newline trailing space-before-tab space-afte-tab empty
;; indentation-space indentation indentation-tab tabs spaces
(setq whitespace-style '(face space-mark tab-mark newline-mark) )
(setq whitespace-line-column 85)
;;====================================================================================
;; swiper mode
;;====================================================================================
;; (use-package swiper
;; :ensure try
;; :config
;; (progn
;; (ivy-mode 1)
;; (setq ivy-use-virtual-buffers t)
;; (global-set-key "\C-s" 'swiper)
;; (global-set-key (kbd "C-c C-r") 'ivy-resume)
;; (global-set-key (kbd "<f6>") 'ivy-resume)
;; (global-set-key (kbd "M-x") 'counsel-M-x)
;; (global-set-key (kbd "C-x C-f") 'counsel-find-file)
;; (global-set-key (kbd "<f1> f") 'counsel-describe-function)
;; (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
;; (global-set-key (kbd "<f1> l") 'counsel-load-library)
;; (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
;; (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
;; (global-set-key (kbd "C-c g") 'counsel-git)
;; (global-set-key (kbd "C-c j") 'counsel-git-grep)
;; (global-set-key (kbd "C-c k") 'counsel-ag)
;; (global-set-key (kbd "C-x l") 'counsel-locate)
;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
;; ))
;;====================================================================================
;; ace window
;;====================================================================================
;; (global-set-key (kbd "M-o") 'ace-window)
;; (defvar aw-dispatch-alist
;; '((?x aw-delete-window "Delete Window")
;; (?m aw-swap-window "Swap Windows")
;; (?M aw-move-window "Move Window")
;; (?j aw-switch-buffer-in-window "Select Buffer")
;; (?n aw-flip-window)
;; (?u aw-switch-buffer-other-window "Switch Buffer Other Window")
;; (?c aw-split-window-fair "Split Fair Window")
;; (?v aw-split-window-vert "Split Vert Window")
;; (?b aw-split-window-horz "Split Horz Window")
;; (?o delete-other-windows "Delete Other Windows")
;; (?? aw-show-dispatch-help))
;; "List of actions for `aw-dispatch-default'.")
;; (put 'scroll-left 'disabled nil)
;;====================================================================================
;; ptyhon mode
;;====================================================================================
;; (require 'python)
;; (defun python--add-debug-highlight ()
;; "Adds a highlighter for use by `python--pdb-breakpoint-string'"
;; (highlight-lines-matching-regexp "## DEBUG ##\\s-*$" 'hi-red-b))
;; (add-hook 'python-mode-hook 'python--add-debug-highlight)
;; (defvar python--pdb-breakpoint-string "import pdb; pdb.set_trace() ## DEBUG ##"
;; "Python breakpoint string used by `python-insert-breakpoint'")
;; (defun python-insert-breakpoint ()
;; "Inserts a python breakpoint using `pdb'"
;; (interactive)
;; (back-to-indentation)
;; ;; this preserves the correct indentation in case the line above
;; ;; point is a nested block
;; (split-line)
;; (insert python--pdb-breakpoint-string))
;; (define-key python-mode-map (kbd "<f5>") 'python-insert-breakpoint)
;; (defadvice compile (before ad-compile-smart activate)
;; "Advises `compile' so it sets the argument COMINT to t
;; if breakpoints are present in `python-mode' files"
;; (when (derived-mode-p major-mode 'python-mode)
;; (save-excursion
;; (save-match-data
;; (goto-char (point-min))
;; (if (re-search-forward (concat "^\\s-*" python--pdb-breakpoint-string "$")