-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.emacs.el
2233 lines (2066 loc) · 83.1 KB
/
.emacs.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
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
(setq load-prefer-newer t)
(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.
'(custom-safe-themes (quote ("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" default)))
'(display-time-world-list (quote (("America/Chicago" "Chicago") ("Asia/Kolkata" "Kolkata") ("Asia/Kuala_Lumpur" "Kuala Lumpur"))))
'(ess-R-font-lock-keywords (quote ((ess-R-fl-keyword:modifiers . t) (ess-R-fl-keyword:fun-defs . t) (ess-R-fl-keyword:keywords . t) (ess-R-fl-keyword:assign-ops . t) (ess-R-fl-keyword:constants . t) (ess-fl-keyword:fun-calls) (ess-fl-keyword:numbers) (ess-fl-keyword:operators) (ess-fl-keyword:delimiters) (ess-fl-keyword:= . t) (ess-R-fl-keyword:F&T))))
'(inferior-R-font-lock-keywords (quote ((ess-S-fl-keyword:prompt . t) (ess-R-fl-keyword:messages . t) (ess-R-fl-keyword:modifiers . t) (ess-R-fl-keyword:fun-defs . t) (ess-R-fl-keyword:keywords . t) (ess-R-fl-keyword:assign-ops . t) (ess-R-fl-keyword:constants . t) (ess-fl-keyword:matrix-labels . t) (ess-fl-keyword:fun-calls) (ess-fl-keyword:numbers) (ess-fl-keyword:operators) (ess-fl-keyword:delimiters) (ess-fl-keyword:= . t) (ess-R-fl-keyword:F&T))))
'(linum-format "%5d")
'(osx-browse-guess-keystrokes (quote ("s-b k")))
'(osx-browse-url-keystrokes (quote ("s-b u"))))
(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.
'(anzu-mode-line ((t (:foreground "#073642" :weight bold)))))
(defun gcr/emacs-version-check ()
"Enforce version compliance."
(interactive)
(when (not (and (= emacs-major-version 24)
(= emacs-minor-version 4)))
(error
"Incorrect Emacs runtime. Expected v24.4. Found v%s.%s"
(number-to-string emacs-major-version)
(number-to-string emacs-minor-version))))
(gcr/emacs-version-check)
(package-initialize)
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/") t)
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-refresh-contents)
(unless (package-installed-p 'package+)
(package-install 'package+))
(package-manifest
'ace-jump-mode
'ace-link
'ace-window
'aggressive-indent
'alert
'anchored-transpose
'anzu
'ascii-art-to-unicode
'auctex
'auto-complete
'auto-complete-chunk
'autotetris-mode
'boxquote
'clips-mode
'ctable
'diff-hl
'diminish
'dired-details+
'dired-imenu
'ess
'ess-R-data-view
'ess-R-object-popup
'esup
'exec-path-from-shell
'expand-region
'f
'figlet
'fill-column-indicator
'flx-ido
'flycheck
'fuzzy
'geiser
'google-this
'graphviz-dot-mode
'highlight-tail
'htmlize
'ido-hacks
'ido-ubiquitous
'ido-vertical-mode
'imenu+
'imenu-anywhere
'inlineR
'json-reformat
'key-chord
'langtool
'lexbind-mode
'magit
'markdown-mode
'metaweblog
'move-text
'multiple-cursors
'neotree
'nyan-mode
'ob-sml
'org-ac
'org-plus-contrib
'osx-browse
'package+
'pandoc-mode
'plantuml-mode
'polymode
'pos-tip
'pretty-mode
'projectile
'r-autoyas
'rainbow-delimiters
's
'smartparens
'smex
'sml-mode
'smooth-scrolling
'solarized-theme
'sparkline
'sqlup-mode
'string-edit
'stripe-buffer
'undo-tree
'unicode-fonts
'vagrant
'web-mode
'wrap-region
'writegood-mode
'xml-rpc
'yaml-mode
)
(load-library "f")
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el")
(goto-char (point-max))
(eval-print-last-sexp)))
(setq gcr/el-get-packages nil)
(add-to-list
'el-get-sources
'(:name org-show
:type http
:url "https://raw.githubusercontent.com/jkitchin/jmax/master/org/org-show.org"
:website "https://github.com/jkitchin/jmax/blob/master/org/org-show.org"
:description "simple presentations in org-mode"))
(add-to-list 'gcr/el-get-packages 'org-show)
(add-to-list
'el-get-sources
'(:name emacs-name
:type http
:url "http://www.splode.com/~friedman/software/emacs-lisp/src/emacs-name.el"
:features emacs-name
:autoloads nil
:website "http://www.splode.com/"
:description "emacs acronym expansions"))
(add-to-list 'gcr/el-get-packages 'emacs-name)
(add-to-list
'el-get-sources
'(:name flame
:type http
:url "http://www.splode.com/~friedman/software/emacs-lisp/src/flame.el"
:features flame
:autoloads nil
:website "http://www.splode.com/"
:description "automatic generation of flamage, as if we needed more"))
(add-to-list 'gcr/el-get-packages 'flame)
(add-to-list
'el-get-sources
'(:name horoscope
:type http
:url "http://www.splode.com/~friedman/software/emacs-lisp/src/horoscope.el"
:features horoscope
:autoloads t
:website "http://www.splode.com/"
:description "generate horoscopes"))
(add-to-list 'gcr/el-get-packages 'horoscope)
(add-to-list
'el-get-sources
'(:name kibologize
:type http
:url "http://www.splode.com/~friedman/software/emacs-lisp/src/kibologize.el"
:features kibologize
:autoloads nil
:website "http://www.splode.com/"
:description "generate ravings about kibology, in the style of kibo"))
(add-to-list 'gcr/el-get-packages 'kibologize)
(add-to-list
'el-get-sources
'(:name shop
:type http
:url "http://www.splode.com/~friedman/software/emacs-lisp/src/shop.el"
:features shop
:autoloads nil
:website "http://www.splode.com/"
:description "generate random shopping lists"))
(add-to-list 'gcr/el-get-packages 'shop)
(add-to-list
'el-get-sources
'(:name youwill
:type http
:url "http://www.splode.com/~friedman/software/emacs-lisp/src/youwill.el"
:features youwill
:autoloads t
:website "http://www.splode.com/"
:description "generate meaningless marketing hype"))
(add-to-list 'gcr/el-get-packages 'youwill)
(add-to-list
'el-get-sources
'(:name swimmers
:type http
:url "http://www.cb1.com/~john/computing/emacs/lisp/games/swimmers.el"
:features swimmers
:autoloads nil
:website "http://www.cb1.com/~john/"
:description "Draw a swimming-pool screensaver"))
(add-to-list 'gcr/el-get-packages 'swimmers)
(add-to-list 'el-get-sources '(:name emacs-uuid
:type github
:pkgname "nicferrier/emacs-uuid"))
(add-to-list 'gcr/el-get-packages 'emacs-uuid)
(add-to-list 'el-get-sources '(:name emacs-world-time-mode
:type github
:pkgname "nicferrier/emacs-world-time-mode"))
(add-to-list 'gcr/el-get-packages 'emacs-world-time-mode)
(el-get 'sync gcr/el-get-packages)
(defun gcr/untabify-buffer ()
"For untabifying the entire buffer."
(interactive)
(untabify (point-min) (point-max)))
(defun gcr/untabify-buffer-hook ()
"Adds a buffer-local untabify on save hook"
(interactive)
(add-hook
'after-save-hook
(lambda () (gcr/untabify-buffer))
nil
'true))
(defun gcr/disable-tabs ()
"Disables tabs."
(setq indent-tabs-mode nil))
(defmacro gcr/on-gnu/linux (statement &rest statements)
"Evaluate the enclosed body only when run on GNU/Linux."
`(when (eq system-type 'gnu/linux)
,statement
,@statements))
(defmacro gcr/on-osx (statement &rest statements)
"Evaluate the enclosed body only when run on OSX."
`(when (eq system-type 'darwin)
,statement
,@statements))
(defmacro gcr/on-gnu/linux-or-osx (statement &rest statements)
"Evaluate the enclosed body only when run on GNU/Linux or OSX."
`(when (or (eq system-type 'gnu/linux)
(eq system-type 'darwin))
,statement
,@statements))
(defmacro gcr/on-windows (statement &rest statements)
"Evaluate the enclosed body only when run on Microsoft Windows."
`(when (eq system-type 'windows-nt)
,statement
,@statements))
(defmacro gcr/on-gui (statement &rest statements)
"Evaluate the enclosed body only when run on GUI."
`(when (display-graphic-p)
,statement
,@statements))
(defmacro gcr/not-on-gui (statement &rest statements)
"Evaluate the enclosed body only when run on GUI."
`(when (not (display-graphic-p))
,statement
,@statements))
(defmacro gcr/diminish (mode)
"Diminish this mode after it is loaded."
(interactive)
`(eval-after-load ,mode
(diminish ,mode)))
(defvar gcr/delete-trailing-whitespace-p t
"Should trailing whitespace be removed?")
(defun gcr/delete-trailing-whitespace ()
"Delete trailing whitespace for everything but the current line.
If `gcr/delete-trailing-whitespace-p' is non-nil, then delete the whitespace.
This is useful for fringe cases where trailing whitespace is important."
(interactive)
(when gcr/delete-trailing-whitespace-p
(let ((first-part-start (point-min))
(first-part-end (point-at-bol))
(second-part-start (point-at-eol))
(second-part-end (point-max)))
(delete-trailing-whitespace first-part-start first-part-end)
(delete-trailing-whitespace second-part-start second-part-end))))
(defun gcr/set-org-babel-default-header-args (property value)
"Easily set system header arguments in org mode.
PROPERTY is the system-wide value that you would like to modify.
VALUE is the new value you wish to store.
Attribution: URL `http://orgmode.org/manual/System_002dwide-header-arguments.html#System_002dwide-header-arguments'"
(setq org-babel-default-header-args
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args))))
(defun gcr/set-org-babel-default-inline-header-args (property value)
"See `gcr/set-org-babel-default-header-args'; same but for inline header args."
(setq org-babel-default-inline-header-args
(cons (cons property value)
(assq-delete-all property org-babel-default-inline-header-args))))
(defun gcr/set-org-babel-default-header-args:R (property value)
"See `gcr/set-org-babel-default-header-args'; same but for R.
This is a copy and paste. Additional languages would warrant a refactor."
(setq org-babel-default-header-args:R
(cons (cons property value)
(assq-delete-all property org-babel-default-header-args:R))))
(defun gcr/ispell-org-header-lines-regexp (h)
"Help ispell ignore org header lines."
(interactive)
(cons (concat "^#\\+" h ":") ".$"))
(defun gcr/ispell-a2isra (block-def)
"Add to the ispell skip region alist the BLOCK-DEF."
(interactive)
(add-to-list 'ispell-skip-region-alist block-def))
(defun gcr/insert-timestamp ()
"Produces and inserts a full ISO 8601 format timestamp."
(interactive)
(insert (format-time-string "%Y-%m-%dT%T%z")))
(defun gcr/insert-timestamp* ()
"Produces and inserts a near-full ISO 8601 format timestamp."
(interactive)
(insert (format-time-string "%Y-%m-%dT%T")))
(defun gcr/insert-datestamp ()
"Produces and inserts a partial ISO 8601 format timestamp."
(interactive)
(insert (format-time-string "%Y-%m-%d")))
(defun gcr/comment-or-uncomment ()
"Comment or uncomment the current line or selection."
(interactive)
(cond ((not mark-active) (comment-or-uncomment-region (line-beginning-position)
(line-end-position)))
((< (point) (mark)) (comment-or-uncomment-region (point) (mark)))
(t (comment-or-uncomment-region (mark) (point)))))
(defun gcr/no-control-m ()
"Aka dos2unix."
(interactive)
(let ((line (line-number-at-pos))
(column (current-column)))
(mark-whole-buffer)
(replace-string "
" "")
(goto-line line)
(move-to-column column)))
(defun gcr/save-all-file-buffers ()
"Saves every buffer associated with a file."
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (and (buffer-file-name) (buffer-modified-p))
(save-buffer)))))
(defun gcr/kill-other-buffers ()
"Kill all other buffers."
(interactive)
(mapc 'kill-buffer (delq (current-buffer) (buffer-list))))
(defun gcr/newline ()
"Locally binds newline."
(local-set-key (kbd "RET") 'sp-newline))
(defun gcr/describe-thing-in-popup ()
"Display help information on the current symbol.
Attribution: URL `http://www.emacswiki.org/emacs/PosTip'
Attribution: URL `http://blog.jenkster.com/2013/12/popup-help-in-emacs-lisp.html'"
(interactive)
(let* ((thing (symbol-at-point))
(help-xref-following t)
(description (with-temp-buffer
(help-mode)
(help-xref-interned thing)
(buffer-string))))
(gcr/on-gui (pos-tip-show description nil nil nil 300))
(gcr/not-on-gui (popup-tip description
:point (point)
:around t
:height 30
:scroll-bar t
:margin t))))
(defun gcr/indent-curly-block (&rest _ignored)
"Open a new brace or bracket expression, with relevant newlines and indent. Src: https://github.com/Fuco1/smartparens/issues/80"
(newline)
(indent-according-to-mode)
(forward-line -1)
(indent-according-to-mode))
(defun beginning-of-line-dwim ()
"Toggles between moving point to the first non-whitespace character, and
the start of the line. Src: http://www.wilfred.me.uk/"
(interactive)
(let ((start-position (point)))
;; see if going to the beginning of the line changes our position
(move-beginning-of-line nil)
(when (= (point) start-position)
;; we're already at the beginning of the line, so go to the
;; first non-whitespace character
(back-to-indentation))))
(defun gcr/lazy-new-open-line ()
"Insert a new line without breaking the current line."
(interactive)
(beginning-of-line)
(next-line)
(newline)
(previous-line))
(defun gcr/smart-open-line ()
"Insert a new line, indent it, and move the cursor there.
This behavior is different then the typical function bound to return
which may be `open-line' or `newline-and-indent'. When you call with
the cursor between ^ and $, the contents of the line to the right of
it will be moved to the newly inserted line. This function will not
do that. The current line is left alone, a new line is inserted, indented,
and the cursor is moved there.
Attribution: URL `http://emacsredux.com/blog/2013/03/26/smarter-open-line/'"
(interactive)
(move-end-of-line nil)
(newline-and-indent))
(defun gcr/narrow-to-region* (boundary-start boundary-end fun)
"Edit the current region in a new, cloned, indirect buffer.
This function is responsible for helping the operator to easily
manipulate a subset of a buffer's contents within a new buffer. The
newly created clone buffer is created with `clone-indirect-buffer',
so all of its behaviors apply. You may care specifically about the
fact that the clone is really just a 'view' of the source buffer, so
actions performed within the source buffer or its clone(s) are
actually occurring only within the source buffer itself. When the
dynamic extent of this function is entered, the operator is prompted
for a function to call to make upon entering the new buffer. The intent
is to specify the desired mode for the new buffer, for example by
calling `scheme-mode', but any function may be called.
The subset chosen for manipulation is narrowed by
`narrow-to-region'. When the clone buffer is created, the lines in
which the start and end of the boundary occur are included at the
end the new clone buffer name to serve as a reminder for its
'true source'. The intent is to facilitate going back from the clone
buffer to the source buffer with knowledge of where it originated.
BOUNDARY-START and BOUNDARY-END are provided by delegation of this
function to `interactive'. FUN is provided interactively by the
operator via the modeline in the same manner. See Info node
`(elisp) Eval' for more on why `funcall' was used here instead of
`eval' for calling the selected function.
Attribution: URL `http://demonastery.org/2013/04/emacs-narrow-to-region-indirect/'
Attribution: URL `http://paste.lisp.org/display/135818Attribution'"
(interactive "*r\naMode name? ")
(let* ((boundary-start (if (< boundary-start 1) (point-min)
boundary-start))
(boundary-end (if (<= boundary-end boundary-start) (point-max)
boundary-end))
(new-name (concat
(buffer-name)
"⊃"
(number-to-string (line-number-at-pos boundary-start))
"-"
(number-to-string (line-number-at-pos boundary-end))))
(buf-name (generate-new-buffer-name new-name))
(fun (if (fboundp fun) fun
'fundamental-mode)))
(with-current-buffer (clone-indirect-buffer buf-name +1 +1)
(narrow-to-region boundary-start boundary-end)
(deactivate-mark)
(goto-char (point-min))
(funcall fun))))
(defun gcr/insert-ellipsis ()
"Insert an ellipsis into the current buffer."
(interactive)
(insert "…"))
(defun gcr/insert-noticeable-snip-comment-line ()
"Insert a noticeable snip comment line (NSCL)."
(interactive)
(if (not (bolp))
(message "I may only insert a NSCL at the beginning of a line.")
(let ((ncl (make-string 70 ?✂)))
(newline)
(previous-line)
(insert ncl)
(comment-or-uncomment-region (line-beginning-position) (line-end-position)))))
(defun gcr/dired-copy-filename ()
"Push the path and filename of the file under the point to the kill ring.
Attribution: URL `https://lists.gnu.org/archive/html/help-gnu-emacs/2002-10/msg00556.html'"
(interactive)
(message "Added %s to kill ring" (kill-new (dired-get-filename))))
(defun gcr/dired-copy-path ()
"Push the path of the directory under the point to the kill ring."
(interactive)
(message "Added %s to kill ring" (kill-new default-directory)))
(defun gcr/file-exists-not-symlink (f)
"True if F exists and is not a symlink."
(interactive)
(and (file-exists-p f)
(not (file-symlink-p f))))
(defun gcr/file-exists-is-symlink (f)
"True if F exists and is a symlink."
(interactive)
(and (file-exists-p f)
(file-symlink-p f)))
(progn
(defvar my-read-expression-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map read-expression-map)
(define-key map [(control ?g)] #'minibuffer-keyboard-quit)
(define-key map [up] nil)
(define-key map [down] nil)
map))
(defun my-read--expression (prompt &optional initial-contents)
(let ((minibuffer-completing-symbol t))
(minibuffer-with-setup-hook
(lambda ()
(emacs-lisp-mode)
(use-local-map my-read-expression-map)
(setq font-lock-mode t)
(funcall font-lock-function 1))
(read-from-minibuffer prompt initial-contents
my-read-expression-map nil
'read-expression-history))))
(defun my-eval-expression (expression &optional arg)
(interactive (list (read (my-read--expression ""))
current-prefix-arg))
(if arg
(insert (pp-to-string (eval expression lexical-binding)))
(pp-display-expression (eval expression lexical-binding)
"*Pp Eval Output*"))))
(defun gcr/util-ielm ()
"Personal buffer setup for ielm.
Creates enough space for one other permanent buffer beneath it."
(interactive)
(split-window-below -20)
(other-window 1)
(ielm)
(set-window-dedicated-p (selected-window) t))
(defun gcr/util-eshell ()
"Personal buffer setup for eshell.
Depends upon `gcr/util-ielm' being run first."
(interactive)
(split-window-below -10)
(other-window 1)
(eshell)
(set-window-dedicated-p (selected-window) t))
(defvar gcr/util-state nil "Track whether the util buffers are displayed or not.")
(defun gcr/util-state-toggle ()
"Toggle the util state."
(interactive)
(setq gcr/util-state (not gcr/util-state)))
(defun gcr/util-start ()
"Perhaps utility buffers."
(interactive)
(gcr/util-ielm)
(gcr/util-eshell)
(gcr/util-state-toggle))
(defun gcr/util-stop ()
"Remove personal utility buffers."
(interactive)
(if (get-buffer "*ielm*") (kill-buffer "*ielm*"))
(if (get-buffer "*eshell*") (kill-buffer "*eshell*"))
(gcr/util-state-toggle))
(defun gcr/ielm-auto-complete ()
"Enables `auto-complete' support in \\[ielm].
Attribution: URL `http://www.masteringemacs.org/articles/2010/11/29/evaluating-elisp-emacs/'"
(setq ac-sources '(ac-source-functions
ac-source-variables
ac-source-features
ac-source-symbols
ac-source-words-in-same-mode-buffers))
(add-to-list 'ac-modes 'inferior-emacs-lisp-mode)
(auto-complete-mode 1))
(defun gcr/uuid-string ()
"Insert a string form of a UUID."
(interactive)
(insert (uuid-to-stringy (uuid-create))))
(defun yf/org-electric-dollar nil
"When called once, insert \\(\\) and leave point in between.
When called twice, replace the previously inserted \\(\\) by one $.
from Nicolas Richard <[email protected]>
Date: Fri, 8 Mar 2013 16:23:02 +0100
Message-ID: <[email protected]>"
(interactive)
(if (and (looking-at "\\\\)") (looking-back "\\\\("))
(progn (delete-char 2)
(delete-char -2)
(insert "$"))
(insert "\\(\\)")
(backward-char 2)))
(defun endless/sharp ()
"Insert #' unless in a string or comment.
SRC: URL `http://endlessparentheses.com/get-in-the-habit-of-using-sharp-quote.html?source=rss'"
(interactive)
(call-interactively #'self-insert-command)
(let ((ppss (syntax-ppss)))
(unless (or (elt ppss 3)
(elt ppss 4))
(insert "'"))))
(defun gcr/chs ()
"Insert opening \"cut here start\" snippet."
(interactive)
(insert "--8<---------------cut here---------------start------------->8---"))
(defun gcr/che ()
"Insert closing \"cut here end\" snippet."
(interactive)
(insert "--8<---------------cut here---------------end--------------->8---"))
(defmacro gcr/measure-time (&rest body)
"Measure the time it takes to evaluate BODY.
Attribution Nikolaj Schumacher: URL `https://lists.gnu.org/archive/html/help-gnu-emacs/2008-06/msg00087.html'"
`(let ((time (current-time)))
,@body
(message "%.06f" (float-time (time-since time)))))
(defun gcr/create-non-existent-directory ()
"Attribution URL: `https://iqbalansari.github.io/blog/2014/12/07/automatically-create-parent-directories-on-visiting-a-new-file-in-emacs/'"
(let ((parent-directory (file-name-directory buffer-file-name)))
(when (and (not (file-exists-p parent-directory))
(y-or-n-p (format "Directory `%s' does not exist. Create it?" parent-directory)))
(make-directory parent-directory t))))
(defun gcr/occur-dwim ()
"Call `occur' with a mostly sane default.
Attribution Oleh Krehel (abo-abo): URL `http://oremacs.com/2015/01/26/occur-dwim/'"
(interactive)
(push (if (region-active-p)
(buffer-substring-no-properties
(region-beginning)
(region-end))
(let ((sym (thing-at-point 'symbol)))
(when (stringp sym)
(regexp-quote sym))))
regexp-history)
(call-interactively 'occur))
(defun gcr/util-cycle ()
"Display or hide the utility buffers."
(interactive)
(if gcr/util-state
(gcr/util-stop)
(gcr/util-start)))
(defun sacha/unfill-paragraph (&optional region)
"Takes a multi-line paragraph and makes it into a single line of text.
ATTRIBUTION: SRC https://github.com/sachac/.emacs.d/blob/gh-pages/Sacha.org#unfill-paragraph"
(interactive (progn
(barf-if-buffer-read-only)
(list t)))
(let ((fill-column (point-max)))
(fill-paragraph nil region)))
(setq solarized-distinct-fringe-background +1)
(setq solarized-high-contrast-mode-line +1)
(setq solarized-use-less-bold +1)
(setq solarized-use-more-italic nil)
(setq solarized-emphasize-indicators nil)
(load-theme 'solarized-dark)
(menu-bar-mode +1)
(gcr/on-osx
(defadvice yes-or-no-p (around prevent-dialog activate)
"Prevent yes-or-no-p from activating a dialog"
(let ((use-dialog-box nil))
ad-do-it))
(defadvice y-or-n-p (around prevent-dialog-yorn activate)
"Prevent y-or-n-p from activating a dialog"
(let ((use-dialog-box nil))
ad-do-it)))
(require 'exec-path-from-shell)
(gcr/on-osx (exec-path-from-shell-initialize))
(require 'alert)
(setq alert-fade-time 10)
(gcr/on-gui
(gcr/on-osx
(setq alert-default-style 'growl)))
(setq alert-reveal-idle-time 120)
(gcr/on-windows
(setq shell-file-name "cmdproxy.exe"))
(gcr/on-osx
(setq mac-control-modifier 'control)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super))
(gcr/on-windows
(setq w32-lwindow-modifier 'super)
(setq w32-rwindow-modifier 'super))
(setq hs-hide-comments-when-hiding-all +1)
(setq hs-isearch-open +1)
(defun display-code-line-counts (ov)
"Displaying overlay content in echo area or tooltip"
(when (eq 'code (overlay-get ov 'hs))
(overlay-put ov 'help-echo
(buffer-substring (overlay-start ov)
(overlay-end ov)))))
(setq hs-set-up-overlay 'display-code-line-counts)
(defadvice goto-line (after expand-after-goto-line activate compile)
"How do I get it to expand upon a goto-line? hideshow-expand affected block when using goto-line in a collapsed buffer."
(save-excursion
(hs-show-block)))
(global-linum-mode -1)
(global-font-lock-mode 1)
(setq aw-keys '(?a ?s ?d ?f ?j ?k ?l ?\;))
(setq blink-matching-paren nil)
(show-paren-mode +1)
(setq show-paren-delay 0)
(setq show-paren-style 'expression)
(setq ring-bell-function 'ignore)
(setq visible-bell +1)
(winner-mode +1)
(blink-cursor-mode 0)
(gcr/on-gui
(setq-default cursor-type 'box))
(setq x-stretch-cursor 1)
(defadvice kill-line (around kill-line-remove-newline activate)
(let ((kill-whole-line t))
ad-do-it))
(setq-default fill-column 80)
(global-diff-hl-mode)
(require 'expand-region)
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
(desktop-save-mode 1)
(setq desktop-restore-eager 10)
(setq auto-save-default t)
(setq make-backup-files nil)
(setq auto-save-visited-file-name t)
(setq auto-save-interval 05)
(setq auto-save-timeout 05)
(defadvice switch-to-buffer (before gcr/save-all-file-buffers-now activate)
(when buffer-file-name (gcr/save-all-file-buffers)))
(defadvice other-window (before other-window-now activate)
(when buffer-file-name (gcr/save-all-file-buffers)))
(defadvice windmove-up (before other-window-now activate)
(when buffer-file-name (gcr/save-all-file-buffers)))
(defadvice windmove-down (before other-window-now activate)
(when buffer-file-name (gcr/save-all-file-buffers)))
(defadvice windmove-left (before other-window-now activate)
(when buffer-file-name (gcr/save-all-file-buffers)))
(defadvice windmove-right (before other-window-now activate)
(when buffer-file-name (gcr/save-all-file-buffers)))
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(gcr/on-osx
(add-to-list 'load-path "/usr/local/Cellar/ccrypt/1.10/share/emacs/site-lisp"))
(gcr/on-windows
(add-to-list 'load-path "C:\\opt\\ccrypt-1.10.cygwin-i386\\"))
(gcr/on-gnu/linux
(warn "Please configure ccrypt."))
(require 'ps-ccrypt "ps-ccrypt.el")
(setq backup-inhibited 1)
(add-hook 'write-file-hooks
(lambda ()
(gcr/delete-trailing-whitespace)))
(prefer-coding-system 'utf-8)
(gcr/on-gui
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(gcr/on-windows
(set-clipboard-coding-system 'utf-16le-dos)))
(require 'undo-tree)
(global-undo-tree-mode 1)
(gcr/diminish 'undo-tree-mode)
(setq require-final-newline t)
(global-auto-revert-mode 1)
(require 'wrap-region)
(gcr/diminish 'wrap-region-mode)
(wrap-region-add-wrapper "*" "*" nil 'org-mode) ;; bold
(wrap-region-add-wrapper "/" "/" nil 'org-mode) ;; italic
(wrap-region-add-wrapper "_" "_" nil 'org-mode) ;; underlined
(wrap-region-add-wrapper "=" "=" nil 'org-mode) ;; verbatim
(wrap-region-add-wrapper "~" "~" nil 'org-mode) ;; code
(wrap-region-add-wrapper "+" "+" nil 'org-mode) ;; strike-through
;; (wrap-region-add-wrapper "" "w" 'org-mode) ;; noweb blocks
(let ((text-buffer (get-buffer-create "*text*")))
(with-current-buffer text-buffer
(text-mode)
(insert "Shall we play a game?")
(beginning-of-line)))
(require 'boxquote)
(setq track-eol +1)
(setq line-move-visual nil)
(global-set-key [?\C-x ?t] 'anchored-transpose)
(autoload 'anchored-transpose "anchored-transpose" nil t)
(require 'ibuffer)
(require 'smooth-scrolling)
(require 'stripe-buffer)
(defadvice save-buffers-kill-terminal (before save-before-save-buffers-kill-terminal first activate)
"Save all buffers before save-buffers-kill-terminal calls."
(gcr/save-all-file-buffers))
(setq sentence-end-double-space nil)
(gcr/diminish 'visual-line-mode)
(eval-after-load "hideshow" '(diminish 'hs-minor-mode))
(gcr/on-osx (setq frame-title-format '("𝔸𝕃𝔼ℂ")))
(gcr/on-windows (setq frame-title-format '("ALEC")))
(scroll-bar-mode 0)
(tool-bar-mode -1)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse +1)
(require 'neotree)
(setq dired-listing-switches "-alh")
(setq dired-recursive-deletes +1)
(require 'dired-details+)
(setq-default dired-details-hidden-string "")
(defun gcr/dired-mode-hook ()
"Personal dired customizations."
(local-set-key "c" 'gcr/dired-copy-filename)
(local-set-key "]" 'gcr/dired-copy-path)
(diff-hl-dired-mode)
(load "dired-x")
(turn-on-stripe-buffer-mode)
(stripe-listify-buffer))
(add-hook 'dired-mode-hook 'gcr/dired-mode-hook)
(setq dired-dwim-target t)
(require 'find-dired)
(setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld"))
(require 'wdired)
(setq wdired-allow-to-change-permissions t)
(setq wdired-allow-to-redirect-links t)
(setq wdired-use-interactive-rename +1)
(setq wdired-confirm-overwrite +1)
(setq wdired-use-dired-vertical-movement 'sometimes)
(require 'dired-imenu)
(defconst gcr/savehist-file-store "~/.emacs.d/history")
(defun gcr/warn-savehist-file-store ()
"Warn of savehist misconfiguration."
(interactive)
(unless (gcr/file-exists-not-symlink gcr/savehist-file-store)
(warn "Can't seem to find a savehist store file where it was expected at: %S. Savehist should continue to function normally; but your history may be lost."
gcr/savehist-file-store)))
(gcr/warn-savehist-file-store)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
'(kill-ring
search-ring
regexp-search-ring))
(savehist-mode +1)
(defconst gcr/aspell-personal-dictionary "~/.aspell.en.pws")
(defun gcr/warn-aspell-personal-dictionary ()
"Warn of aspell misconfiguration: personal dictionary."
(interactive)
(unless (gcr/file-exists-is-symlink gcr/aspell-personal-dictionary)
(warn
"Can't seem to find an aspell personal dictionary where it was expected at: %S. aspell should continue to function normally; but your personal dictionary will not be used."
gcr/aspell-personal-dictionary)))
(gcr/warn-aspell-personal-dictionary)
(defconst gcr/aspell-personal-replacement-dictionary "~/.aspell.en.prepl")
(defun gcr/warn-aspell-personal-replacement-dictionary ()
"Warn of aspell misconfiguration: personal replacement dictionary."
(interactive)
(unless (gcr/file-exists-is-symlink gcr/aspell-personal-replacement-dictionary)
(warn
"Can't seem to find an aspell personal replacement dictionary where it was expected at: %S. aspell should continue to function normally; but your personal replacement dictionary will not be used."
gcr/aspell-personal-replacement-dictionary)))
(gcr/warn-aspell-personal-replacement-dictionary)
(require 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)
(gcr/diminish 'flycheck-mode)
(require 'yasnippet)
(yas-global-mode 1)
(gcr/diminish 'yas-minor-mode)
(defun gcr/yas-minor-mode-hook ()
"Personal customizations."
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "s-4") 'yas-expand))
(add-hook 'yas-minor-mode-hook 'gcr/yas-minor-mode-hook)
(require 'whitespace)
(setq whitespace-style '(trailing lines tab-mark))
(setq whitespace-line-column 80)
(global-whitespace-mode 1)
(gcr/diminish 'global-whitespace-mode)
(gcr/diminish 'whitespace-mode)
(delete-selection-mode 1)
(require 'diminish)
(size-indication-mode)
(column-number-mode 1)
(autoload 'esup "esup" "Emacs Start Up Profiler." nil)
(fset 'yes-or-no-p 'y-or-n-p)
(setq resize-mini-windows +1)
(setq max-mini-window-height 0.33)
(setq enable-recursive-minibuffers t)
(minibuffer-depth-indicate-mode 1)
(setq isearch-lax-whitespace +1)
(setq isearch-regexp-lax-whitespace +1)
(setq-default case-fold-search +1)
(require 'ido)
(require 'flx-ido)
(ido-mode 1)
(require 'ido-hacks nil +1)
(require 'ido-ubiquitous)
(ido-ubiquitous-mode +1)
(setq ido-create-new-buffer 'always)
(flx-ido-mode +1)
(setq ido-use-faces nil)
(require 'ido-vertical-mode)
(ido-vertical-mode +1)
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)
(require 'anzu)
(global-anzu-mode +1)
(global-set-key (kbd "M-%") 'anzu-query-replace)
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
(setq anzu-mode-lighter "")
(setq anzu-deactivate-region t)
(setq anzu-search-threshold 1000)
(setq anzu-replace-to-string-separator " => ")
(gcr/on-gnu/linux-or-osx
(defadvice ido-find-file (after find-file-sudo activate)
"Find file as root if necessary.
Attribution: SRC `http://emacsredux.com/blog/2013/04/21/edit-files-as-root/'"
(unless (and buffer-file-name
(file-writable-p buffer-file-name))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))))
(require 'pos-tip)
(gcr/on-windows
(ignore-errors
(pos-tip-w32-max-width-height)))
(setq pos-tip-foreground-color "#073642")
(setq pos-tip-background-color "#839496")
(require 'fuzzy)
(require 'auto-complete)
(require 'auto-complete-config)
(setq ac-quick-help-prefer-pos-tip nil)
(ac-config-default)
(setq ac-auto-start nil)
(ac-set-trigger-key "TAB")
(gcr/diminish 'auto-complete-mode)
(require 'auto-complete-chunk)
(require 'smartparens-config)