-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.el
1352 lines (1235 loc) · 58.2 KB
/
settings.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
;; -*- mode: Emacs-Lisp -*-
;; Set the font sizesS
(setq-default line-spacing 0.17)
;; (setq-default indent-tabs-mode nil)
;; Or set the below in hooks for major modes
;; (setq indent-tabs-mode nil)
;; (jj/infer-indentation-style)
;; should start putting double spaces after periods so don't need this command
;; sentence-navigation replaced forward backward but still used for kills
(setq sentence-end-double-space nil)
(setq recentf-max-menu-items 20)
(setq recentf-max-saved-items nil)
(setq history-length 750)
(setq helm-ff-history-max-length 500)
(setq ivy-dired-history-max 999)
(setq helm-dired-history-max 999)
(setq buffers-menu-max-size 20)
(setq kill-whole-line t)
(setq kill-read-only-ok t)
(setq-default tab-width 4)
(setq column-number-mode t)
(setq ns-auto-hide-menu-bar t)
(if (featurep 'scroll-bar) (toggle-scroll-bar -1))
(setq mark-ring-max 32)
(setq global-mark-ring-max 6)
(setq set-mark-command-repeat-pop t)
(setq winner-ring-size 500)
;; (add-to-list 'savehist-additional-variables 'winner-ring-alist)
;; (setq winner-dont-bind-my-keys t)
(setq enable-recursive-minibuffers t)
(setq inferior-lisp-program "/usr/local/bin/sbcl")
;; Removed slime so don't need the following line
;; (setq slime-contribs '(slime-fancy))
(setq recentf-save-file (expand-file-name "~/Programs/scimax/user/recentf"))
;; (run-with-timer (* 60 60) (* 60 60) 'recentf-save-list)
(setq recentf-exclude (append recentf-exclude '(".*projectile-bookmarks.eld$" ".*user/recentf$" ".*user/history$" ".*user/abbrev_defs$" ".*user/ac-comphist.dat$" ".*user/bookmarks$" ".*mp3$" ".*mp4$" ".*elc$" ".*\\.el\\.gz$" ".*mkv$" ".*avi$" ".*wmv$" ".*dmg$" ".*pkg$" ".*png$" ".*\\.r[0-9a][0-9r]" ".*/FinishedTor/.*$" ".*/To_Delete/K/.*$" ".*/scimax/elpa/.*$")))
;; ".*\\.pdf$"
;; disable recentf-cleanup on Emacs start, because it can cause
;; problems with remote files
;; (recentf-auto-cleanup 'never)
;; Possibly use this if using network filed systems because checks every file on emacs exit
;; (setq save-place-forget-unreadable-files nil)
;; (setq save-place-file (locate-user-emacs-file "places" ".emacs-places"))
(setq save-place-limit 2000)
(setq save-place-ignore-files-regexp "\\(?:COMMIT_EDITMSG\\|hg-editor-[[:alnum:]]+\\.txt\\|svn-commit\\.tmp\\|recentf\\|bzr_log\\.[[:alnum:]]+\\)$")
;; (run-with-timer (* 60 120) (* 60 120) 'save-place-alist-to-file)
(defvar save-place-timer nil)
;; removed because added save-place-alist to savehist
;; Don't need this since have the timer above but if added savehist
;; has to be loaded after save-place=mode so the variable loaded in later
;; (add-to-list 'savehist-additional-variables 'save-place-alist)
(save-place-mode 1)
;; untitled~~.tmp files will open into text-mode (
(add-to-list 'auto-mode-alist '("\\.qqq\\'" . text-mode))
;; symlinks under version control are followed to there real directory
;; only necessary if using emacs for controlling git (possibly remove later)
(setq vc-follow-symlinks t)
;; Can use but post command hooks can't be expensive operations
;; (defun vc-state-refresh-post-command-hook ()
;; "Check if command in `this-command' was executed, then run `vc-refresh-state'"
;; (when (memq this-command '(other-window kill-buffer ido-kill-buffer ido-switch-buffer))
;; (vc-refresh-state)))
;; (add-hook 'post-command-hook #'vc-state-refresh-post-command-hook)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Undo Tree
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; setup later undo info
;; (setq undo-tree-auto-save-history t)
;; (setq undo-tree-history-directory-alist
;; (quote (("" . "~/.local/var/emacs/undo_hist"))))
(setq undo-outer-limit (* 1024 1024 10))
(setq undo-strong-limit (* 1024 1024 6))
(setq undo-limit (* 1024 1024 5))
;; (with-eval-after-load "volatile-highlights-autoloads"
;; (volatile-highlights-mode 1))
;; ;; Treat undo history as a tree.
;; (with-eval-after-load "undo-tree-autoloads"
;; ;; Enable Global-Undo-Tree mode.
;; (global-undo-tree-mode 1))
;; (with-eval-after-load "undo-tree"
;; (with-eval-after-load "diminish-autoloads"
;; (diminish 'undo-tree-mode))
;; ;; Display times relative to current time in visualizer.
;; (setq undo-tree-visualizer-relative-timestamps t)
;; ;; Display time-stamps by default in undo-tree visualizer.
;; (setq undo-tree-visualizer-timestamps t)
;; ; Toggle time-stamps display using `t'.
;; ;; Display diff by default in undo-tree visualizer.
;; (setq undo-tree-visualizer-diff t) ; Toggle the diff display using `d'.
;; (define-key undo-tree-map (kbd "C-/") nil)
;; ;; (defalias 'redo 'undo-tree-redo)
;; (global-set-key (kbd "C-S-z") #'undo-tree-redo)
;; (global-set-key (kbd "<S-f11>") #'undo-tree-redo))
;; ) ; Chapter 7 ends here.
;; Look at adding
;; (defadvice undo-tree-make-history-save-file-name
;; (after undo-tree activate)
;; (setq ad-return-value (concat ad-return-value ".gz")))
;;; Shut up compile saves
(setq compilation-ask-about-save nil)
;; Fix minor mode lines that not useful
(setq beacon-lighter nil) ; beacon-mode
(setq back-button-mode-lighter nil) ; back-button-mode
(setq google-this-modeline-indicator nil) ;google-this-mode
;; couldn't figure out how to change lighter of emacs-lock-mode
(eval-after-load 'whitespace-cleanup-mode
'(progn
(defun whitespace-cleanup-mode-mode-line ()
"Return a string for mode-line.
Use '!' to signify that the buffer was not initially clean."
(concat " WS"
(unless whitespace-cleanup-mode-initially-clean
"!")))))
(when (eq system-type 'darwin)
(osx-trash-setup))
(setq delete-by-moving-to-trash t)
;; This doesn't work for Chrome but will work for safari
(setq osx-browse-prefer-background 'background)
;; For google this possibly set this and figure out how to make it run in the background
;; (setq google-this-browse-url-function 'osx-browse-url-safari)
(setq counsel-grep-base-command "grep -E -n -i -e %s %s")
;; Use to make the ivy-directories in buffer switch use full paths
;; (setq ivy-virtual-abbreviate 'full)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ivy and Counsel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq ivy-use-virtual-buffers nil)
(setq ivy-height 14)
(ivy-set-actions
'ivy-switch-buffer
'(("k"
(lambda (x)
(jj/ivy-kill-buffer x)
(ivy--reset-state ivy-last))
"kill"
)))
(setq ivy-initial-inputs-alist
'((org-refile . "")
(org-agenda-refile . "^")
(org-capture-refile . "")
(counsel-M-x . "")
(counsel-describe-function . "")
(counsel-describe-variable . "")
(counsel-org-capture . "^")
(Man-completion-table . "^")
(woman . "^")))
(setq ivy-re-builders-alist
'((counsel-bookmark . ivy--regex-fuzzy)
(counsel-bookmarked-directory . ivy--regex-fuzzy)
(swiper . ivy--regex-ignore-order)
(counsel-recentf . ivy--regex-plus)
(counsel-locate . ivy--regex-ignore-order)
(counsel-describe-function . ivy--regex-fuzzy)
(counsel-find-file . ivy--regex-fuzzy)
(counsel-apropos . ivy--regex-fuzzy)
(counsel-descbinds . ivy--regex-fuzzy)
(counsel-info-lookup-symbol . ivy--regex-fuzzy)
(counsel-describe-variable . ivy--regex-fuzzy)
(counsel-load-library . ivy--regex-fuzzy)
(counsel-package . ivy--regex-fuzzy)
(counsel-M-x . ivy--regex-fuzzy)
(swiper-all . ivy--regex-ignore-order)
(dired-goto-file . ivy--regex-plus)
(counsel-git-grep . ivy--regex-ignore-order)
(swiper-multi . ivy--regex-ignore-order)
(counsel-org-goto . ivy--regex-fuzzy)
(counsel-org-goto-all . ivy--regex-fuzzy)
(counsel-grep-or-swiper . ivy--regex-ignore-order)
(jj/counsel-find-name-everything . ivy--regex-ignore-order)
(t . ivy--regex-ignore-order)))
(add-to-list 'ivy-sort-functions-alist
'(read-file-name-internal . jj/ivy-sort-file-function))
;; (add-to-list 'ivy-sort-functions-alist
;; '(read-file-name-internal . jj/ivy-sort-file-by-mtime))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Whitespace mode and ws-butler settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: Write change major-mode hook that if whitespace cleanup mode activated calls before changing
;; TODO: write mode hooks using the DEPTH attribute so can load after or before
;; hook needs to be run before whitespace-cleanup-mode hook so that is loaded first
(add-hook 'prog-mode-hook 'jj/ws-butler-mode-if-whitespace-initially-not-clean)
(add-hook 'org-mode-hook 'jj/ws-butler-mode-if-whitespace-initially-not-clean)
;; (global-whitespace-cleanup-mode)
;; modes to ignore for whitespace-cleanup-mode (useful when global-whtespace-cleanup-mode enabled)
;;
(dolist (hook '(prog-mode-hook text-mode-hook latex-mode-hook conf-space-mode-hook conf-unix-mode-hook ...))
(add-hook hook (lambda ()
(whitespace-cleanup-mode))))
(add-hook 'markdown-mode-hook
(lambda () (whitespace-cleanup-mode 0)))
(eval-after-load 'whitespace-cleanup-mode
'(setq whitespace-cleanup-mode-ignore-modes
(nconc '(markdown-mode dired-mode fundamental-mode image-mode doc-view-mode archive-mode tar-mode)
whitespace-cleanup-mode-ignore-modes)))
(add-hook 'prog-mode-hook 'clean-aindent-mode)
(add-hook 'prog-mode-hook 'dtrt-indent-mode)
;; if using semantic might need this (removes print on opening buffer)
;; (setq dtrt-indent-verbosity 0)
;; Turn on flycheck mode to validate json and add settings
(eval-after-load "json-mode"
'(progn
(add-hook 'json-mode-hook (lambda ()
(setq-local tab-width 2)))
(define-key json-mode-map "\C-c\C-n" (function flycheck-next-error))
(define-key json-mode-map "\C-cn" (function flycheck-previous-error))
(define-key json-mode-map "\C-c\C-l" (function flycheck-list-errors))
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Diminish mode line settins and cyphejor mode-line settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: Replace diminish with delight (https://www.emacswiki.org/emacs/DelightedModes)
;; (don't need to call eval-after-load) also supports major-modes
;;
;; use diminish to change minor-mode line or with no argument deletes it
;; can also be used to change major-mode lines
;; (eval-after-load "dubcaps" '(diminish 'dubcaps-mode))
(eval-after-load 'emacs-lock-mode '(diminish 'org-indent-mode))
(eval-after-load "dired-filter" '(diminish 'dired-filter-mode "Filt"))
(eval-after-load "org-src" '(diminish 'org-src-mode "Ωsrc"))
(eval-after-load "dired-x" '(diminish 'dired-omit-mode "Omt"))
(eval-after-load "flycheck" '(diminish 'flycheck-mode "FC"))
(eval-after-load "flyspell" '(diminish 'flyspell-mode "FS"))
(eval-after-load "org-indent" '(diminish 'org-indent-mode ))
(eval-after-load "ws-butler" '(diminish 'ws-butler-mode " WB"))
(eval-after-load "dtrt-indent" '(diminish 'dtrt-indent-mode ""))
(add-hook 'dired-mode-hook (lambda ()
(eval-after-load "dired-x" '(diminish 'dired-omit-mode " Om"))))
(eval-after-load "dired-filter" '(diminish 'dired-filter-mode "Filt"))
(eval-after-load "dired-narrow" '(diminish 'dired-narrow-mode "Nrw"))
(eval-after-load "elpy" '(diminish 'elpy-mode " El"))
(eval-after-load "autorevert" '(progn (setq auto-revert-mode-text " AR")))
(eval-after-load "emacs-lock" '(diminish 'emacs-lock-mode
`("" (emacs-lock--try-unlocking " l:" " L:")
(:eval (substring (symbol-name emacs-lock-mode) 0 1) ))))
(setq
cyphejor-rules
'(
;; :upcase replace words that are not matched explicitly with their first letter upcased
("bookmark" "→")
("buffer" "β")
("diff" "Δ")
("emacs" "∃")
("fundamental" "Ⓕ")
("inferior" "i" :prefix)
("interaction" "i" :prefix)
("interactive" "i" :prefix)
("lisp" "λ" :postfix)
("menu" "▤" :postfix)
("mode" "")
("markdown" "M")
("gfm" "MG")
("package" "↓")
("python" "π") ;Ƥ
("org" "Ω") ;Ⓞ
("org-agenda" "ΩA") ;Ⓞ
("shell" "sh" :postfix)
("help" "Ήϵ")
("dired" "Ɖ") ;Ⓓ
("text" "Ŧ")
("terraform" "Ŧϵ")
("powershell" "PS")
("yaml" "Yml")
("dotenv" ".env")
("dockerfile" "Dck")
("wdired" "𝓦Ɖ")))
(cyphejor-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HTML
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'html-mode-hook (lambda () (setq-local tab-width 2)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Python
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO: Switch to jupyter if bug fixed: https://github.com/jorgenschaefer/elpy/issues/1550
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "--simple-prompt -c exec('__import__(\\'readline\\')') -i")
(with-eval-after-load "elpy"
(when (require 'flycheck nil t)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules)))
(defun jj/flycheck-mode-python-setup ()
"Custom behaviours of flycheck mode for `python-mode'."
(setq-local flycheck-check-syntax-automatically (quote (save idle-change mode-enabled)))
(setq-local flycheck-idle-change-delay 1)
(setq-local flycheck-idle-buffer-switch-delay 1))
(add-hook 'elpy-mode-hook 'jj/flycheck-mode-python-setup))
;; NOTE: set so id column for pylint is wider (only has global control)
(with-eval-after-load "flycheck"
(setq flycheck-error-list-format
`[("File" 3)
("Line" 5 flycheck-error-list-entry-< :right-align t)
("Col" 3 nil :right-align t)
("Level" 5 flycheck-error-list-entry-level-<)
("ID" 18 t)
(,(flycheck-error-list-make-last-column "Message" 'Checker) 0 t)]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Latex and Tex
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; scale height of section commands by 1.2
(setq font-latex-fontify-sectioning 1.2)
;; don't query user to save on running latex commands
(setq TeX-save-query nil)
(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-clean-confirm t)
;; (setq TeX-source-correlate-method 'synctex)
;; Maybe change to ask then ask about allowing inverse search
(setq TeX-source-correlate-start-server nil)
(eval-after-load "tex"
'(progn
;; adding command options -b before -g below will highlight the line number in skim
(add-to-list 'TeX-command-list '("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -r -g %n %o %b" TeX-run-TeX nil t))
(add-to-list 'TeX-command-list '("latexmk" "latexmk -pdf -r ~/Programs/scimax/user/latexmkrc %s" TeX-run-TeX nil t :help "Run latexmk on file then output to skim"))
(add-to-list 'TeX-command-list
'("Xelatexnonstop" "xelatex -no-pdf -synctex=1 -interaction=nonstopmode %s"
TeX-run-command t t :help "Run xelatex"))
(add-to-list 'TeX-command-list '("Xelatex" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(add-to-list 'TeX-command-list '("Xelatexmk" "latexmk -xelatex -pdfxe -r ~/Programs/scimax/user/latexmkrc %s" TeX-run-TeX nil t :help "Run xelatexmk on file then output to skim"))
(add-to-list 'TeX-command-list
'("Lualatexnonstop" "lualatex -synctex=1 -interaction=nonstopmode %s"
TeX-run-command t t :help "Run xelatex"))
(add-to-list 'TeX-command-list '("Lualatexmk" "latexmk -lualatex -pdflua -r ~/Programs/scimax/user/latexmkrc %s" TeX-run-TeX nil t :help "Run Lualatexmk on file then output to skim"))
(setq TeX-view-program-selection '((output-pdf "Skim")))
(setq TeX-view-program-list '(("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -r -g %n %o %b")))
(setq-default TeX-command-default "latexmk")
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))
)
)
;; Sample `latexmkrc` for OSX that copies the *.pdf file from the `/tmp` directory
;; to the working directory:
;; $pdflatex = 'pdflatex -file-line-error -synctex=1 %O %S && (cp "%D" "%R.pdf")';
;; $pdf_mode = 1;
;; $out_dir = '/tmp';"
;; ;; The below didn't work for some reason
;; (eval-after-load
;; "tex"
;; '(progn
;; (add-to-list 'TeX-view-predicate-list-builtin '(output-pdf t))
;; (add-to-list 'TeX-expand-list '("%(tex-file-name)" (lambda () (concat "\"" (with-current-buffer TeX-command-buffer buffer-file-name) "\""))))
;; (add-to-list 'TeX-expand-list '("%(pdf-file-name)" (lambda () (concat "\"" (car (split-string (with-current-buffer TeX-command-buffer buffer-file-name) "\\.tex")) ".pdf" "\""))))
;; (add-to-list 'TeX-expand-list '("%(line-number)" (lambda () (format "%d" (line-number-at-pos)))))
;; (cond
;; ((eq system-type 'darwin)
;; (add-to-list 'TeX-expand-list '("%(latexmkrc-osx)" (lambda () (expand-file-name "~/.latexmkrc"))))
;; (add-to-list 'TeX-command-list '("latexmk-osx" "latexmk -pdf -r %(latexmkrc-osx) %s" TeX-run-TeX nil t))
;; (add-to-list 'TeX-expand-list '("%(skim)" (lambda () "/Applications/Skim.app/Contents/SharedSupport/displayline")))
;; (add-to-list 'TeX-command-list '("Skim" "%(skim) -b -g %(line-number) %(pdf-file-name) %(tex-file-name)" TeX-run-TeX nil t))
;; (add-to-list 'TeX-view-program-list '("skim-viewer" "%(skim) -b -g %(line-number) %(pdf-file-name) %(tex-file-name)"))
;; (setq TeX-view-program-selection '((output-pdf "skim-viewer"))))
;; ((eq system-type 'windows-nt)
;; (add-to-list 'TeX-expand-list '("%(latexmkrc-nt)" (lambda () "y:/scimax/users/.latexmkrc-nt")))
;; (add-to-list 'TeX-command-list '("latexmk-nt" "latexmk -pdf -r %(latexmkrc-nt) %s" TeX-run-TeX nil t))
;; (add-to-list 'TeX-expand-list '("%(sumatra)" (lambda () "\"c:/Program Files/SumatraPDF/SumatraPDF.exe\"")))
;; (add-to-list 'TeX-command-list '("SumatraPDF" "%(sumatra) -reuse-instance -forward-search %(tex-file-name) %(line-number) %(pdf-file-name)" TeX-run-TeX nil t))
;; (add-to-list 'TeX-view-program-list '("sumatra-viewer" "%(sumatra) -reuse-instance -forward-search %(tex-file-name) %(line-number) %(pdf-file-name)"))
;; (setq TeX-view-program-selection '((output-pdf "sumatra-viewer")))))))
;; Set fill-column for fill-paragraph command. Also wraps visual-fill-column-width globally at this value
(setq fill-column 80)
;; (dolist (hook 'text-mode-hook markdown-mode-hook tex-mode-hook LaTeX-mode-hook latex-mode-hook ...)
;; (add-hook hook (lambda ())))
(add-hook 'text-mode-hook
(lambda ()
(visual-fill-column-mode)
(setq visual-fill-column-width 91)
(setq visual-fill-column-center-text t)))
(add-hook 'tex-mode-hook
(lambda ()
(setq visual-fill-column-width 94)))
(add-hook 'org-mode-hook
(lambda ()
(setq visual-fill-column-center-text nil)
(setq visual-fill-column-width 108)
;; Turns off TODO, DONE, NEXT, and set local so doesn't override default value
(setq-local hl-todo-keyword-faces '(("HOLD" . "#d0bf8f") ("T0D0" . "#cc9393")
("TOD0" . "#cc9393") ("TODOO" . "#cc9393")
("THEM" . "#dc8cc3") ("PROG" . "#7cb8bb") ("OKAY" . "#7cb8bb")
("DONT" . "#5f7f5f") ("FAIL" . "#8c5353")
("FINISHED" . "#afd8af") ("UNSURE" . "#dc8cc3") ("T000" . "#cc9393")
("NOTE" . "#d0bf8f") ("KLUDGE" . "#d0bf8f") ("HACK" . "#d0bf8f")
("TEMP" . "#d0bf8f") ("FIXME" . "#cc9393") ("XXX+" . "#cc9393")
("QQQ+" . "#cc9393")
))
(hl-todo-mode)
))
(add-hook 'nxml-mode-hook
(lambda ()
(setq visual-fill-column-mode nil)
(setq visual-fill-column-center-text nil)
(setq visual-fill-column-width 108)
))
(add-hook 'table-lood-hook
(lambda ()
(setq visual-fill-column-mode nil)
(setq visual-fill-column-center-text t)
(setq visual-fill-column-width 200)
))
(add-hook 'org-src-mode-hook
(lambda ()
(setq visual-fill-column-center-text t)
(setq visual-fill-column-width 200)
(setq visual-fill-column-mode nil)
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; hl-todo highlight todo mode settins
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq hl-todo-highlight-punctuation "\-:*/~=#<>|\\?")
;; Sets for every buffer so can run hl-todo-occur even if hl-todo-mode not enabled
(setq-default hl-todo--regexp "\\(\\<\\(HOLD\\|TODO\\|T0D0\\|NEXT\\|TOD0\\|TODOO\\|THEM\\|PROG\\|OKAY\\|DONT\\|FAIL\\|DONE\\|FINISHED\\|UNSURE\\|T000\\|NOTE\\|KLUDGE\\|HACK\\|TEMP\\|FIXME\\|XXX+\\|QQQ+\\)\\(?:\\>\\|\\>?\\)[-:*/~=#<>|\\?]*\\)")
(setq-default hl-todo-keyword-faces '(("HOLD" . "#d0bf8f") ("TODO" . "#cc9393") ("T0D0" . "#cc9393")
("NEXT" . "#dca3a3") ("TOD0" . "#cc9393") ("TODOO" . "#cc9393")
("THEM" . "#dc8cc3") ("PROG" . "#7cb8bb") ("OKAY" . "#7cb8bb")
("DONT" . "#5f7f5f") ("FAIL" . "#8c5353") ("DONE" . "#afd8af")
("FINISHED" . "#afd8af") ("UNSURE" . "#dc8cc3") ("T000" . "#cc9393")
("NOTE" . "#d0bf8f") ("KLUDGE" . "#d0bf8f") ("HACK" . "#d0bf8f")
("TEMP" . "#d0bf8f") ("FIXME" . "#cc9393") ("XXX+" . "#cc9393")
("QQQ+" . "#cc9393")
))
;; below uneccasry because hl-todo-mode is set by hl-todo-activate-in-modes
;; this defualts to (prog-mode text-mode) but not turned on in org-mode
(global-hl-todo-mode)
;; highlight todo, done, and fixme in prog-modes and latex-mode
;; (dolist (hook '(prog-mode-hook latex-mode-hook markdown-mode-hook ...))
;; (add-hook hook (lambda ()
;; (hl-todo-mode))))
;; (add-hook 'text-mode-hook (lambda () (text-scale-decrease 1)))
;; Setup fonts and t
(defface doom-fixme-tasks ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:foreground "#ff3300"))) "")
(setq doom/ivy-task-tags
'(("TODO" . warning)
;; ("XXX" . warning)
;; ("XXXX" . warning)
;; ("QQQQ" . warning)
;; ("QQQ" . warning)
;; ("UNSURE" . doom-fixme-tasks)
("DONE" . success)
;; ("NOTE" . success)
;; ("FINISHED" . success)
("CANCELED" . success)
("FAIL" . doom-fixme-tasks)
("FIXME" . doom-fixme-tasks)
))
(defalias 'jj/doom/ivy-ag-rg-todos-tasks 'doom/ivy-tasks)
;; Beacon mode settings
(beacon-mode)
(setq beacon-blink-duration 0.3)
(setq beacon-blink-delay 0.1)
(setq beacon-size 35)
;; (setq beacon-color "#B194CB")
(setq beacon-blink-when-focused t)
(setq beacon-blink-when-window-changes t)
(setq beacon-blink-when-buffer-changes t)
(setq beacon-blink-when-point-moves-horizontally nil)
(setq beacon-blink-when-point-moves-vertically nil)
(setq beacon-blink-when-window-scrolls nil)
;; (jj/append-to-list-no-duplicates 'beacon-dont-blink-commands '(evil-scroll-down evil-scroll-up evil-scroll-page-up evil-scroll-page-down jj/evil-scroll-up-15-lines jj/evil-scroll-down-15-lines evil-scroll-line-up evil-scroll-line-down) t)
(add-hook 'eyebrowse-post-window-switch-hook #'beacon-blink)
;; Visible mark settings
(defface visible-mark-active ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:background "magenta"))) "")
(defface visible-mark-light-purple ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:background "#7549EC"))) "")
(defface visible-mark-light-orange ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:background "#BF674A"))) "")
(defface visible-mark-dark-orange ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:background "#AE5041"))) "")
(defface visible-mark-magenta ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:background "#A445A7"))) "")
(defface visible-mark-dark-teal ;; put this before (require 'visible-mark)
'((((type tty) (class mono)))
(t (:background "#226E68"))) "")
;; looping below to set faces to certain attributes
;; (dolist (face '(sml/line-number sml/numbers-separator sml/col-number))
;; (set-face-attribute face nil
;; :background zenburn/bg-1
;; :foreground zenburn/fg
;; :weight 'unspecified))
(global-visible-mark-mode 1)
(setq visible-mark-max 2)
(setq visible-mark-faces `(visible-mark-face1 visible-mark-face2))
;; use below for dark themes
;; (setq visible-mark-faces `(visible-mark-magenta visible-mark-dark-orange))
(setq show-paren-priority 999)
;; (setq avy-timeout-seconds 0.5)
;; Can also use fullheight, fullwidth, fullboth<-(makes it go into own space)
;; if use f11 to fullscreen into own space then new ones open in own space
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
(add-to-list 'default-frame-alist '(fullscreen . maximized))
;; So no gaps between emacs frames and other windows
(setq frame-resize-pixelwise t)
;; (setq magit-remote-set-if-missing nil)
;; Typing: "Fixes #" in git commit buffer will bring up all the issues in helm window
(add-hook 'git-commit-mode-hook 'git-commit-insert-issue-mode)
;; Added because on mac this call to git faster apparently
(if (eq system-type 'darwin) (cond ((file-exists-p "/usr/local/bin/git") (setq magit-git-executable "/usr/local/bin/git"))
((file-exists-p "/opt/homebrew/bin/git") (setq magit-git-executable "/opt/homebrew/bin/git"))))
(setq magit-branch-prefer-remote-upstream t)
;; FIXME: Do I want to add these?
;; (remove-hook 'magit-status-sections-hook 'magit-insert-unpushed-to-pushremote)
;; (remove-hook 'magit-status-sections-hook 'magit-insert-unpushed-to-upstream-or-recent)
;; (remove-hook 'magit-status-sections-hook 'magit-insert-unpulled-from-pushremote)
;; (remove-hook 'magit-status-sections-hook 'magit-insert-unpulled-from-upstream)
;; Makes it so you can't kill this buffer (but with dired can't usa a or keys that don't open new buffer
;; (with-current-buffer "Downloads"
;; (emacs-lock-mode 'kill))
;; Themes
(setq custom-safe-themes t)
;; (when (display-graphic-p)
;; (load-theme 'leuven t)
;; )
(sml/setup)
(setq sml/theme 'automatic)
(jj/sml/total-lines-append-mode-line)
(setq line-number-display-limit-width 500)
;; Set for file size line number not too display
;; (setq line-number-display-limit )
;; (setq jmax-user-theme 'monokai)
;; (setq sml/theme 'dark)
;; (add-hook 'after-init-hook (lambda () (load-theme 'smart-mode-line-dark)))
(cond
((string-equal system-type "darwin")
(set-face-attribute 'default nil :font "Hack-14"))
((string-equal system-type "gnu/linux")
(set-face-attribute 'default nil :font "Hack-12")))
;; possibly set after-setting-font-hook if changing themes a lot to keep setting the mode-line
;; or since use dired a lot set in function that forces mode-line to be rewritten
(cond
;; ((string-equal system-type "gnu/linux")
;; (set-face-attribute 'default nil :font "Hack-12"))
((string-equal system-type "darwin")
(set-face-attribute 'mode-line nil :font "Lucida Grande-13")))
(add-hook 'emacs-lisp-mode-hook 'jj/remove-elc-on-save)
;; this is a test does it work well I think so
(jj/load-theme-sanityinc-tomorrow-eighties)
(setq global-auto-revert-mode t)
;; refresh dired buffers when revisited
(setq dired-auto-revert-buffer t)
;; Below works by not auto reverting recursive directories (subdir)
;; (setq dired-auto-revert-buffer (lambda (_dir) (null (cdr dired-subdir-alist))))
(setq auto-revert-verbose nil) ;; Set to nil to not generate messages
(setq dired-omit-verbose nil)
;; Uses xargs to run commands instead of passing -exec to find which makes it very slow
(setq find-ls-option '("-print0 | xargs -0 ls -ld" . "-ld"))
(add-hook
'dired-mode-hook
(lambda ()
(auto-revert-mode)
(when (file-remote-p dired-directory)
(setq-local dired-actual-switches "-a -F -Alh"))
(dired-omit-caller)
(dired-hide-details-mode)
(dired-sort-toggle-or-edit)
(when (get-buffer "saves-*")
(progn
(with-current-buffer "saves-*"
(interactive)
(setq dired-omit-mode nil)
(dired-hide-details-mode 0)
(jj/dired-sort-by-time-switch-toggle))))))
(setq dired-create-destination-dirs 'ask)
(setq dired-ranger-bookmark-reopen 'always)
;; Set up so that dired+ mode properly ignores auto-save files
;; Need to load dired+ after setting up the settings or they don't work
(jj/append-to-list 'dired-omit-extensions '("#" "##"))
(setq diredp-ignore-compressed-flag nil)
(setq diredp-omit-files-regexp "\\.#\\|\\.\\|\\.\\.\\|\\..*")
(setq dired-dwim-target t)
(setq wdired-allow-to-change-permissions t)
;; start directory
(defvar jj/move-file-here-start-dir (expand-file-name "~/Downloads"))
(defvar-local is-new-file-buffer nil)
(add-hook 'kill-buffer-hook 'jj/save-new-file-before-kill)
;; Not necessary because can't symlink settings elc with emacs native comp or emacs is broken
;; (add-hook 'kill-emacs-hook 'jj/brc-functions-file)
;; Setup remebering what major mode to open files with no file extension
;; Appends these to the list to open files
;; TODO: Improve this if using because seems to load the file many times
;; (add-to-list 'savehist-additional-variables 'kill-ring)
(add-to-list 'savehist-additional-variables 'jj/last-change-pos1)
(add-to-list 'savehist-additional-variables 'jj/last-change-pos2)
(add-hook 'find-file-hook 'jj/find-file-hook-root-header-warning)
;; (add-hook 'jj/find-file-root-hook 'find-file-root-header-warning)
(add-to-list 'savehist-additional-variables 'jj/find-file-root-history)
;; Needs to be defined before savehist-mode is loaded
;; Save the dired directories previously used for copy and rename and goto with ,
(add-to-list 'savehist-additional-variables 'ivy-dired-history-variable)
(add-to-list 'savehist-additional-variables 'recentf-list)
;; Out of the box desktop.el saves registers but in case of error this is backup
(add-to-list 'savehist-additional-variables 'register-alist)
;; (add-to-list 'savehist-additional-variables 'save-place-alist)
(setq savehist-autosave-interval (* 9 60))
(defvar file-name-mode-alist '())
;; (add-to-list 'savehist-additional-variables 'file-name-mode-alist)
(when (fboundp 'file-name-mode-alist)
(setq auto-mode-alist (append auto-mode-alist file-name-mode-alist)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Backup each save and emacs default backup settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'after-save-hook 'backup-each-save)
(setq backup-each-save-mirror-location (expand-file-name "~/.emacs_path_backups"))
;; Backup-save size limit is set to 5mb
(setq backup-each-save-size-limit (* 1024 1024 2))
(setq backup-each-save-filter-function 'jj/backup-each-save-filter)
;; https://www.emacswiki.org/emacs/BackupFiles
(setq
backup-inhibited nil ; enable backups
backup-by-copying t ; don't clobber symlinks
kept-new-versions 4 ; keep 12 latest versions
kept-old-versions 1 ; don't bother with old versions
delete-old-versions t ; don't ask about deleting old versions
version-control t ; number backups
vc-make-backup-files t) ; backup version controlled files
;; Later maybe update the backup functions above so the tramp files are stored into their own
;; per-session and per-save directories
(add-to-list 'backup-directory-alist
(cons tramp-file-name-regexp (expand-file-name "~/.emacs_backups/per-save")))
;; Disabling backups can be targeted to just the su and sudo methods:
;; (setq backup-enable-predicate
;; (lambda (name)
;; (and (normal-backup-enable-predicate name)
;; (not
;; (let ((method (file-remote-p name 'method)))
;; (when (stringp method)
;; (member method '("su" "sudo"))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; backup every save ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; http://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files
;; https://www.emacswiki.org/emacs/backup-each-save.el
(defvar jj/backup-file-size-limit (* 5 1024 1024)
"Maximum size of a file (in bytes) that should be copied at each savepoint.
If a file is greater than this size, don't make a backup of it.
Default is 5 MB")
(defvar jj/backup-location (expand-file-name "~/.emacs_backups")
"Base directory for backup files.")
(defvar jj/backup-trash-dir (expand-file-name "~/.Trash")
"Directory for unwanted backups.")
(defvar jj/backup-exclude-regexp "\\.\\(vcf\\|gpg\\|pdf\\|snes\\|org_archive\\)$"
"Don't back up files matching this regexp.
Files whose full name matches this regexp are backed up to `jj/backup-trash-dir'. Set to nil to disable this.")
(defvar jj/backup-exclude-file-regex "\\(gcal\\.org\\|\\bookmarks\\)$"
"Don't back up files matching this regexp.
Files whose full name matches this regexp are backed up to `jj/backup-trash-dir'. Set to nil to disable this.")
;; Default and per-save backups go here:
;; N.B. backtick and comma allow evaluation of expression
;; when forming list
(setq backup-directory-alist
`(("" . ,(expand-file-name "per-save" jj/backup-location))))
;; add trash dir if needed
(if jj/backup-exclude-regexp
(add-to-list 'backup-directory-alist `(,jj/backup-exclude-regexp . ,jj/backup-trash-dir)))
(if jj/backup-exclude-file-regex
(add-to-list 'backup-directory-alist `(,jj/backup-exclude-file-regex . ,jj/backup-trash-dir)))
;; add to save hook
(add-hook 'before-save-hook 'jj/backup-every-save)
;; If sensitive mode is turned off then the autosave file will be created
;; and the backups will go to the trash due to the settings jj/backup-every-save
;; Can also use the below to make it sensitive-minor mode
;; // -*-mode:org; mode:sensitive; fill-column:132-*-
(setq auto-mode-alist
(append '(("\\.gpg$" . sensitive-mode)
;; ("\\.pdf$" . sensitive-mode)
)
auto-mode-alist))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Auto save settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; turn off auto-save-messages
(setq auto-save-no-message t)
;; auto save often
;; save every 20 characters typed (this is the minimum)
(setq auto-save-interval 60)
;; number of seconds before auto-save when idle
(setq auto-save-timeout 10)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dumbjump jump settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq dumb-jump-selector 'ivy)
(setq dumb-jump-prefer-searcher 'rg)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Go to (Special) End of Buffer for certain modes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(eval-after-load 'dired '(jj/special-beginning-of-buffer dired
(while (not (ignore-errors (dired-get-filename)))
(dired-next-line 1))))
(jj/special-end-of-buffer dired
(if (not (ignore-errors (dired-get-filename)))
(dired-previous-line 1)))
(jj/special-beginning-of-buffer occur
(occur-next 1))
(jj/special-end-of-buffer occur
(occur-prev 1))
(jj/special-beginning-of-buffer ibuffer
(ibuffer-forward-line 1))
(jj/special-end-of-buffer ibuffer
(ibuffer-backward-line 1))
(jj/special-beginning-of-buffer vc-dir
(vc-dir-next-line 1))
(jj/special-end-of-buffer vc-dir
(vc-dir-previous-line 1))
(jj/special-beginning-of-buffer bs
(bs-down 2))
(jj/special-end-of-buffer bs
(bs-up 1)
(bs-down 1))
(jj/special-beginning-of-buffer recentf-dialog
(when (re-search-forward "^ \\[" nil t)
(goto-char (match-beginning 0))))
(jj/special-end-of-buffer recentf-dialog
(re-search-backward "^ \\[" nil t))
(jj/special-beginning-of-buffer ag
(compilation-next-error 1))
(jj/special-end-of-buffer ag
(compilation-previous-error 1))
(jj/special-beginning-of-buffer org-agenda
(org-agenda-next-item 1))
(jj/special-end-of-buffer org-agenda
(org-agenda-previous-item 1))
(jj/special-beginning-of-buffer ag
(compilation-next-error 1))
(jj/special-end-of-buffer ag
(compilation-previous-error 1))
(jj/special-end-of-buffer elfeed-search
(forward-line -2))
(jj/special-end-of-buffer elfeed-search
(forward-line -2))
;; (savehist-mode 1)
;; not needed as above does the same thing
;; (run-with-timer (* 30 60) (* 30 60) 'savehist-save)
;; or if you use desktop-save-mode
(add-hook 'after-change-major-mode-hook
(lambda ()
(when (and
buffer-file-name
(not
(file-name-extension
buffer-file-name)))
(setq file-name-mode-alist
(cons
(cons buffer-file-name major-mode)
file-name-mode-alist))
(setq auto-mode-alist
(append auto-mode-alist
(list (cons buffer-file-name major-mode)))))))
;; Faster pop-to-mark by if cursor in same location repeatedly pop mark
(advice-add 'pop-to-mark-command :around #'jj/multi-pop-to-mark)
(advice-add 'semantic-idle-scheduler-function :around #'ignore)
;; Sets up so going to previous place in previous buffer works correctly
(add-hook 'after-change-functions 'jj/buffer-change-hook)
(setq openwith-associations
'(("\\.\\(?:mpe?g\\|avi\\|wmv\\|dmg\\|pkg\\|mat\\|mkv\\|xlsx\\|mp4\\|m4a\\|mp3\\|xls\\|doc\\|docx\\|ppt\\|pptx\\|wav\\|mov\\|psd\\)\\'" "open" (file))))
;; '(("\\.avi\\'" "open" (file))))
(openwith-mode t)
;; dired won't ask unless file bigger than 100MB set to nil to completely get rid of
(setq large-file-warning-threshold 100000000)
;; Makes it so don't ask for these file types if opening bigger than 100MB
(defvar jj/ok-large-file-types
(rx "." (or "mp4" "mkv" "avi" "mpeg" "mpg" "wmv" "mov" "m4a" "dmg") string-end)
"Regexp matching filenames which are definitely ok to visit,
even when the file is larger than `large-file-warning-threshold'.")
(defadvice abort-if-file-too-large (around my-check-ok-large-file-types)
"If FILENAME matches `jj/ok-large-file-types', do not abort."
(unless (string-match-p jj/ok-large-file-types (ad-get-arg 2))
ad-do-it))
(ad-activate 'abort-if-file-too-large)
;; Directories sorted by folder first
(cond
((string-equal system-type "darwin")
(setq insert-directory-program "gls" dired-use-ls-dired t)))
;; -A means almost all below not including . and ..
;; (setq dired-omit-case-fold t)
(setq dired-listing-switches "-a -F -lGhHAv --group-directories-first")
;; First is normal then group directories first and then with proper number sorting scheme -v
;; (setq dired-listing-switches "-lXGh --group-directories-first")
;; Very dangerous to set to always below (on Mac sends to Trash so ok to set to always)
(setq dired-recursive-copies 'always)
(if (eq system-type 'darwin) (setq dired-recursive-deletes 'always)
(setq dired-recursive-deletes 'top))
(setq dired-omit-mode t)
(setq dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$\\|^\\..*$")
;; (setq dired-omit-files "^\\...+$")
;; Makes it so doesn't ask if I want to use the command the first time
;; (if set to t it will ask me the first time when starting emacs)
(put 'dired-find-file-other-buffer 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
(setq dired-guess-shell-alist-user
(list
'("\\.dvi\\'" "xdvi" ) ; preview and printing
'("\\.mpe?g\\'\\|\\.avi\\'\\|\\.mkv\\'\\|\\.mp4\\'" "open -a NicePlayer")
'("\\.ogg\\'" "open -a Clementine")
'("\\.mp3\\'" "open -a Clementine")
'("\\.gif\\'" "open -a Preview") ; view gif pictures
'("\\.tif\\'" "open -a Preview")
'("\\.png\\'" "open -a Preview") ; xloadimage 4.1 doesn't grok PNG
'("\\.jpe?g\\'" "open -a Preview")
'("\\.fig\\'" "xfig") ; edit fig pictures
'("\\.out\\'" "xgraph") ; for plotting purposes.
'("\\.tex\\'" "latex" "tex")
'("\\.texi\\(nfo\\)?\\'" "makeinfo" "texi2dvi")
'("\\.pdf\\'" "open -a Preview")
))
;; Also placed in preload.el right now
(setq emacs-lock-default-locking-mode 'kill)
(with-current-buffer "*scratch*"
(emacs-lock-mode 'kill))
;; different from find-alternate-file because when hit enter on file
;; keeps that directory open and opens file (find-alt will close the dired buffer)
(defadvice dired-advertised-find-file (around dired-subst-directory activate)
"Replace current buffer if file is a directory."
(interactive)
(let ((orig (current-buffer))
(filename (dired-get-filename)))
ad-do-it
(when (and (file-directory-p filename)
(not (eq (current-buffer) orig)))
(kill-buffer orig))))
;; (require 'savehist)
;; (add-to-list 'savehist-additional-variables 'helm-dired-history-variable)
;; (savehist-mode 1)
;; (with-eval-after-load 'dired
;; (require 'helm-dired-history)
;; ;; if you are using ido,you'd better disable ido for dired
;; ;; (define-key (cdr ido-minor-mode-map-entry) [remap dired] nil) ;in ido-setup-hook
;; (define-key dired-mode-map "[" 'dired))
;; save all buffers when you lose emacs focus
;; (add-hook 'focus-out-hook (lambda () (save-some-buffers t)))
;; auto-save all buffers when you lose emacs focus
(add-hook 'focus-out-hook (lambda () (do-auto-save t)))
;; open in the original frame
(setq ns-pop-up-frames nil)
;; Deals with remembering window history and go back with C-c left/right
(winner-mode 1) ;; winner-undo and winner-redo the functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org-mode (scimax specific org-mode also)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(scimax-toggle-abbrevs 'scimax-month-abbreviations +1)
(scimax-toggle-abbrevs 'scimax-weekday-abbreviations +1)
(scimax-toggle-abbrevs 'scimax-chemical-formula-abbreviations -1)
(scimax-toggle-abbrevs 'scimax-misc-abbreviations 1)
(scimax-toggle-abbrevs 'scimax-contraction-abbreviations +1)
(setq scimax-autoformat-ordinals nil)
(setq scimax-autoformat-fractions t)
(setq scimax-autoformat-superscript nil)
(setq scimax-autoformat-transposed-caps nil)
(setq scimax-autoformat-sentence-capitalization nil)
;; ;; To turn them on all that time add the line below
(add-hook 'org-mode-hook 'scimax-autoformat-mode)
;; deletes comments before export so paragraphs aren't split where comments are
;; (add-hook 'org-export-before-processing-hook 'delete-org-comments)
;; Bibliography
;; (setq reftex-default-bibliography '((expand-file-name "~/Google-dr/Research/MyWork/Bibtex/library.bib")))
;; see org-ref for use of these variables
;; (setq org-ref-bibliography-notes (expand-file-name "~/Google-dr/Research/MyWork/Bibtex/libraryNotes.bib")
;; org-ref-default-bibliography '((expand-file-name "~/Google-dr/Research/MyWork/Bibtex/library.bib"))
;; org-ref-pdf-directory (expand-file-name "~/Google-dr/Research/Papers/"))
;; setup when start refiling notes
;; (setq org-refile-targets
;; '(("gtd.org" :maxlevel . 1)
;; ("done.org" :maxlevel . 1)))
(setq org-refile-targets
'((nil :maxlevel . 1)
(org-agenda-files :maxlevel . 2)))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Orgzly/gtd.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Orgzly/gtd.org" :maxlevel . 3)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Computer_notes.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Computer_notes.org" :maxlevel . 2)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Orgzly/Manager_notes.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Orgzly/Manager_notes.org" :maxlevel . 2)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/archive/Archive_notes.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/archive/Archive_notes.org" :maxlevel . 1)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Interview_prep.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Interview_prep.org" :maxlevel . 1)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Orgzly/Books_notes.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Orgzly/Books_notes.org" :maxlevel . 2)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Orgzly/someday.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Orgzly/someday.org" :maxlevel . 1)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Work/gtd_work.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Work/gtd_work.org" :maxlevel . 3)
))))
(if (file-exists-p (expand-file-name "~/Dropbox/Documents/Notes/Work/realtor.org"))
(setq org-refile-targets (append org-refile-targets
'(("~/Dropbox/Documents/Notes/Work/realtor.org" :maxlevel . 3)
))))
(setq org-outline-path-complete-in-steps nil) ; Refile in a single go
;; also seen people set use-outline-path to 'file
;; this allows refiling to the top level of a file
;; TODO: Possible change back to t instead of 'file if don't need to refile at the top level
(setq org-refile-use-outline-path 'file) ; Show full paths for refiling
(setq org-refile-allow-creating-parent-nodes 'confirm)
(setq org-download-screenshot-method "screencapture -i %s")