-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinit.el
More file actions
1154 lines (858 loc) · 33.3 KB
/
init.el
File metadata and controls
1154 lines (858 loc) · 33.3 KB
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
;; -*-emacs-lisp-*-
;;;
;;; Seong-Kook Shin's .emacs initialization file.
;;;
;;;
;;; You can download the latest version of this script at cinsk.org
;;;
;;; $ # make sure that you don't have .emacs.d/ nor .emacs file
;;; $ rm -r .emacs.d .emacs
;;; $ # Get the source file from my repository
;;; $ git clone http://github.com/cinsk/emacs-scripts.git .emacs.d
;;;
;;; The default value of `gc-cons-threshold' is set to 800000 on
;;; 64-bit system.
(defvar cinsk/gc-cons-threshold (* 10 gc-cons-threshold))
(setq gc-cons-threshold cinsk/gc-cons-threshold)
;;(setq garbage-collection-messages t)
;;;
;;; Load custom configuration -- Emacs's customizable variables will
;;; update this file if `custom-file' is nil which is not preferrable.
(setq custom-file "~/.emacs.d/my-custom.el")
(when (file-readable-p custom-file)
(load custom-file))
;;;
;;; emacs packages for my personal uses are placed in $HOME/.emacs.d
;;;
(defun path-join (path &rest args)
"Join all parameters to build a pathname."
(if args
(apply 'path-join
(concat (file-name-as-directory path) (car args))
(cdr args))
path))
(defmacro time-loop (n &rest body)
"Return time before and after N iteration of BODY.
DO NOT USE THIS MACRO. INSTEAD, USE `benchmark'."
(declare (indent 1) (debug t))
`(let ((t1 (current-time)))
(dotimes (i ,n)
,@body)
(time-subtract (current-time) t1)))
(defmacro save-font-excursion (face &rest body)
"Save the :font property of given FACE during the execution of BODY."
(declare (indent 1) (debug t))
`(let ((oldfont (face-attribute ,face :font)) ret)
(setq ret (progn ,@body))
(or (string= oldfont (face-attribute ,face :font))
(set-face-attribute ,face nil :font oldfont))
ret))
(defmacro enable-minor-mode (major-mode-file major-mode-hook feature minor-mode &rest condition)
"Enable MINOR-MODE on a major mode based on the CONDITION.
This macro will register a function which enables MINOR-MODE
based on CONDITION to the hook, MAJOR-MODE-HOOK. Since
MAJOR-MODE-HOOK might not available by the time this macro
called, the whole code will be body of `with-eval-after-load'
using MAJOR-MODE-FILE.
If CONDITION is omitted, MODE will be enabled always. If
CONDITION is a string, it will be treated as a regular expression
pattern and if it matches to the buffer-file-name, MODE will be
enabled. Otherwise, CONDITION is treated as a form and MODE will
be enabled if CONDITION evaluated as true.
Examples:
(enable-minor-mode \"js2-mode\" js2-mode-hook skewer-mode skewer-mode)
(enable-minor-mode \"js2-mode\" js2-mode-hook skewer-mode skewer-mode \"/d3/.*\\\\.js\\\\'\")
(enable-minor-mode \"js2-mode\" js2-mode-hook skewer-mode skewer-mode
;; ...
t)
"
(declare (indent 4))
`(when (locate-library ,major-mode-file)
(with-eval-after-load ,major-mode-file
(require (quote ,feature))
(add-to-list (quote ,major-mode-hook)
(lambda ()
(when ,(cond ((null condition) t)
((and (eq (length condition) 1) (stringp (car condition))) `(string-match ,@condition (buffer-file-name nil)))
(t `(progn ,@condition)))
(,minor-mode)))))))
(when (string-equal (getenv "SHELL") "/bin/false")
;; "$SHELL" is set to "/bin/false" in darwin under Amazon User
;; Cert. System. -- Hmm. this seems not true.
;; (let ((sh (or (executable-find "bash") "/bin/sh")))
(let ((sh (or (executable-find "zsh") "/bin/zsh")))
(setenv "SHELL" sh)
(setq shell-file-name sh)))
(setq user-emacs-directory "~/.emacs.d/")
(when (and (not (file-accessible-directory-p user-emacs-directory))
(not noninteractive))
(if (yes-or-no-p
(format "create user directory(%s)? " user-emacs-directory))
(make-directory user-emacs-directory t)))
(setq initial-buffer-choice "~/.emacs.d/README.org")
;;;
;;; package
;;;
;;;
;;; Whenever major upgrade for Emacs, try to execute below sexp to recompile
;;; everything in elpa/ directory.
;;;
;;; (byte-recompile-directory package-user-dir nil 'force)
;;;
(with-eval-after-load "tls"
;; On recent Mac (Mac Mojave), the ca-bundle is not available from
;; the file system, so `gnutls-trustfiles' would return nil. If the
;; `tls-program' uses "--x509cafile nil" command-line, gnutls-cli
;; will fail, so I'm going to remove "--x509cafile" from the
;; command-line
;;
;; TODO: Is it secure enough?
;; To verify, run:
;; (url-copy-file "https://www.google.com/" "google.txt")
(add-to-list 'tls-program "gnutls-cli -p %p %h"))
(let ((pkgdir (path-join user-emacs-directory "package")))
;; PKGDIR will contains the last emacs-23 compatible package.el from
;; https://github.com/technomancy/package.el
(when (and (file-readable-p pkgdir)
(= emacs-major-version 23))
(add-to-list 'load-path pkgdir))
(when (and (>= emacs-major-version 23)
(locate-library "package"))
(require 'package)
(dolist (entry '(;; marmalade cert expired.
;; ("marmalade" . "https://marmalade-repo.org/packages/")
;; ("sc" . "http://joseito.republika.pl/sunrise-commander/")
("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")
;; ("gnu" . "https://elpa.gnu.org/packages/")
))
(add-to-list 'package-archives entry))
(setq package-archive-priorities
'(("gnu" . 5)
("melpa" . 0)
("melpa-stable" . 10)))
;; According to the package.el, if `package-enable-at-startup' is
;; t, it will load all the packages on start up. But it didn't.
;; Perhaps it's a problem related to the version (currently Emacs
;; 23). Thus, I'll force to load it here.
(package-initialize)
;;
(setq package-enable-at-startup t)))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-compute-statistics t)
;;(unless (locate-library "s")
;; (package-install 's))
;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/skewer-mode"))
;;(require 'skewer-mode)
;; I will install packages that is not managed by packages.el in
;; "$HOME/.emacs.d/site-lisp".
;;
;; Note that packages in this directory has higher priority than others.
(defvar user-custom-packages-directory
(path-join user-emacs-directory "local")
"Manually installed packages are in this directory")
;;
;; No bell (beep)
;;
(setq ring-bell-function 'ignore)
(let ((srcpath (expand-file-name (path-join user-emacs-directory "src"))))
(add-to-list 'load-path srcpath)
)
(setq uinit/init-directory "~/.emacs.d/init"
uinit/use-byte-compile nil)
;; (byte-recompile-directory package-user-dir nil 'force)
(require 'uinit)
(use-package cinsk-common
:config
(global-set-key [(control ?c) ?n] #'cinsk/line-numbers-on-region)
(global-set-key [(control ?c) ?q] #'cinsk/fill-text-line-paragraph)
(global-set-key [(meta ?Q)] #'cinsk/unfill-paragraph)
;;(cinsk/add-site-lisp-directories "/usr/local/share/emacs/site-lisp")
;;(cinsk/add-site-lisp-directories user-custom-packages-directory)
)
(when (file-directory-p "/apollo/env/EmacsAmazonLibs/share/emacs/site-lisp")
(add-to-list 'load-path "/apollo/env/EmacsAmazonLibs/share/emacs/site-lisp"))
(use-package amz-common
:disabled
:config
(when (boundp 'c-default-style)
;; Amazon library uses BSD style for C/C++, which I don't like
(setq c-default-style (delq (assoc 'c++-mode c-default-style)
c-default-style)
c-default-style (delq (assoc 'c-mode c-default-style)
c-default-style))))
(use-package capitalize+
:config
(substitute-key-definition 'capitalize-word 'capitalize-word+
(current-global-map)))
(defun system--uname ()
"Return system information."
(let ((cmd (cond ((or (eq system-type 'gnu/linux)
(eq system-type 'darwin))
"uname -a")
((eq system-type 'windows-nt)
"ver")
(t
nil))))
(if cmd
(string-trim (shell-command-to-string cmd))
"")))
(defvar system-uname (system--uname)
"system information")
(defun wsl-p ()
(if (and (eq system-type 'gnu/linux)
(string-match "[mM]icrosoft" system-uname))
t))
(uinit/load "wsl"
(wsl-p))
(uinit/load "darwin"
(eq system-type 'darwin))
(uinit/load "X"
(eq window-system 'x))
(uinit/load "_ediff"
;; Note that some external packages loads 'ediff by themselves, such
;; as magit and color-theme. Since
;; `ediff-make-wide-display-function' should be set before loading
;; `ediff, ediff customization should be placed in the first
;; place. -- cinsk
'ediff)
(use-package fontutil
:config
;; For the actual fontset selection, see init/X.el or init/darwim.el
(fontutil/install-mouse-wheel))
;;; Sometimes, Emacs asks for the confirmation of a command such as
;;; killing a buffer. In that case, user should type "yes" or "no"
;;; directly.
;;;
;;; Below configuration let the user uses "y" or "n" instead of using
;;; longer version.
(defalias 'yes-or-no-p 'y-or-n-p)
;;; Helpers for TAGS manipulation
(setq tags-add-tables 't) ; do not ask to add new tags table.
;;; Try completes if the line is already indented
(setq tab-always-indent 'complete)
;;; Set up the keyboard so the delete key on both the regular keyboard
;;; and the keypad delete the character under the cursor and to the right
;;; under X, instead of the default, backspace behavior.
;;;
;; (global-set-key [delete] 'delete-char)
;; (global-set-key [kp-delete] 'delete-char)
(uinit/load "_cc-mode"
'cc-mode)
;;; Emacs generates a backup file (filename plus "~") whenever a file
;;; the first time it is saved. Uncomment below line to prevents it.
;;;
;; (setq-default make-backup-files nil)
;;;
;;; Window-less system Configuration
;;;
(when (or window-system (daemonp))
(menu-bar-mode 1) ; -1 to hide, 1 to show
(tool-bar-mode -1) ; -1 to hide, 1 to show
)
(uinit/load "korean"
enable-multibyte-characters)
;;;
;;; Search and replace related configuration
;;;
(defalias 'qr 'query-replace)
(defalias 'qrr 'query-replace-regexp)
(progn
;; The default key binding M-% and C-M-% are too difficult to type.
;; Since M-# and C-M-# are not used by official bindings, I'll use them.
(global-set-key [(meta ?#)] 'query-replace)
(global-set-key [(control meta ?#)] 'query-replace-regexp)
;; During isearch, M-% and C-M-% will also launching replace job
;; with the last search string. Thus, I'll add M-% and C-M-% for
;; the consistence.
(define-key isearch-mode-map [(meta ?#)] 'isearch-query-replace)
(define-key isearch-mode-map [(control meta ?#)]
'isearch-query-replace-regexp)
;; During isearch, `M-s w' will toggle word search, which is
;; difficult to remember, so use `M-W' instead.
;;
;; Note that `M-w' works as original, `kill-ring-save'.
(define-key isearch-mode-map [(meta ?W)] 'isearch-toggle-word)
)
(uinit/load "_shell"
'shell)
(uinit/load "buffer-menu"
'buffer-menu)
;;; When a user paste clipboard content in Emacs using mouse button 2,
;;; the content will be pasted in the place at mouse click. Comment
;;; below line for the default behavior (at mouse click).
(setq mouse-yank-at-point t)
;; browse-kill-ring: interactive kill-ring navigation
;; disabled in favor of `helm-show-kill-ring'
;;
;; (when (uinit/require 'browse-kill-ring)
;; (when (fboundp 'browse-kill-ring)
;; (global-set-key [(control ?c) (control ?k)] 'browse-kill-ring)))
;;;
;;; If you are intended BS (backspace) key to work
;;; correctly on some terminals, uncomment one of below s-exp.
;;; -- cinsk
;;(global-set-key [C-?] 'backward-delete-char)
;;(global-set-key [C-h] 'backward-delete-char)
(global-set-key "\C-cc" 'compile)
(when (uinit/require 'dwim-compile)
(require 'dwim-compile)
(global-set-key [(control ?c) ?c] 'dwim-c/compile))
(global-set-key [(control ?c) (control ?c)] 'comment-region)
(setq comment-empty-lines t)
(global-set-key [?\C-.] 'find-tag-other-window) ; C-x o
(global-set-key [(control c) ?i] 'indent-region)
(global-set-key [(f11)] 'toggle-case-fold-search)
;;; Show matching parenthese
(when (fboundp 'show-paren-mode)
(show-paren-mode 1))
;;;
;;; ICE setup
;;;
(add-to-list 'auto-mode-alist '(".*\\.ice$" . java-mode))
;;;
;;; Abbrev mode, skeletons, and autoload settings
;;;
(use-package xskel)
(let ((abb_default "~/.abbrev_defs")
(abb_correct (path-join user-emacs-directory "abbrev_defs")))
;; Prefer "~/.emacs.d/abbrev_defs" to "~/.abbrev_defs"
(setq abbrev-file-name
(if (file-readable-p abb_correct)
abb_correct
(if (file-readable-p abb_default)
abb_default
abb_correct))))
;;;
;;; Use hippie expansion for dynamic abbreviation
;;;
(use-package hippie-exp
:config
(global-set-key [(meta ?/)] 'hippie-expand)
(setq hippie-expand-try-functions-list
'(try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-line
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-expand-list
try-complete-lisp-symbol-partially
try-complete-lisp-symbol)))
;;;
;;; Switching between buffers using iswitchb/ido
;;;
(unless (package-installed-p 'helm)
(use-package iswitchb
:disabled
:config
;; (iswitchb-mode 1) ; smart buffer switching mode
(setq iswitchb-default-method 'maybe-frame)) ; ask to use another frame.
(use-package ido
:config
(ido-mode 1)
;;(setq ido-default-buffer-method 'maybe-frame)
(setq ido-use-filename-at-point 'guess)
(setq ido-max-directory-size 100000)
(when (boundp 'ido-file-completion-map)
;; The default binding `C-x C-f' is too much for me
(define-key ido-file-completion-map [(control return)] 'ido-enter-dired)
(define-key ido-file-completion-map [(meta return)] 'ido-enter-dired))))
;;
;; Normally, switching buffer commands (e.g. `switch-to-buffer' or
;; `iswitchb-buffer') ignore buffer that matched "^ ".
;;
;; When I develop some lisp package, I need to switch to buffers that
;; begins with "^ ". Thus, I don't use "^ " as the value of
;; `iswitchb-buffer-ignore'.
;;
;; The problem is, sometimes " *Minibuf-1*" buffer will be in the buffer
;; list, which makes me annoying. Thus, I'll explicitly ignore minibuffer-like
;; names in `iswitchb-buffer-ignore'. -- cinsk
;;
;; (setq iswitchb-buffer-ignore '("^ \\*Minibuf[^*]*\\*"))
;; I tried helm-mode, which looks promising, but it does not seem to
;; have enough short-cut mechanism to boost user's input. For
;; example, completing q-r-r is not possible for
;; `query-replace-regexp'. And if there are multiple choices, I need
;; to navigate using up/down shortcut, with careful on-looking to the
;; helm buffer. It distract me from what I try to do. Until helm
;; updated, or until I found better way, I'll stick to
;; 'icomplete-mode.
;(icomplete-mode 1)
;(with-eval-after-load "icomplete"
; (uinit/require 'icomplete+ nil 'noerror))
(when (> emacs-major-version 23)
;; diable completion cycling
(setq completion-cycle-threshold nil))
;; Now I'm using helm. One minor problem is, whenever I invoke
;; `helm-find-files', sometimes it freezes. I believe this is related
;; to the garbage collection. See the comment in the beginning of the
;; file for `garbage-collection-messages'.
(uinit/load "_helm" (locate-library "helm"))
;;;
;;; Minor Mode configuration
;;;
;; imenu mode
;;(add-hook 'c-mode-hook (function (lambda nil (imenu-add-to-menubar))))
;;(add-hook 'c++-mode-hook (function (lambda nil (imenu-add-to-menubar))))
;;(add-hook 'c-mode-hook (function (lambda nil (which-function-mode))))
;;(add-hook 'c++-mode-hook (function (lambda nil (which-function-mode))))
;;(when window-system
;; (which-function-mode 1)) ; display function names in mode-line
(global-font-lock-mode 1) ; every buffer uses font-lock-mode
(line-number-mode 1) ; show line number in mode-line
(column-number-mode 1) ; show column number in mode-line
(setq resize-minibuffer-mode t) ; ensure all contents of mini
; buffer visible
;; (when (display-graphic-p)
;; (global-hl-line-mode 1))
;; I'll try the `ido-use-filename-at-point' instead ffap for now
;;
;;(setq ffap-require-prefix t)
;;(ffap-bindings) ; context-sensitive find-file
(use-package untabify
:config
(setq-default indent-tabs-mode nil) ; do not insert tab character.
(add-hook 'before-save-hook 'untabify-remove-trailing-spaces-on-write))
(uinit/load "delete"
'delete)
;;;
;;; Colors
;;;
;;(set-background-color "rgb:0000/1500/8000")
;;(set-foreground-color "white")
;;(set-cursor-color "")
;;(set-mouse-color "")
;;(set-face-foreground 'highlight "white")
;;(set-face-background 'highlight "slate blue")
;;(set-face-background 'region "slate blue")
;;(set-face-background 'secondary-selection "turquoise")
;;;
;;; emacs server
;;;
(when (and (not noninteractive) (display-graphic-p))
(ignore-errors
(server-start)))
;;;
;;; I prefer case-sensitive search & replace
;;;
(setq-default case-fold-search nil)
(setq-default tags-case-fold-search nil)
(fset 'find-next-tag "\C-u\256") ; macro for C-u M-.
(fset 'find-prev-tag "\C-u-\256") ; macro for C-u - M-.
(global-set-key "\M-]" 'find-next-tag)
(global-set-key "\M-[" 'find-prev-tag)
;;(global-set-key [up] '(lambda () (interactive) (scroll-down 1)))
;;(global-set-key [down] '(lambda () (interactive) (scroll-up 1)))
(fset 'scroll-other-frame "\C-xo\C-v\C-xo") ; C-x o C-v C-x o
(fset 'scroll-other-frame-down "\C-xo\366\C-xo") ; C-x o M-v C-x o
(global-set-key [(meta shift prior)] 'scroll-other-frame-down)
(global-set-key [(meta shift next)] 'scroll-other-frame)
(global-set-key [(control meta ?\])] #'forward-page)
(global-set-key [(control meta ?\[)] #'backward-page)
(when (and (or (display-graphic-p) (daemonp))
(eq (lookup-key (current-global-map) [(control ?z)])
#'suspend-frame))
;; `suspend-frame' is bound to `C-z' and `C-x C-z'.
;; As I accidentally press `C-z' so remove its binding.
(global-unset-key [(control ?z)]))
(uinit/load "window-frame"
'window-frame)
;;;
;;; Markdown mode
;;;
(use-package markdown-mode
:config
(add-to-list 'markdown-css-paths "http://thomasf.github.io/solarized-css/solarized-light.min.css")
;; On Emacs 27.1, if a displayed image is too tall, it prevent Emacs
;; scroll up/down.
(when (or (memq 'scale (image-transforms-p))
(image-type-available-p 'imagemagick))
(let ((h (* 20 (line-pixel-height)))
(w (floor (* (frame-inner-width) 0.7))))
(and (<= h 0) (setq h 400))
(and (<= w 0) (setq w 400))
(setq markdown-max-image-size (cons w h)))))
;;;
;;; vim-modeline
;;;
(let ((vim-modeline-path (expand-file-name
(path-join user-emacs-directory "vim-modeline"))))
(when (file-accessible-directory-p vim-modeline-path)
(add-to-list 'load-path vim-modeline-path)
(when (locate-library "vim-modeline")
(require 'vim-modeline)
(add-hook 'find-file-hook 'vim-modeline/do))))
(uinit/load "vcs"
'version-control-system)
(use-package cmake-mode
:disabled
:config
(setq auto-mode-alist
(append '(("CMakeLists\\.txt\\'" . cmake-mode)
("\\.cmake\\'" . cmake-mode))
auto-mode-alist)))
(use-package winner
:config
;; A history manager for window configuration.
;; `C-c left' for undo, `C-c right' for redo
(winner-mode 1))
(use-package windmove
:disabled
:config
;; Select a window by pressing arrow keys.
;; The default modifier is 'shift which is not suitable for me since
;; I use `shift-left' and `shift-right' bindings in org-mode.
;;
;; Since my keyboard (HHK) has separate Alt key (apart from Meta
;; key), I use the 'alt instead of 'shift -- cinsk
(windmove-default-keybindings 'alt))
;;
;; Company mode
;;
(with-eval-after-load "company"
(define-key company-mode-map [(control meta ?i)] 'company-complete-common)
(define-key company-active-map [(control ?n)] 'company-select-next)
(define-key company-active-map [(control ?p)] 'company-select-previous)
(define-key company-active-map [(control ?v)] 'company-next-page)
(define-key company-active-map [(meta ?v)] 'company-previous-page)
)
(uinit/load "_paren.el" (or (locate-library "paredit")
(locate-library "smartparens")))
(uinit/load "lisp"
'lisp)
(uinit/load "_clojure"
(and (locate-library "clojure-mode") (locate-library "cider-mode")))
(uinit/load "_latex"
'latex-mode)
(uinit/load "_mmm" 'deferred)
(uinit/load "_nxml"
(or (locate-library "nxml-mode")
;; For legacy nxml-mode which does not use `provide' for nxml-mode.
(locate-library "rng-auto")))
(uinit/load "dired"
'dired)
(global-set-key [(meta ?F) ?d return] 'find-dired)
(global-set-key [(meta ?F) ?g ?d] 'find-grep-dired)
(global-set-key [(meta ?F) ?g return] 'find-grep)
(global-set-key [(meta ?F) ?r] 'rgrep)
;;;
;;; cscope binding
;;;
;;; You need to install cscope(1) and xcscope.el to use below bindings
;;; Read xcscope.el packaged in cscope source tarball. It can be obtained
;;; from http://cscope.sourceforge.net/
;;;
;;; As xcscope is available in Melpa, manual configuration is no
;;; longer needed.
;; (when (locate-library "xcscope")
;; (require 'xcscope)
;; (and (fboundp 'cscope-setup)
;; (cscope-setup)))
;;;
;;; Version Control
;;;
;; vc-toggle-read-only is an obsolete command (as of 24.1)
(global-set-key [(control x) (control q)]
(if (fboundp 'read-only-mode)
'read-only-mode
'vc-toggle-read-only))
;;(split-window-horizontally)
;;(uinit/load "mail" 'mail-news-gnus)
;;;
;;; YAML mode
;;;
(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)))
;;;
;;; CSS mode
;;;
(with-eval-after-load "css-mode"
(setq cssm-indent-function #'cssm-c-style-indenter))
(autoload 'css-mode "css-mode" "CSS editing major mode" t)
(add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))
;;;
;;; htmlize
;;;
(use-package htmlize
:disabled
:config
(setq htmlize-convert-nonascii-to-entities nil))
;;;
;;; Calender
;;;
(require 'calendar)
(global-set-key [(control f12)] 'calendar)
(let ((my-diary-file (path-join user-emacs-directory "diary")))
(if (file-readable-p my-diary-file)
(setq diary-file my-diary-file)))
(setq mark-holidays-in-calendar t)
(when (and (boundp 'diary-file)
(file-readable-p diary-file))
(setq mark-diary-entries-in-calendar t))
(add-hook 'diary-display-hook 'fancy-diary-display)
(setq local-holidays
'((holiday-fixed 11 1 "삼성전자 창립일")))
(let ((cal-korea-path (expand-file-name
(path-join user-emacs-directory "cal-korea-x"))))
(when (file-accessible-directory-p cal-korea-path)
(add-to-list 'load-path cal-korea-path)
(when (locate-library "cal-korea-x")
(require 'cal-korea-x)
(setq holiday-general-holidays cal-korea-x-korean-holidays))))
(use-package amazon-util
:disabled
:requires amz-common)
(uinit/load "_org" (locate-library "org"))
;;;
;;; Emacs-wiki support
;;;
;; (require 'emacs-wiki)
;;;
;;; ispell(aspell) configuration
;;;
;;; Currently neither of them provides Korean dictionary.
;;; Currently, ispell complained that it does not have proper dictionary in
;;; Korean language environment.
(with-eval-after-load "ispell"
(setq ispell-dictionary "english"))
;;;
;;; Do not display splash screen on startup
;;;
;; Disable the startup screen
(setq inhibit-splash-screen t)
(uinit/load "ruby"
(locate-library "ruby-mode"))
(if (locate-library "python-mode")
;; remember that Aquamacs provides its own version of python-mode
;; which may not the one you're looking for.
(uinit/load "_python" t)
(uinit/load "_py" t))
(uinit/load "_js" 'js)
(uinit/load "_rust"
(locate-library "rust-mode"))
(uinit/load "maven" 'maven)
(uinit/load "_browse-url"
(locate-library "browse-url"))
;;;
;;; gnuplot
;;;
(when (locate-library "gnuplot")
(autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
(autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)
(setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode))
auto-mode-alist)))
;;;
;;; go lang
;;;
(uinit/load "_go" (locate-library "go-mode"))
(unless (locate-library "go-mode")
(let* ((godir "/usr/local/go")
(gldir (path-join godir "misc/emacs")))
(when (file-accessible-directory-p gldir)
(add-to-list 'load-path gldir 'append)
(when (locate-library "go-mode-load")
(require 'go-mode-load)))))
;;;
;;; lua
;;;
(uinit/load "_lua"
(when (locate-library "lua-mode")
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-mode))))
;;;
;;; YASnippet -- http://code.google.com/p/yasnippet/
;;;
(use-package yasnippet
:config
;; tested with yasnippet 0.8.0 (beta)
;; The official document describes the snippets directory in
;; "~/.emacs.d/plugins/yasnippet-x.y.z/snippets", whereas Gentoo
;; yasnippet package installed them in
;; "/usr/share/emacs/etc/yasnippet/snippets".
(setq yas-snippet-dirs (cinsk/accessible-directories
"~/.emacs.d/snippets"))
;; (concat (file-name-directory
;; (locate-library "yasnippet"))
;; "snippets")
;; "/usr/share/emacs/etc/yasnippet/snippets"))
(yas-global-mode 1)
(global-set-key [(control ?x) (control ?/)] 'yas-insert-snippet)
(setq yas/prompt-functions '(yas-ido-prompt
yas-dropdown-prompt
yas-completing-prompt
yas-no-prompt))
(unless (eq system-type 'darwin)
(add-to-list 'yas/prompt-functions 'yas-x-prompt))
(defun apply-snippet-mode ()
"Change major-mode to `snippet-mode' if the current file is
in any of directory in `yas-snippet-dirs'."
(when (buffer-file-name)
(let ((fullname (expand-file-name (buffer-file-name)))
(filename (file-name-nondirectory (buffer-file-name))))
(when (and (not (string-prefix-p "." filename))
(< 0 (apply '+
(mapcar (lambda (dir)
(let ((absdir (expand-file-name dir)))
(if (string-prefix-p absdir fullname)
1
0)))
yas-snippet-dirs))))
(snippet-mode)))))
(add-to-list 'find-file-hook 'apply-snippet-mode)
(when nil
;; While old version (e.g. 0.6.1b) uses `yas/root-directory', and
;; provides `yas/reload-all', new version uses `yas-snippets-dirs'
;; and provides `yas-reload-all'.
(if (not (fboundp 'yas-reload-all))
(progn
(setq yas/root-directory yas-snippet-dirs)
(and (fboundp 'yas/reload-all)
(yas/reload-all)))
;; Otherwise, use the new interface.
(and (fboundp 'yas-reload-all)
(yas-reload-all))))
)
(uinit/load "scala" t)
;;;
;;; ESS(Emacs Speaks Statistics) setting for R.
;;;
(uinit/load "_ess"
(locate-library "ess-site"))
(uinit/load "_sunrise"
(locate-library "sunrise-commander"))
;;; To save & load Emacs session, following lines should be the last
;;; line in this file.
;;;
;;; The first time you save the state of the Emacs session, you must
;;; do it manually, with the command `M-x desktop-save'. Once you have
;;; done that, exiting Emacs will save the state again--not only the
;;; present Emacs session, but also subsequent sessions. You can also
;;; save the state at any time, without exiting Emacs, by typing `M-x
;;; desktop-save' again.
;;;
;;; In order for Emacs to recover the state from a previous session,
;;; you must start it with the same current directory as you used when
;;; you started the previous session. This is because `desktop-read'
;;; looks in the current directory for the file to read. This means
;;; that you can have separate saved sessions in different
;;; directories; the directory in which you start Emacs will control
;;; which saved session to use.