-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
922 lines (769 loc) · 31.8 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
(setq debug-on-error t)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("elpa" . "http://tromey.com/elpa/")
("melpa" . "http://melpa.milkbox.net/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
))
;; list the packages you want
;; with C-h v package-activated-list
(setq package-list '(ac-emmet auto-complete popup emmet-mode auto-complete popup color-theme-github color-theme csv-mode diff-hl drupal-mode php-mode easy-repeat elscreen emmet-mode emms-info-mediainfo emms f dash s flycheck-pyflakes flycheck let-alist pkg-info epl dash flycheck-tip s popup dash flycheck let-alist pkg-info epl dash flylisp flymake-css flymake-easy flymake-cursor flymake-gjshint flymake-haml flymake-easy flymake-hlint flymake-easy flymake-jshint flymake-easy flymake-jslint flymake-easy flymake-json flymake-easy flymake-less less-css-mode flymake-lua flymake-php flymake-easy flymake-phpcs flymake-easy flymake-python-pyflakes flymake-easy flymake-ruby flymake-easy flymake-sass flymake-easy flymake-shell flymake-easy flymake-yaml flymake-easy github-theme gitignore-mode hl-anything js3-mode json-mode json-snatcher json-reformat json-reformat json-snatcher less-css-mode let-alist lua-mode magit markdown-mode minimap move-text neotree nginx-mode php-auto-yasnippets yasnippet php-mode php-mode pkg-info epl popup rainbow-mode s sass-mode haml-mode scss-mode smartparens dash ssh-config-mode syslog-mode hide-lines tea-time twittering-mode vcl-mode web-beautify web-mode yaml-mode yasnippet iedit))
(add-to-list 'load-path "~/.emacs.d/lisp")
(add-to-list 'load-path "~/.emacs.d/elpa")
; activate all the packages (in particular autoloads)
(package-initialize)
; fetch the list of packages available
(unless package-archive-contents
(package-refresh-contents))
; install the missing packages
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package)))
;;;;;;;;;;;;; General settings
;; Turn on syntax colouring in all modes supporting it:
(global-font-lock-mode t)
(recentf-mode 1) ; keep a list of recently opened files
(delete-selection-mode 1) ;; replace selection when typing
(setq search-highlight t) ; Highlight search object
(setq query-replace-highlight t) ; Highlight query object
(setq mouse-sel-retain-highlight t) ; Keep mouse high-lightening
(setq stack-trace-on-error t)
;; stop annoying questions
(setq-default abbrev-mode t)
;;(read-abbrev-file “~/.abbrev_defs”)
(setq save-abbrevs t)
;; delete trailing whitespaces!
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(fset 'yes-or-no-p 'y-or-n-p)
;; mover línea hacia arriba
(defun move-line-up ()
(interactive)
(transpose-lines 1)
(forward-line -2))
;; mover línea hacia abajo
(defun move-line-down ()
(interactive)
(forward-line 1)
(transpose-lines 1)
(forward-line -1))
(global-set-key (kbd "S-M-<up>") 'move-text-up)
(global-set-key (kbd "S-M-<down>") 'move-text-down)
;; cycle through buffers
(global-set-key (kbd "<C-tab>") 'bury-buffer)
;; tea time
(define-key global-map "\C-ct" 'tea-time)
(global-set-key "\C-xk" 'kill-this-buffer) ; Kill buffer without confirmation
(defun duplicate-line-or-region (&optional n)
"Duplicate current line, or region if active.
With argument N, make N copies.
With negative N, comment out original line and use the absolute value."
(interactive "*p")
(let ((use-region (use-region-p)))
(save-excursion
(let ((text (if use-region ;Get region if active, otherwise line
(buffer-substring (region-beginning) (region-end))
(prog1 (thing-at-point 'line)
(end-of-line)
(if (< 0 (forward-line 1)) ;Go to beginning of next line, or make a new one
(newline))))))
(dotimes (i (abs (or n 1))) ;Insert N times, or once if not specified
(insert text))))
(if use-region nil ;Only if we're working with a line (not a region)
(let ((pos (- (point) (line-beginning-position)))) ;Save column
(if (> 0 n) ;Comment out original with negative arg
(comment-region (line-beginning-position) (line-end-position)))
(forward-line 1)
(forward-char pos)))))
(global-set-key (kbd "C-c d") 'duplicate-line-or-region) ; duplicate line or region
(global-set-key "\C-c\C-d" "\C-a\C- \C-n\M-w\C-y\C-p") ; clone current line
(global-set-key (kbd "C-x g") 'magit-status)
(setq gtags-auto-update nil) ;; drupal fix/workaround?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; revert
(global-auto-revert-mode 1)
(setq auto-revert-verbose nil)
(global-set-key (kbd "<f5>") 'revert-buffer)
;; end revert
;;; Variables
(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-names-vector
["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#ad7fa8" "#8cc4ff" "#eeeeec"])
'(blink-cursor-mode nil)
'(c-tab-always-indent nil)
'(column-number-mode t)
'(company-auto-complete (quote (quote company-explicit-action-p)))
'(cua-mode t nil (cua-base))
'(custom-enabled-themes (quote (deeper-blue)))
'(delete-selection-mode t)
'(display-battery-mode t)
'(display-time-mode t)
'(ecb-options-version "2.40")
'(erc-auto-query (quote window-noselect))
'(erc-autoaway-mode t)
'(erc-away-nickname nil)
'(erc-join-buffer (quote window-noselect))
'(erc-modules
(quote
(completion list menu scrolltobottom autojoin button dcc fill irccontrols match move-to-prompt netsplit networks noncommands readonly ring stamp spelling track)))
'(erc-nick-notify-mode t)
'(erc-prompt ">")
'(erc-public-away-p t)
'(erc-speedbar-sort-users-type (quote alphabetical))
'(erc-user-full-name "Tomás Solar")
'(flymake-phpcs-location (quote tempdir))
'(flymake-phpcs-standard "PSR2")
'(flyspell-mode 1 t)
'(git-state-modeline-decoration (quote git-state-decoration-small-dot))
'(global-diff-hl-mode t)
'(global-hl-line-mode t)
'(global-hl-line-sticky-flag nil)
'(global-linum-mode t)
'(global-subword-mode t)
'(gtags-auto-update nil t)
'(haml-backspace-backdents-nesting nil)
'(haml-indent-offset 4)
'(identica-display-success-messages t)
'(identica-soft-wrap-status t)
'(ido-enable-flex-matching t)
'(ido-mode 1 nil (ido))
'(indent-tabs-mode t)
'(inhibit-startup-screen t)
'(ispell-extra-args (quote ("--sug-mode=fast")))
'(ispell-list-command "--list")
'(jabber-show-offline-contacts nil)
'(jabber-show-resources nil)
'(js2-auto-indent-p t)
'(js2-bounce-indent-p t)
'(js2-cleanup-whitespace t)
'(js2-enter-indents-newline t)
'(less-css-compile-at-save t)
'(magit-auto-revert-mode nil)
'(magit-last-seen-setup-instructions "1.4.0")
'(password-cache-expiry nil)
'(php-lineup-cascaded-calls t)
'(php-mode-coding-style (quote pear))
'(php-template-compatibility nil)
'(rainbow-x-colors-major-mode-list
(quote
(emacs-lisp-mode lisp-interaction-mode c-mode c++-mode java-mode lua-mode html-helper-mode php-mode css-mode lisp-mode)))
'(recentf-mode t)
'(safe-local-variable-values
(quote
((encoding . utf-8)
(less-css-output-directory . "../css")
(less-css-compile-at-save . t))))
'(save-place t nil (saveplace))
'(scroll-conservatively 1)
'(send-mail-function (quote smtpmail-send-it))
'(show-paren-mode t)
'(show-paren-style (quote mixed))
'(size-indication-mode t)
'(sml-modeline-mode t)
'(smtpmail-smtp-server "mail.gnuchile.cl")
'(smtpmail-smtp-service 25)
'(tab-always-indent t)
'(text-mode-hook (quote (text-mode-hook-identify)))
'(tramp-chunksize 5000)
'(tramp-default-host "localhost")
'(tramp-default-method "ssh")
'(transient-mark-mode 1)
'(web-mode-enable-current-column-highlight t)
'(web-mode-enable-part-face nil)
'(which-function-mode t))
;;; after declarating cua-mode
;; yanking
;; after copy Ctrl+c in X11 apps, you can paste by `yank' in emacs
(setq x-select-enable-clipboard t)
;; after mouse selection in X11, you can paste by `yank' in emacs
(setq x-select-enable-primary t)
(setq tramp-auto-save-directory "~/tmp/emacs-auto-save")
;; disable linum
(setq linum-disabled-modes-list '(eshell-mode wl-summary-mode compilation-mode emms)) (defun linum-on () (unless (or (minibufferp) (member major-mode linum-disabled-modes-list)) (linum-mode 1)))
;;; faces
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Inconsolata" :foundry "unknown" :slant normal :weight normal :height 113 :width normal))))
'(cursor ((t (:background "green"))))
'(iedit-occurrence ((t (:background "yellow" :foreground "black"))))
'(web-mode-block-face ((t nil)))
'(web-mode-inlay-face ((t nil)))
'(web-mode-part-face ((t nil))))
;;;;;;;;;;;;;;; end general settings
;;;;;;;; Lets load the modes
;; init.el
;(require 'package)
;(package-initialize)
(load "lua-mode")
;;(load "php-mode")
(load "web-mode")
(load "flymake-easy")
(load "flymake-cursor")
(load "rainbow-mode")
(load "flycheck")
(load "tea-time")
(load "iedit")
(global-git-gutter+-mode)
(require 'git-gutter-fringe+)
(require 'ecb)
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
(require 'smartparens-config)
(sp-local-pair 'web-mode "{" "}" :actions nil)
(sp-local-pair 'web-mode "<" ">" :actions nil)
(require 'auto-complete)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)
(require 'php-auto-yasnippets)
;; (load "php-auto-yasnippets")
(define-key php-mode-map (kbd "C-c C-y") 'yas/create-php-snippet)
(payas/ac-setup)
(require 'emmet-mode)
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'css-mode-hook 'emmet-mode) ;; enable Emmet's css abbreviation.
(add-hook 'web-mode-hook 'emmet-mode) ;; enable Emmet in web-mode
(setq emmet-move-cursor-between-quotes t) ;; default nil
(require 'ac-emmet)
(add-hook 'sgml-mode-hook 'ac-emmet-html-setup)
(add-hook 'css-mode-hook 'ac-emmet-css-setup)
(require 'flymake-haml)
(require 'flymake-jslint)
(require 'flymake-json)
(require 'flymake-lua)
(require 'flymake-php)
(require 'flymake-phpcs)
(require 'flymake-shell)
(require 'flymake-jshint)
(require 'flymake-python-pyflakes)
(require 'notifications)
(require 'hl-anything)
;;(require 'hl-paren-mode)
(require 'easy-repeat)
(require 'rinari)
(global-rinari-mode)
;(require 'company) ; load company mode
;(require 'company-web-html) ; load company mode html backend
(require 'slim-mode)
;; you may key bind, for example for web-mode:
(define-key web-mode-map (kbd "C-'") 'company-web-html)
;;;;;;;;;;;;; modes loaded
;;;;;;;;;;;; modes configs
;; company-mode
(setq company-tooltip-limit 20) ; bigger popup window
(setq company-tooltip-align-annotations 't) ; align annotations to the right tooltip border
(setq company-idle-delay .3) ; decrease delay before autocompletion popup shows
(setq company-begin-commands '(self-insert-command)) ; start autocompletion only after typing
;(global-set-key (kbd "C-c /") 'company-files) ; Force complete file names on "C-c /" key
;; ssh-config-mode
(autoload 'ssh-config-mode "ssh-config-mode" t)
(add-to-list 'auto-mode-alist '(".ssh/config\\'" . ssh-config-mode))
(add-to-list 'auto-mode-alist '("sshd?_config\\'" . ssh-config-mode))
(add-hook 'ssh-config-mode-hook 'turn-on-font-lock)
;; nginx-mode
(add-to-list 'auto-mode-alist '("/etc/nginx/nginx.conf\\'" . nginx-mode))
(add-to-list 'auto-mode-alist '("/etc/nginx/sites-\\(enabled\\|available\\)/.*\\'" . nginx-mode))
;; varnish-mode
(add-to-list 'auto-mode-alist '("\\.vcl\\'" . vcl-mode))
;; markdown-mode
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
;; Associate an engine
;; A specific engine can be forced with web-mode-engines-alist.
;;;
(setq web-mode-engines-alist
'(("php" . "\\.phtml\\'")
("blade" . "\\.blade\\.")
("php" . "\\.php\\.")
)
)
(add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ctp\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ctp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.blade\\.php\\'" . web-mode))
(setq web-mode-markup-indent-offset 4)
(setq web-mode-css-indent-offset 4)
(setq web-mode-code-indent-offset 4)
(setq web-mode-indent-style 4)
(set-face-attribute 'web-mode-css-at-rule-face nil :foreground "Pink3")
;;(define-key web-mode-map (kbd "C-n") 'web-mode-tag-match)
(setq web-mode-disable-auto-pairing nil)
(setq web-mode-enable-block-face t)
(setq web-mode-enable-part-face t)
(setq web-mode-enable-comment-keywords t)
(setq web-mode-enable-heredoc-fontification t)
(setq web-mode-disable-css-colorization nil)
(setq web-mode-enable-current-element-highlight t)
(defun web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-markup-indent-offset 4)
)
(add-hook 'web-mode-hook 'web-mode-hook)
(setq web-mode-ac-sources-alist
'(
("php" . (ac-source-yasnippet ac-source-php-auto-yasnippets))
("html" . (ac-source-emmet-html-aliases ac-source-emmet-html-snippets))
("css" . (ac-source-css-property ac-source-emmet-css-snippets))))
(add-hook 'web-mode-before-auto-complete-hooks
'(lambda ()
(let ((web-mode-cur-language
(web-mode-language-at-pos)))
(if (string= web-mode-cur-language "php")
(yas-activate-extra-mode 'php-mode)
(yas-deactivate-extra-mode 'php-mode))
(if (string= web-mode-cur-language "css")
(setq emmet-use-css-transform t)
(setq emmet-use-css-transform nil)))))
;; JSX syntax highlighting for web-mode
;; from https://truongtx.me/2014/03/10/emacs-setup-jsx-mode-and-jsx-syntax-checking/
(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
;; JSX syntax checking
;; from https://truongtx.me/2014/03/10/emacs-setup-jsx-mode-and-jsx-syntax-checking/
(flycheck-define-checker jsxhint-checker
"A JSX syntax and style checker based on JSXHint."
:command ("jsxhint" source)
:error-patterns
((error line-start (1+ nonl) ": line " line ", col " column ", " (message) line-end))
:modes (web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (equal web-mode-content-type "jsx")
;; enable flycheck
(flycheck-select-checker 'jsxhint-checker)
(flycheck-mode))))
(setq flymake-python-pyflakes-executable "flake8")
(setq flycheck-tip-avoid-show-func nil)
;; web-beautify
(eval-after-load 'js2-mode
'(define-key js2-mode-map (kbd "C-c b") 'web-beautify-js))
(eval-after-load 'js3-mode
'(define-key js3-mode-map (kbd "C-c b") 'web-beautify-js))
;; Or if you're using 'js-mode' (a.k.a 'javascript-mode')
(eval-after-load 'js
'(define-key js-mode-map (kbd "C-c b") 'web-beautify-js))
(eval-after-load 'json-mode
'(define-key json-mode-map (kbd "C-c b") 'web-beautify-js))
(eval-after-load 'sgml-mode
'(define-key html-mode-map (kbd "C-c b") 'web-beautify-html))
(eval-after-load 'css-mode
'(define-key css-mode-map (kbd "C-c b") 'web-beautify-css))
;; yaml
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;; csv
(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode))
(autoload 'csv-mode "csv-mode"
"Major mode for editing comma-separated value files." t)
;;; hooks
;; emmet
;; company-mode
;; (add-hook 'after-init-hook 'global-company-mode) ;; don't wanna load everywhere
(add-hook 'web-mode-hook (lambda ()
(set (make-local-variable 'company-backends) '(company-web-html))
(company-mode t)))
;; rainbow-mode
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'php-mode-hook 'rainbow-mode)
(add-hook 'html-helper-mode-hook 'rainbow-mode)
(add-hook 'lua-mode-hook 'rainbow-mode)
(add-hook 'emacs-lisp-mode-hook 'rainbow-mode)
;; flymake
(add-hook 'haml-mode-hook 'flymake-haml-load)
(add-hook 'php-mode-hook 'flymake-php-load)
(add-hook 'php-mode-hook 'flymake-phpcs-load)
(add-hook 'lua-mode-hook 'flymake-lua-load)
(add-hook 'css-mode-hook 'flymake-css-load)
(add-hook 'js-mode-hook 'flymake-jslint-load)
(add-hook 'js2-mode-hook 'flymake-jslint-load)
(add-hook 'js3-mode-hook 'flymake-jslint-load)
(add-hook 'lua-mode-hook 'flymake-lua-load)
(add-hook 'yaml-mode-hook 'flymake-yaml-load)
(add-hook 'sh-set-shell-hook 'flymake-shell-load)
(add-hook 'js-mode-hook 'flymake-mode)
(add-hook 'js2-mode-hook 'flymake-mode)
(add-hook 'python-mode-hook 'flymake-python-pyflakes-load)
(add-hook 'yaml-mode-hook
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))
(add-hook 'tea-time-notification-hook
(lambda ()
(notifications-notify :title "Time is up!"
:body "I know you're busy, but it's TEA TIME!!"
:app-name "Tea Time"
:sound-name "alarm-clock-elapsed")))
(add-hook 'php-mode-hook (lambda () (setq comment-start "// "
comment-end ""
comment-style 'indent
comment-use-syntax t
)))
;; indent region after exit yasnippet
(add-hook 'yas/after-exit-snippet-hook
'(lambda ()
(indent-region yas/snippet-beg yas/snippet-end)))
;; I am using yasnippet in PHP mode, so, load minor mode!
(add-hook 'php-mode-hook 'yas-minor-mode)
;;;; Disable flymake during expansion
(defvar flymake-is-active-flag nil)
(defadvice yas/expand-snippet
(before inhibit-flymake-syntax-checking-while-expanding-snippet activate)
(setq flymake-is-active-flag
(or flymake-is-active-flag
(assoc-default 'flymake-mode (buffer-local-variables))))
(when flymake-is-active-flag
(flymake-mode-off)))
(add-hook 'yas/after-exit-snippet-hook
'(lambda ()
(when flymake-is-active-flag
(flymake-mode-on)
(setq flymake-is-active-flag nil))))
;;; end disable flymake during expansion
;; git-gutter+
(eval-after-load 'git-gutter+
'(progn
;;; Jump between hunks
(define-key git-gutter+-mode-map (kbd "C-x n") 'git-gutter+-next-hunk)
(define-key git-gutter+-mode-map (kbd "C-x p") 'git-gutter+-previous-hunk)
;;; Act on hunks
(define-key git-gutter+-mode-map (kbd "C-x v =") 'git-gutter+-show-hunk)
(define-key git-gutter+-mode-map (kbd "C-x r") 'git-gutter+-revert-hunks)
;; Stage hunk at point.
;; If region is active, stage all hunk lines within the region.
(define-key git-gutter+-mode-map (kbd "C-x t") 'git-gutter+-stage-hunks)
(define-key git-gutter+-mode-map (kbd "C-x c") 'git-gutter+-commit)
(define-key git-gutter+-mode-map (kbd "C-x C") 'git-gutter+-stage-and-commit)
(define-key git-gutter+-mode-map (kbd "C-x C-y") 'git-gutter+-stage-and-commit-whole-buffer)
(define-key git-gutter+-mode-map (kbd "C-x U") 'git-gutter+-unstage-whole-buffer)))
;; end git-gutter+
;;;;;;;;;;;; end modes config
;;;;;;;;;; Flymake
;; Yes, I want my copies in the same dir as the original.
;; (setq flymake-run-in-place t)
;; Nope, I want my copies in the system temp dir.
(setq flymake-run-in-place nil)
;; This lets me say where my temp dir is.
;;(setq temporary-file-directory "~/.emacs.d/tmp/")
(setq temporary-file-directory "/tmp")
;; I want to see at most the first 4 errors for a line.
(setq flymake-number-of-errors-to-display 4)
;; I want to see all errors for the line.
(setq flymake-number-of-errors-to-display nil)
;;;;;;; end flymake
;; paren-mode-helper
(defadvice show-paren-function
(after show-matching-paren-offscreen activate)
"If the matching paren is offscreen, show the matching line in the
echo area. Has no effect if the character before point is not of
the syntax class ')'."
(interactive)
(let* ((cb (char-before (point)))
(matching-text (and cb
(char-equal (char-syntax cb) ?\) )
(blink-matching-open))))
(when matching-text (message matching-text))))
;;;; the following makes a jump to code, I do not like that :/
;; (defadvice show-paren-function (after my-echo-paren-matching-line activate)
;; "If a matching paren is off-screen, echo the matching line."
;; (when (char-equal (char-syntax (char-before (point))) ?\))
;; (let ((matching-text (blink-matching-open)))
;; (when matching-text
;; (message matching-text)))))
;; end paren mode helper
;;; comment or uncomment line or region
(defun comment-or-uncomment-current-line-or-region ()
"Comments or uncomments current current line or whole lines in region."
(interactive)
(save-excursion
(let (min max)
(if (region-active-p)
(setq min (region-beginning) max (region-end))
(setq min (point) max (point)))
(comment-or-uncomment-region
(progn (goto-char min) (line-beginning-position))
(progn (goto-char max) (line-end-position))))))
(global-set-key (kbd "C-7") 'comment-or-uncomment-current-line-or-region)
;;; end comment or uncoment...
;;; EMMS
(require 'emms-setup)
(emms-standard)
(emms-default-players)
(require 'emms-source-file)
(require 'emms-source-playlist)
(require 'emms-info)
(require 'emms-cache)
(require 'emms-playlist-mode)
;; (require 'emms-mode-line)
(require 'emms-playing-time)
(require 'emms-player-mpd)
(require 'emms-playlist-sort)
(require 'emms-mark)
(require 'emms-browser)
(require 'emms-lyrics)
(require 'emms-last-played)
(require 'emms-score)
;;(require 'emms-lastfm)
(setq emms-playlist-default-major-mode 'emms-playlist-mode)
(add-to-list 'emms-track-initialize-functions 'emms-info-initialize-track)
;; (emms-mode-line 1)
;; (emms-mode-line-blank)
(emms-playing-time 1)
(emms-lyrics 1)
(add-hook 'emms-player-started-hook 'emms-last-played-update-current)
(emms-score 1)
(when (fboundp 'emms-cache) ; work around compiler warning
(emms-cache 1))
(setq emms-score-default-score 3)
(require 'emms-player-mpd)
;;Set the variables emms-player-mpd-server-name and emms-player-mpd-server-port to the location and port (respectively) of your MusicPD server. For example:
(setq emms-player-mpd-server-name "localhost")
(setq emms-player-mpd-server-port "6601")
;; If your MusicPD setup requires a password, you will to set emms-player-mpd-server-password as follows.
;;(setq emms-player-mpd-server-password "mypassword")
;; To get track information from MusicPD, invoke the following:
(add-to-list 'emms-info-functions 'emms-info-mpd)
;; Adding `emms-player-mpd' to your Emms player list is accomplished by invoking:
(add-to-list 'emms-player-list 'emms-player-mpd)
(setq emms-player-mpd-sync-playlist t)
(defvar emms-browser-info-title-format "%i%n :: %a - %A - %T. %t")
(defvar emms-browser-playlist-info-title-format
emms-browser-info-title-format)
;; Playlist format
(defun my-describe (track)
(let* ((empty "...")
(name (emms-track-name track))
(type (emms-track-type track))
(short-name (file-name-nondirectory name))
(play-count (or (emms-track-get track 'play-count) 0))
(last-played (or (emms-track-get track 'last-played) '(0 0 0)))
(artist (or (emms-track-get track 'info-artist) empty))
(year (emms-track-get track 'info-year))
(playing-time (or (emms-track-get track 'info-playing-time) 0))
(min (/ playing-time 60))
(sec (% playing-time 60))
(album (or (emms-track-get track 'info-album) empty))
(tracknumber (emms-track-get track 'info-tracknumber))
(short-name (file-name-sans-extension
(file-name-nondirectory name)))
(title (or (emms-track-get track 'info-title) short-name))
(rating (emms-score-get-score name))
(rate-char ?☭)
)
(format "%15s - %.4s [%-20s] - %2s. %-30s |%2d %s"
artist
year
album
tracknumber
title
play-count
(make-string rating rate-char)))
)
(setq emms-track-description-function 'my-describe)
;; end EMMS
;; smartparent config
;;;;;;;;;
;; global
;; (require 'smartparens-config)
(smartparens-global-mode t)
;; highlights matching pairs
(show-smartparens-global-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;
;; keybinding management
;; (define-key sp-keymap (kbd "C-M-f") 'sp-forward-sexp)
;; (define-key sp-keymap (kbd "C-M-b") 'sp-backward-sexp)
;; (define-key sp-keymap (kbd "C-M-d") 'sp-down-sexp)
;; (define-key sp-keymap (kbd "C-M-a") 'sp-backward-down-sexp)
;; (define-key sp-keymap (kbd "C-S-a") 'sp-beginning-of-sexp)
;; (define-key sp-keymap (kbd "C-S-d") 'sp-end-of-sexp)
;; (define-key sp-keymap (kbd "C-M-e") 'sp-up-sexp)
;; (define-key emacs-lisp-mode-map (kbd ")") 'sp-up-sexp)
;; (define-key sp-keymap (kbd "C-M-u") 'sp-backward-up-sexp)
;; (define-key sp-keymap (kbd "C-M-t") 'sp-transpose-sexp)
;; (define-key sp-keymap (kbd "C-M-n") 'sp-next-sexp)
;; (define-key sp-keymap (kbd "C-M-p") 'sp-previous-sexp)
;; (define-key sp-keymap (kbd "C-M-k") 'sp-kill-sexp)
;; (define-key sp-keymap (kbd "C-M-w") 'sp-copy-sexp)
;; (define-key sp-keymap (kbd "M-<delete>") 'sp-unwrap-sexp)
;; (define-key sp-keymap (kbd "M-<backspace>") 'sp-backward-unwrap-sexp)
;; (define-key sp-keymap (kbd "C-<right>") 'sp-forward-slurp-sexp)
;; (define-key sp-keymap (kbd "C-<left>") 'sp-forward-barf-sexp)
;; (define-key sp-keymap (kbd "C-M-<left>") 'sp-backward-slurp-sexp)
;; (define-key sp-keymap (kbd "C-M-<right>") 'sp-backward-barf-sexp)
;; (define-key sp-keymap (kbd "M-D") 'sp-splice-sexp)
;; (define-key sp-keymap (kbd "C-M-<delete>") 'sp-splice-sexp-killing-forward)
;; (define-key sp-keymap (kbd "C-M-<backspace>") 'sp-splice-sexp-killing-backward)
;; (define-key sp-keymap (kbd "C-S-<backspace>") 'sp-splice-sexp-killing-around)
;; (define-key sp-keymap (kbd "C-]") 'sp-select-next-thing-exchange)
;; (define-key sp-keymap (kbd "C-<left_bracket>") 'sp-select-previous-thing)
;; (define-key sp-keymap (kbd "C-M-]") 'sp-select-next-thing)
;; (define-key sp-keymap (kbd "M-F") 'sp-forward-symbol)
;; (define-key sp-keymap (kbd "M-B") 'sp-backward-symbol)
;; (define-key sp-keymap (kbd "H-t") 'sp-prefix-tag-object)
;; (define-key sp-keymap (kbd "H-p") 'sp-prefix-pair-object)
;; (define-key sp-keymap (kbd "H-s c") 'sp-convolute-sexp)
;; (define-key sp-keymap (kbd "H-s a") 'sp-absorb-sexp)
;; (define-key sp-keymap (kbd "H-s e") 'sp-emit-sexp)
;; (define-key sp-keymap (kbd "H-s p") 'sp-add-to-previous-sexp)
;; (define-key sp-keymap (kbd "H-s n") 'sp-add-to-next-sexp)
;; (define-key sp-keymap (kbd "H-s j") 'sp-join-sexp)
;; (define-key sp-keymap (kbd "H-s s") 'sp-split-sexp)
;;;;;;;;;;;;;;;;;;
;; pair management
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
;;; markdown-mode
(sp-with-modes '(markdown-mode gfm-mode rst-mode)
(sp-local-pair "*" "*" :bind "C-*")
(sp-local-tag "2" "**" "**")
(sp-local-tag "s" "```scheme" "```")
(sp-local-tag "<" "<_>" "</_>" :transform 'sp-match-sgml-tags))
;;; tex-mode latex-mode
(sp-with-modes '(tex-mode plain-tex-mode latex-mode)
(sp-local-tag "i" "\"<" "\">")
(sp-local-tag "<" "<_>" "</_>" :transform 'sp-match-sgml-tags))
;;; html-mode
(sp-with-modes '(html-mode sgml-mode)
(sp-local-pair "<" ">"))
;;; lisp modes
(sp-with-modes sp--lisp-modes
(sp-local-pair "(" nil :bind "C-("))
;; end smart parens
;; Tabbar
(require 'tabbar)
;; Tabbar settings
(set-face-attribute
'tabbar-default nil
:background "gray20"
:foreground "gray20"
:box '(:line-width 1 :color "gray20" :style nil))
(set-face-attribute
'tabbar-unselected nil
:background "gray30"
:foreground "white"
:box '(:line-width 5 :color "gray30" :style nil))
(set-face-attribute
'tabbar-selected nil
:background "gray75"
:foreground "black"
:box '(:line-width 5 :color "gray75" :style nil))
(set-face-attribute
'tabbar-highlight nil
:background "white"
:foreground "black"
:underline nil
:box '(:line-width 5 :color "white" :style nil))
(set-face-attribute
'tabbar-button nil
:box '(:line-width 1 :color "gray20" :style nil))
(set-face-attribute
'tabbar-separator nil
:background "gray20"
:height 0.6)
;; Change padding of the tabs
;; we also need to set separator to avoid overlapping tabs by highlighted tabs
(custom-set-variables
'(tabbar-separator (quote (0.5))))
;; adding spaces
(defun tabbar-buffer-tab-label (tab)
"Return a label for TAB.
That is, a string used to represent it on the tab bar."
(let ((label (if tabbar--buffer-show-groups
(format "[%s] " (tabbar-tab-tabset tab))
(format "%s " (tabbar-tab-value tab)))))
;; Unless the tab bar auto scrolls to keep the selected tab
;; visible, shorten the tab label to keep as many tabs as possible
;; in the visible area of the tab bar.
(if tabbar-auto-scroll-flag
label
(tabbar-shorten
label (max 1 (/ (window-width)
(length (tabbar-view
(tabbar-current-tabset)))))))))
;; Tabbar
;; (require 'tabbar)
;; ;; Tabbar settings
;; (set-face-attribute
;; 'tabbar-default nil
;; :background "gray20"
;; :foreground "gray20"
;; :box '(:line-width 1 :color "gray20" :style nil))
;; (set-face-attribute
;; 'tabbar-unselected nil
;; :background "gray30"
;; :foreground "white"
;; :box '(:line-width 5 :color "gray30" :style nil))
;; (set-face-attribute
;; 'tabbar-selected nil
;; :background "gray75"
;; :foreground "black"
;; :box '(:line-width 5 :color "gray75" :style nil))
;; (set-face-attribute
;; 'tabbar-highlight nil
;; :background "white"
;; :foreground "black"
;; :underline nil
;; :box '(:line-width 5 :color "white" :style nil))
;; (set-face-attribute
;; 'tabbar-button nil
;; :box '(:line-width 1 :color "gray20" :style nil))
;; (set-face-attribute
;; 'tabbar-separator nil
;; :background "gray20"
;; :height 0.6)
;; ;; Change padding of the tabs
;; ;; we also need to set separator to avoid overlapping tabs by highlighted tabs
;; (custom-set-variables
;; '(tabbar-separator (quote (0.5))))
;; ;; adding spaces
;; (defun tabbar-buffer-tab-label (tab)
;; "Return a label for TAB.
;; That is, a string used to represent it on the tab bar."
;; (let ((label (if tabbar--buffer-show-groups
;; (format "[%s] " (tabbar-tab-tabset tab))
;; (format "%s " (tabbar-tab-value tab)))))
;; ;; Unless the tab bar auto scrolls to keep the selected tab
;; ;; visible, shorten the tab label to keep as many tabs as possible
;; ;; in the visible area of the tab bar.
;; (if tabbar-auto-scroll-flag
;; label
;; (tabbar-shorten
;; label (max 1 (/ (window-width)
;; (length (tabbar-view
;; (tabbar-current-tabset)))))))))
;; (tabbar-mode 1)
(require 'tabbar)
(setq tabbar-use-images nil)
(tabbar-mode t)
(setq tabbar-cycle-scope 'tabs)
(setq tabbar-buffer-groups-function
(lambda ()
(list "All")))
;; (setq tabbar-buffer-groups-function
;; (lambda ()
;; (let ((dir (expand-file-name default-directory)))
;; (cond ((member (buffer-name) '("*Completions*"
;; "*scratch*"
;; "*Messages*"
;; "*Ediff Registry*"))
;; (list "#misc"))
;; ((string-match-p "/.emacs.d/" dir)
;; (list ".emacs.d"))
;; (t (list dir))))))
(global-set-key [C-prior] 'tabbar-backward-tab)
(global-set-key [C-next] 'tabbar-forward-tab)