-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdot-emacs.el
More file actions
1603 lines (1307 loc) · 52.3 KB
/
dot-emacs.el
File metadata and controls
1603 lines (1307 loc) · 52.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
(message "***** .emacs loading *****")
(defvar emacs-root
(if (eq system-type 'windows-nt)
"C:/users/kirath/"
"~/"))
(add-to-list 'load-path (concat emacs-root "emacs-misc"))
;; ------------------------------------------------------------
;; Install missing packages
;; http://stackoverflow.com/a/10093312
;; http://stackoverflow.com/a/10095853
(setq package-list '(magit
highlight-indentation
pp-c-l
bookmark+
key-chord
ledger-mode
jinja2-mode
inf-ruby
coffee-mode
eproject
py-autopep8
highlight-chars
virtualenv
virtualenvwrapper
ace-jump-mode
js2-mode
yaml-mode
rainbow-blocks
restclient
ox-gfm
haskell-mode
flycheck
ag
projectile
alchemist
ace-window
go-mode
use-package
markdown-mode
dart-mode
py-isort
dumb-jump
vue-mode
web-mode
))
(setq package-archives '(("elpa" . "http://tromey.com/elpa/")
("melpa" . "http://melpa.milkbox.net/packages/")))
;; 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)
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package))))
;; ------------------------------------------------------------
;; (require 'cl)
;(global-set-key "\C-x\C-m" 'execute-extended-command) ;use chord xm
;(define-key global-map [f8] 'kill-region) ;use chord fk
(global-set-key "\C-w" 'backward-kill-word)
(define-key global-map [f9]
(lambda ()
(interactive)
(switch-to-buffer "*scratch*")
)
)
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(global-set-key [f5] 'call-last-kbd-macro)
(global-set-key [f6] 'magit-status)
;; tab
;; http://student.northpark.edu/pemente/emacs_tabs.htm
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
;; karl at wmt uses tabs
;; this will help avoid http://www.emacswiki.org/emacs/TabsSpacesBoth
(add-hook 'ruby-mode-hook
(lambda ()
(setq indent-tabs-mode t)
))
;; (setq ruby-indent-tabs-mode t)
;; http://www.emacs.uniyar.ac.ru/doc/em24h/emacs100.htm
(setq show-paren-mode t)
(setq show-paren-style 'parenthesis)
;; --- to learn from ---
;; http://www.emacswiki.org/cgi-bin/wiki/emacs-init.el
;; this url seems to be a good resource
(setq inhibit-startup-message t)
;; http://homepages.inf.ed.ac.uk/s0243221/emacs/
;; http://tldp.org/HOWTO/Emacs-Beginner-HOWTO-4.html
(defun alt-colors-1 ()
(progn
(set-cursor-color "Orchid")
(set-mouse-color "Orchid")
(set-background-color "DarkSlateGray")
(set-foreground-color "Wheat")
(blink-cursor-mode 0)
(global-hl-line-mode 1)
))
;; lines
(setq scroll-step 1)
(line-number-mode 1)
(column-number-mode 1)
;; backup
(setq make-backup-files t)
(setq version-control t)
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
;; auto-save files
;; http://stackoverflow.com/a/2020954/2221101
(setq auto-save-default t)
(defvar autosave-dir (expand-file-name "~/.emacs_autosave/"))
(setq auto-save-file-name-transforms `((".*" ,autosave-dir t)))
;; ----------------------------------------
;; paren hilite
;; http://www.emacsblog.org/2007/08/07/quick-tip-show-paren-mode/
(show-paren-mode t)
;(setq show-paren-style 'expression)
(setq show-paren-style 'parenthesis)
;; http://www.math.umn.edu/~garrett/shortest/emacs_customization.html
(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.
'(package-selected-packages
'(magit web-mode-edit-element web-mode helm-open-github sql-indent markdown-mode use-package go-mode ace-window ag realgud yafolding alchemist projectile rjsx-mode haskell-mode ox-gfm restclient rainbow-blocks yaml-mode js2-mode virtualenvwrapper virtualenv py-autopep8 pp-c-l ledger-mode key-chord jinja2-mode inf-ruby highlight-indentation highlight-chars eproject coffee-mode bookmark+ ace-jump-mode))
'(tramp-syntax 'default nil (tramp)))
(defun alt-colors-2 ()
(progn
(set-background-color "DimGray")
(set-foreground-color "LightGray")
(set-cursor-color "DarkSlateBlue")
(set-border-color "DimGray")
(set-mouse-color "DarkSlateBlue")
(set-face-background 'default "DimGray")
(set-face-background 'region "DarkSlateGray")
(set-face-background 'highlight "DarkSlateBlue")
(set-face-background 'modeline "DarkSlateBlue") ;;; CornflowerBlue")
(set-face-foreground 'default "LightGray")
(set-face-foreground 'region "Ivory")
(set-face-foreground 'highlight "LightGray") ;;; DimGray")
(set-face-foreground 'modeline "LightGray")
))
(setq-default delete-old-versions 't)
;(alt-colors-2)
(alt-colors-1)
(dired emacs-root)
(rename-buffer "dired1")
;(shell)
;(find-file (concat emacs-root ".emacs"))
(find-file (concat emacs-root "ppp/emacs-kiru/dot-emacs.el"))
;; ----------------------------------------
;; http://www.zafar.se/bkz/Articles/EmacsTips
(add-hook 'isearch-mode-end-hook 'custom-goto-match-beginning)
(defun custom-goto-match-beginning ()
"Use with isearch hook to end search at first char of match."
(when isearch-forward (goto-char isearch-other-end)))
;; ----------------------------------------
(setq resize-minibuffer-mode t)
;; ----------------------------------------
;; http://www.emacswiki.org/cgi-bin/wiki/EmacsNiftyTricks#toc3
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
(cl-flet ((process-list ())) ad-do-it))
(fset 'yes-or-no-p 'y-or-n-p)
;repl for elisp
(ielm)
;; ----------------------------------------
;; http://common-lisp.net/project/slime/doc/html/Installation.html#Installation
;; slime
;; installation:
;; apt-get install sbcl sbcl-doc sbcl-source slime
;; bookmark: [transcript of marco baringer's slime movie]
;; http://www.pchristensen.com/blog/articles/reference-for-the-slimelispemacs-screencast/#comment-144
(if (eq system-type 'windows-nt)
(progn
;; (message "i am starting slime")
;; (setq inferior-lisp-program "C:/sbcl-1.0.19/sbcl.exe --core C:/sbcl-1.0.19/sbcl.core")
;; (add-to-list 'load-path "C:/slime")
;; (require 'slime)
;; (slime-setup)
;; (slime-setup '(slime-fancy slime-asdf))
;; (slime)
;; (setq slime-startup-animation nil)
)
(progn
;; [May 04, 2013 18:44] - disabling slime as "Polling /tmp/slime.5268" message persists in the minibuffer
;; (message "i am starting slime")
;; (setq inferior-lisp-program "/usr/bin/sbcl")
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/slime")
;; (require 'slime)
;; (slime-setup)
;; (slime-setup '(slime-fancy slime-asdf))
;; ;(slime-setup '(slime-fancy slime-asdf slime-js))
;; (slime)
;; ; http://www.jasondunsmore.com/emacs/dotemacs.txt
;; (setq slime-startup-animation nil)
))
;; color theme
;; http://www.emacswiki.org/cgi-bin/wiki?ColorTheme
;; http://www.cs.cmu.edu/~maverick/GNUEmacsColorThemeTest/
;(require 'color-theme)
;(color-theme-initialize)
;(color-theme-robin-hood)
;(color-theme-subtle-hacker)
;; ; w3m
;; ; http://www.emacswiki.org/cgi-bin/emacs-en/emacs-w3m
;; ; http://emacs-w3m.namazu.org/
;; ; note : worked when i used the dev branch instead of the stable branch for w3m.el
;; (if (eq system-type 'windows-nt)
;; (message "i am skipping w3m")
;; (progn
;; (message "i am starting w3m")
;; ;(add-to-list 'load-path (concat emacs-root "emacs/emacs-w3m-1.4.4"))
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/w3m")
;; (require 'w3m-load)
;; (setq browse-url-browser-function 'w3m-browse-url)
;; (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;; (global-set-key "\C-xm" 'browse-url-at-point)))
;(define-key global-map [f11] 'hexl-find-file)
;(define-key global-map [f12] 'compare-windows)
(global-set-key [kp-subtract] "\C-a\C-k\C-d") ; numpad minus = nuke line
;; Apr 26, 2013 - commented out the following section as emacs said:
;; "Package pgg-gpg is obsolete!"
;;
;; ; auto encryption - begin
;; ; http://www.emacswiki.org/cgi-bin/wiki/AutoEncryption
;; (defvar pgg-gpg-user-id "kirubakaran")
;; (autoload 'pgg-make-temp-file "pgg" "PGG")
;; (autoload 'pgg-gpg-decrypt-region "pgg-gpg" "PGG GnuPG")
;; (define-generic-mode 'gpg-file-mode
;; (list ?#)
;; nil nil
;; '(".gpg\\'" ".gpg-encrypted\\'")
;; (list (lambda ()
;; (add-hook 'before-save-hook
;; (lambda ()
;; (let ((pgg-output-buffer (current-buffer)))
;; (pgg-gpg-encrypt-region (point-min) (point-max)
;; (list pgg-gpg-user-id))))
;; nil t)
;; (add-hook 'after-save-hook
;; (lambda ()
;; (let ((pgg-output-buffer (current-buffer)))
;; (pgg-gpg-decrypt-region (point-min) (point-max)))
;; (set-buffer-modified-p nil)
;; (auto-save-mode nil))
;; nil t)
;; (let ((pgg-output-buffer (current-buffer)))
;; (pgg-gpg-decrypt-region (point-min) (point-max)))
;; (auto-save-mode nil)
;; (set-buffer-modified-p nil)))
;; "Mode for gpg encrypted files")
;; ; auto encryption - end
(require 'epa-file)
(epa-file-enable)
;; ----------------------------------------
;; set window title to contain the current buffer name
;; this is so that rescue-time can see what buffer I am in
;; I don't want everything I do in emacs to be classified as 'dev work'
;(defadvice switch-to-buffer (after name-the-frame (arg))
;; (set-frame-name (concat (buffer-name) " - emacs")))
;
;(ad-activate 'switch-to-buffer)
;; a method that wasn't sufficient:
;(global-set-key [f10]
;; '(lambda ()
;; (interactive)
;; (set-frame-name (concat "emacs : " (buffer-name)))))
;; a method that didn't work:
;(global-set-key "\C-xb"
;; '(lambda (buffer &optional norecord)
;; (interactive)
;; (set-frame-name (concat "emacs : " (buffer-name)))
;; (switch-to-buffer buffer norecord)))
;; references:
;; http://www.gnu.org/software/emacs/elisp/html_node/Advising-Functions.html#Advising-Functions
;; http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/9e50dd3a196c86c8
;; ----------------------------------------
;(split-window-horizontally)
;; cygwin
;; http://www.khngai.com/emacs/cygwin.php
(if (eq system-type 'windows-nt)
(progn
(setenv "PATH" (concat (getenv "PATH") ";C:\\users\\kirath\\cygwin\\bin"))
(setq exec-path (cons "c:/users/kirath/cygwin/bin/" exec-path))
(require 'cygwin-mount)
(cygwin-mount-activate)
;; Replace DOS shell with Cygwin Bash Shell
(add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t)
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt nil t)
(setq explicit-shell-file-name "bash.exe")
;; For subprocesses invoked via the shell
;; (e.g., "shell -c command")
(setq shell-file-name explicit-shell-file-name)))
;; ------------------------------------------------------------
;; python mode
;; http://www.emacswiki.org/cgi-bin/wiki/PythonMode
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (define-key python-mode-map "\"" 'electric-pair)
;; (define-key python-mode-map "\'" 'electric-pair)
;; (define-key python-mode-map "(" 'electric-pair)
;; (define-key python-mode-map "[" 'electric-pair)
;; (define-key python-mode-map "{" 'electric-pair)))
;; (defun electric-pair ()
;; "Insert character pair without sournding spaces"
;; (interactive)
;; (let (parens-require-spaces)
;; (insert-pair)))
;; ------------------------------------------------------------
;; ------------------------------------------------------------
;; open my files
;; (message "i am loading files from thumb drive")
;; (defun thumbdrive ()
;; (if (eq system-type 'windows-nt)
;; '"f:/"
;; '"/media/HANZO\ SWORD/"))
;; (defun open-file-if-exists (file1)
;; (when (file-readable-p file1)
;; (find-file file1)))
;; (defun oife (file1)
;; (open-file-if-exists (concat (thumbdrive) "Performance/" file1)))
;; (mapc 'oife
;; (list
;; "done.txt"
;; "goals.txt"
;; "ideas.txt"
;; "startup-log.txt"
;; "try-new-habits.org"
;; "todo.txt"))
;; ------------------------------------------------------------
(defun my-date ()
(interactive)
(insert
(my-date-str)))
(defun my-date-str ()
(concat "[" (format-time-string "%b %d, %Y %H:%M") "] "))
(defun my-time ()
(interactive)
(insert
(my-time-str)))
(defun my-time-str ()
(concat "[" (format-time-string "Time %H:%M") "] "))
(defun my-just-date ()
(interactive)
(insert
(format-time-string "%b %d")))
(defun iso-date-str ()
(concat
(format-time-string "%Y-%m-%dT%T")
(concat
(substring (format-time-string "%z") 0 3)
":"
(substring (format-time-string "%z") 3))))
(defun isodt ()
(interactive)
(insert
(iso-date-str)))
(define-key global-map [f3] 'my-time)
(define-key global-map [S-f3] 'my-date)
(define-key global-map [C-f3] 'my-just-date)
;; ------------------------------------------------------------
;; ---
;; copy line without selection
;; http://www.emacswiki.org/cgi-bin/wiki/CopyWithoutSelection
(defun copy-line (&optional arg)
"Save current line into Kill-Ring without mark the line "
(interactive "P")
(let ((beg (line-beginning-position))
(end (line-end-position arg)))
(copy-region-as-kill beg end)))
(global-set-key (kbd "C-c l") 'copy-line)
;; ---
;; (defun totd ()
;; (interactive)
;; (random t) ;; seed with time-of-day
;; (with-output-to-temp-buffer "*Tip of the day*"
;; (let* ((commands (loop for s being the symbols
;; when (commandp s) collect s))
;; (command (nth (random (length commands)) commands)))
;; (princ
;; (concat "Your tip for the day is:\n"
;; "========================\n\n"
;; (describe-function command)
;; "\n\nInvoke with:\n\n"
;; (with-temp-buffer
;; (where-is command t)
;; (buffer-string)))))))
;; (totd)
;; ------------------------------------------------------------
;; http://mail.python.org/pipermail/python-list/2007-October/464038.html
(defun my-file-processing-fn (fpath)
"\nelisp file processing function. \nKill word that occurs after kite and hoo. \n~Kirubakaran\n"
(interactive)
(let (mybuffer)
(setq mybuffer (find-file fpath))
(search-forward "kite")
(search-forward "hoo")
(kill-word (point))
(save-buffer)
(kill-buffer mybuffer)))
;; ------------------------------------------------------------
;; ------------------------------------------------------------
;; http://www3.ntu.edu.sg/home5/pg04878518/EmacsTools.html
;;(require 'ido)
;;(ido-mode t)
;;(setq ido-enable-flex-matching t)
;;(setq ido-create-new-buffer 'always)
;(require 'browse-kill-ring)
;(global-set-key [(control c)(k)] 'browse-kill-ring)
;(browse-kill-ring-default-keybindings)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
;commenting coz this only turned out to be a nuisance in my non-lisp coding
;(global-set-key "%" 'match-paren)
(require 'generic)
(require 'generic-x)
(if (not (eq system-type 'windows-nt))
(setq x-select-enable-clipboard 't))
(autoload 'gtypist-mode "gtypist-mode")
(setq auto-mode-alist
(cons '("\\.typ\\'" . gtypist-mode) auto-mode-alist))
;; ------------------------------------------------------------
(if (eq system-type 'windows-nt)
(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
(:stipple nil
:background "DarkSlateGray"
:foreground "Wheat"
:inverse-video nil
:box nil
:strike-through nil
:overline nil
:underline nil
:slant normal
:weight normal
:height 140
:width normal
:family "outline-consolas"))))))
;; (require 'python-mode)
;; ;(require 'ipython)
;; (setq py-shell-name "ipython")
;; (setq ipython-command "/usr/bin/ipython")
;; ;(setq py-python-command-args '("-pylab" "-colors" "LightBG"))
;; ;(setq-default py-python-command-args '("--colors=LightBG"))
;; (setq-default py-python-command-args '("--colors=Linux"))
;experimental
;(add-to-list 'load-path (concat emacs-root "emacs/g-client"))
;(load-library "g")
;; makes line into
;; +------+
;; | line |
;; +------+
(global-set-key [f7] 'k_box)
(defun k_box ()
(interactive)
(setq cur_line (thing-at-point 'line))
;delete trailing newline
(if (string=
(substring cur_line -1)
"\n")
(progn
(setq cur_line
(substring cur_line 0 (- (length cur_line) 1)))))
(setq ins_line (concat "| " cur_line " |\n"))
(setq border_line
(concat "+"
(make-string (- (length ins_line) 3) ?-)
"+"))
(beginning-of-line)
(kill-line)
(insert
border_line
"\n"
ins_line
border_line
"\n"))
;; escreen
;; 2014-07-04 not needed as i now use xmonad to manage
;; even emacs frames
;; (load "escreen")
;; (escreen-install)
;; (global-set-key (kbd "<s-prior>") 'escreen-goto-prev-screen)
;; (global-set-key (kbd "<s-next>") 'escreen-goto-next-screen)
(delete-selection-mode t)
;; CSS color values colored by themselves
;; http://xahlee.org/emacs/emacs_html.html
(defvar hexcolour-keywords
'(("#[abcdef[:digit:]]\\{6\\}"
(0 (put-text-property
(match-beginning 0)
(match-end 0)
'face (list :background
(match-string-no-properties 0)))))))
(defun hexcolour-add-to-font-lockfont-lock ()
(font-lock-add-keywords nil hexcolour-keywords))
(add-hook 'css-mode-hook 'hexcolour-add-to-font-lock)
;; end
(global-set-key "\C-x\C-b" 'ibuffer) ; was list-buffers ;use chord xb
;; make emacs fonts bigger
;; :height 100 ===> 10px
;; http://stackoverflow.com/questions/294664/how-to-set-the-font-size-in-emacs
(set-face-attribute 'default nil :height 110)
;; Use a better font
(when (string= system-name "hulk")
(set-default-font "Inconsolata-16"))
;; Zap-back-to-char
;; http://www.reddit.com/r/programming/comments/8lfx7/what_emacs_commands_do_you_use_most_and_find_most/c09p0ut
;; kiru : doesn't seem to work
;; (global-set-key "\C-\M-z" #'(lambda (arg char) (interactive "p\ncZap to char: ") (zap-to-char (- arg) char)))
(setq eshell-save-history-on-exit t)
;; windmove
;; http://news.ycombinator.com/item?id=1080253
;; http://hovav.net/elisp/
;; http://www.emacswiki.org/emacs/WindMove
(windmove-default-keybindings 'control)
;; chrome <--> emacs
;(require 'edit-server)
;(edit-server-start)
;(require 'org-babel-init)
;full screen / maximize
;http://ubuntuforums.org/showthread.php?t=782196
(defun toggle-fullscreen ()
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
)
;(toggle-fullscreen)
;(global-unset-key [left])
;(global-unset-key [right])
;(global-unset-key [up])
;(global-unset-key [down])
;(global-unset-key [prior])
;(global-unset-key [next])
(global-unset-key [home])
(global-unset-key [end])
;; ------------------------------------------------------------
;; http://stackoverflow.com/questions/1839313/
;; key : a
(put 'dired-find-alternate-file 'disabled nil)
;; http://www.emacswiki.org/emacs/PrettyControlL
(defvar pp^L-^L-string-function
(lambda (win) (make-string (1- (window-width win)) ?_)))
(put 'set-goal-column 'disabled nil)
;; http://code.google.com/p/yasnippet/
;; (add-to-list 'load-path (concat emacs-root "emacs/plugins/yasnippet-0.6.1c"))
;; (require 'yasnippet)
;; (yas/initialize)
;; (yas/load-directory (concat emacs-root "emacs/plugins/yasnippet-0.6.1c/snippets"))
;; (setq yas/prompt-functions
;; '(yas/ido-prompt yas/x-prompt))
;; ------------------------------------------------------------
;; http://www.djcbsoftware.nl/dot-emacs.html
;; when using ido, the confirmation is rather annoying...
(setq confirm-nonexistent-file-or-buffer nil)
;; increase minibuffer size when ido completion is active
;; (add-hook 'ido-minibuffer-setup-hook
;; (function
;; (lambda ()
;; (make-local-variable 'resize-minibuffer-window-max-height)
;; (setq resize-minibuffer-window-max-height 1))))
(global-set-key (kbd "M-g") 'goto-line)
;; ------------------------------------------------------------
;; http://box.matto.nl/emacsgmail.html
;; wanderlust
(autoload 'wl "wl" "Wanderlust" t)
(autoload 'wl-other-frame "wl" "Wanderlust on new frame." t)
(autoload 'wl-draft "wl-draft" "Write draft with Wanderlust." t)
;; IMAP
(setq elmo-imap4-default-server "imap.gmail.com")
(setq elmo-imap4-default-user "kulalosai@gmail.com")
(setq elmo-imap4-default-authenticate-type 'clear)
(setq elmo-imap4-default-port '993)
(setq elmo-imap4-default-stream-type 'ssl)
(setq elmo-imap4-use-modified-utf7 t)
;; SMTP
(setq wl-smtp-connection-type 'starttls)
(setq wl-smtp-posting-port 587)
(setq wl-smtp-authenticate-type "plain")
(setq wl-smtp-posting-user "kulalosai")
(setq wl-smtp-posting-server "smtp.gmail.com")
(setq wl-local-domain "gmail.com")
(setq wl-default-folder "%inbox")
(setq wl-default-spec "%")
(setq wl-draft-folder "%[Gmail]/Drafts") ; Gmail IMAP
(setq wl-trash-folder "%[Gmail]/Trash")
(setq wl-folder-check-async t)
(setq elmo-imap4-use-modified-utf7 t)
(autoload 'wl-user-agent-compose "wl-draft" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent 'wl-user-agent))
(if (fboundp 'define-mail-user-agent)
(define-mail-user-agent
'wl-user-agent
'wl-user-agent-compose
'wl-draft-send
'wl-draft-kill
'mail-send-hook))
;; ------------------------------------------------------------
;; http://www.djcbsoftware.nl/dot-emacs.html
;; restore window configuration
(require 'winner)
(setq winner-dont-bind-my-keys t) ;; winner conflicts with org
(global-set-key (kbd "<s-left>") 'winner-undo)
(global-set-key (kbd "<XF86Forward>") 'winner-redo)
(global-set-key (kbd "<s-right>") 'winner-redo)
(global-set-key (kbd "<XF86Back>") 'winner-undo)
(winner-mode t)
(size-indication-mode t)
;; uniquify: unique buffer names
(require 'uniquify) ;; make buffer names more unique
(setq
uniquify-buffer-name-style 'post-forward
uniquify-separator ":"
uniquify-after-kill-buffer-p t
uniquify-ignore-buffers-re "^\\*")
;; http://emacs-fu.blogspot.com - same guy as http://www.djcbsoftware.nl/dot-emacs.html
(setq cua-enable-cua-keys nil) ;; only for rectangles
(cua-mode t)
(setq delete-by-moving-to-trash t) ; moves file to ~/.Trash on delete
(setq save-place-file "~/.emacs.d/saveplace") ;; keep my ~/ clean
(save-place-mode 1)
;; http://garage.pimentech.net/libcommonDjango_django_emacs/
;;(autoload 'django-html-mode "django-html-mode")
;; (add-to-list 'auto-mode-alist '("\\.[sx]?html?\\'" . html-mode))
;
;; (add-to-list 'auto-mode-alist '("\\.[sx]?html?\\'" . jinja2-mode))
;; ; start emacs server
;; ; http://ipython.scipy.org/doc/rel-0.9.1/html/config/initial_config.html
;; (defvar server-buffer-clients)
;; ;(when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
;; (when (fboundp 'server-start)
;; (server-start)
;; (defun fp-kill-server-with-buffer-routine ()
;; (and server-buffer-clients (server-done)))
;; (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
;; C-a once command beginning and twice to line beginning
;; http://www.emacswiki.org/emacs/EshellFunctions
(defun eshell-maybe-bol ()
(interactive)
(let ((p (point)))
(eshell-bol)
(if (= p (point))
(beginning-of-line))))
(add-hook 'eshell-mode-hook
'(lambda () (define-key eshell-mode-map "\C-a" 'eshell-maybe-bol)))
;; [Apr 09, 2013] I'm going to use https://github.com/mooz/js2-mode
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; fixing js2-mode indentation
;; bottom of : https://github.com/mitchellh/dotfiles/blob/master/emacs.d/modes.el
;; thanks to : http://news.ycombinator.com/item?id=1952346
(setq js-indent-level 2)
(setq js2-basic-offset 2)
(setq js2-cleanup-whitespace t)
;http://stackoverflow.com/questions/88399/how-do-i-duplicate-a-whole-line-in-emacs
(defun duplicate-line()
(interactive)
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(next-line 1)
(yank)
(back-to-indentation)
)
(global-set-key (kbd "C-S-f") 'duplicate-line)
(global-set-key (kbd "C-S-a") 'align-regexp)
(put 'narrow-to-region 'disabled nil)
(global-set-key "\C-ch" 'highlight-indentation)
;Erlang
;http://parijatmishra.wordpress.com/2008/08/15/up-and-running-with-emacs-erlang-and-distel/
;; temporarily disabling this [Jul 04, 2014 12:05]
;; (push "/home/kiru/emacs-misc/distel/elisp" load-path)
;; (require 'erlang-start)
;; (require 'distel)
;; (distel-setup)
(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.
)
;(load-file "/home/kiru/opt/dvc/++build/dvc-load.el")
(setq dired-listing-switches "-alk")
;(require 'dired+)
(global-set-key (kbd "M-/") 'hippie-expand)
(require 'bookmark+)
;; (require 'google)
;; (setq google-license-key "ABQIAAAAX24y9sOWkGb05hZfRXyLqhQMUf-zCmQEDwv1N16oyUFq57qOsBRRq3EREDeLpkl2ki4azX9DIGjX5g" ; optional
;; google-referer "http://www.kirubakaran.com/") ; required!
;; (google-search-video "rickroll")
;; keychord
;; http://www.emacswiki.org/emacs/download/key-chord.el
(require 'key-chord)
(key-chord-mode 1)
;(key-chord-define-global "xm" 'execute-extended-command)
;;(key-chord-define-global "xo" 'other-window)
(key-chord-define-global "xo" 'ace-window)
(key-chord-define-global "xb" 'ibuffer)
(key-chord-define-global "fk" 'kill-region)
(key-chord-define-global "zl" 'insert-console-log)
(key-chord-define-global "zk" 'insert-js-fn)
(key-chord-define-global "z'" 'insert-pdb-break)
;(key-chord-define-global "ms" 'magit-status)
;(key-chord-define-global "fs" 'save-buffer)
;(key-chord-define-global "fb" 'ido-switch-buffer)
(global-set-key "\C-cr" 'remember)
(defun insert-console-log ()
"Insert 'console.log' into buffer"
(interactive)
(insert "console.log();")
(backward-char)
(backward-char)
)
(defun insert-pdb-break ()
"Insert pdb breakpoint"
(interactive)
(end-of-line)
(newline-and-indent)
(insert "import pdb;pdb.set_trace()")
)
(defun insert-js-fn ()
"Insert js function into buffer"
(interactive)
(insert "function () {}")
(backward-char)(backward-char)(backward-char)(backward-char)
)
;; http://orgmode.org/worg/org-hacks.html
(defun my-org-extract-link ()
"Extract the link location at point and put it on the killring."
(interactive)
(when (org-in-regexp org-bracket-link-regexp 1)
(setq link (org-link-unescape (org-match-string-no-properties 1)))
(message (concat "In kill ring : " link))
(kill-new link)))
(defun org_setup ()
(progn
(setq org-directory "/home/kiru/Documents/org")
(setq org-default-notes-file
(concat org-directory "/notes.org"))
(define-key global-map "\C-cc" 'org-capture)
(define-key global-map "\C-cl" 'org-store-link)
;; (add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'org-mode-hook 'auto-fill-mode)
(add-hook 'org-mode-hook
(lambda ()
(local-set-key "\C-ck" 'my-org-extract-link)))
(setq sentence-end-double-space nil) ; fixing fill
(key-chord-define org-mode-map "fl" 'collapse-to-title-wrap)
(setq org-clock-modeline-total 'current)
))
(org-babel-do-load-languages
'org-babel-load-languages
'(
(python . t)
(ruby . t)
(sqlite . t)
(js . t)
))
(message "Emacs version 23/24 check")
(if (> emacs-major-version 23)
(progn
(message "in >23")
;; expand emacs package manager with community contributed packages
;; http://sachachua.com/blog/2011/01/emacs-24-package-manager/
(require 'package)
;; Add the original Emacs Lisp Package Archive
(add-to-list 'package-archives
'("elpa" . "http://tromey.com/elpa/"))
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/"))
;; Add the user-contributed repository
;; (add-to-list 'package-archives
;; '("marmalade" . "http://marmalade-repo.org/packages/"))
;; using melpa instead of marmalade [May 28, 2014 10:02]
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(eval-after-load "org"
'(progn
(org_setup)
)))
(progn
(message "in <=23")
(require 'org)
(org_setup)
)
)
;; doesn't seem to be working
;; --------------------------
;; plan9 style eshell
;; http://www.masteringemacs.org/articles/2010/12/13/complete-guide-mastering-eshell/
(require 'eshell)
(require 'em-smart)
(setq eshell-where-to-jump 'begin)
(setq eshell-review-quick-commands nil)
(setq eshell-smart-space-goes-to-end t)
;; use dpkg -L ledger-el to see where it is installed
;; 2012-jun-18 - note: i couldn't find ledger.el in the system
;; 2012-jun-18 - so i copied it from github /usr/share/emacs/site-lisp/
(add-hook
'ledger-mode-hook
(lambda ()
(local-set-key (kbd "C-c =") 'ledger-align-amounts)))
;temporarily commented out for better presentation
;; ; http://www.nongnu.org/color-theme/
;; (add-to-list 'load-path (concat emacs-root "emacs/color-theme-6.6.0"))
;; (require 'color-theme)
;; (eval-after-load "color-theme"