-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.org~
1269 lines (978 loc) · 37.3 KB
/
config.org~
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
#+TITLE: Emacs Configuration File
#+AUTHOR: Timo Lassmann
#+LATEX_CLASS: report
#+OPTIONS: toc:nil
#+OPTIONS: H:4
#+LATEX_CMD: xelatex
#+PROPERTY: header-args:emacs-lisp :tangle elisp/config-main.el
#+PROPERTY: header-args:shell :tangle no
#+PROPERTY: header-args :results silent :eval no-export :comments org
# \Author{Timo La\ss mann}
# \DocumentID{src_sh[:value verbatim]{shasum -a 256 config.org | awk '{print $1}' }}
* General Settings
** Whoami
#+BEGIN_SRC emacs-lisp
(setq user-full-name "Timo Lassmann"
user-mail-address "[email protected]")
#+END_SRC
** Emacs directory
#+BEGIN_SRC emacs-lisp
(defconst tl/emacs-directory (concat (getenv "HOME") "/.emacs.d/"))
(defun tl/emacs-subdirectory (d) (expand-file-name d tl/emacs-directory))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(message "%s" (tl/emacs-subdirectory "elisp"))
(add-to-list 'load-path (tl/emacs-subdirectory "elisp"))
#+END_SRC
** Sensible setting
#+BEGIN_SRC emacs-lisp
(load-file "~/.emacs.d/elisp/sensible-defaults.el")
(sensible-defaults/increase-gc-threshold)
(sensible-defaults/use-all-settings)
(sensible-defaults/use-all-keybindings)
#+END_SRC
** Very general
#+BEGIN_SRC emacs-lisp
(setq scroll-conservatively 10000
scroll-preserve-screen-position t)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(let ((path-from-shell (shell-command-to-string "/bin/bash -l -c 'echo $PATH'")))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator)))
#+END_SRC
** Modernizing Emacs
Found [[https://github.com/wasamasa/dotemacs/blob/master/init.org#init][here]] how to remove the warnings from the GnuTLS library when
using HTTPS... increase the minimum prime bits size:
#+BEGIN_SRC emacs-lisp
(setq gnutls-min-prime-bits 4096)
#+END_SRC
** misc
Assume that I always want to kill the current buffer when hitting C-x k.
#+BEGIN_SRC emacs-lisp
(defun tl/kill-current-buffer ()
"Kill the current buffer without prompting."
(interactive)
(kill-buffer (current-buffer)))
(global-set-key (kbd "C-x k") 'tl/kill-current-buffer)
#+END_SRC
Never use tabs. Tabs are the devil’s whitespace.
#+BEGIN_SRC emacs-lisp
(setq-default indent-tabs-mode nil)
#+END_SRC
Tell emacs about the mactex installation...
#+BEGIN_SRC emacs-lisp
(setenv "PATH" (concat "/Library/TeX/texbin" ":" (getenv "PATH")))
#+END_SRC
This should do it...
** Start in fullscreen
Start in fullscreen mode
#+BEGIN_SRC emacs-lisp
(custom-set-variables '(initial-frame-alist (quote ((fullscreen . maximized)))))
#+END_SRC
* Package Initialization
** Package Manager
Emacs has become like every other operating system, and now has a
[[http://tromey.com/elpa/][package manager]] with its own collection repository, but since it is
so conservative, we need to add more repositories to get all the
sweet goodness, I demand.
#+BEGIN_SRC emacs-lisp
(load-library "url-handlers")
(require 'package)
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(package-refresh-contents)
#+END_SRC
** Use-Package
Using [[https://github.com/jwiegley/use-package][use-package]] to automatically install certain packages, as
well as the ease of lazily loading them.
#+BEGIN_SRC emacs-lisp
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
#+END_SRC
** Init File Support
Load up a collection of enhancements to Emacs Lisp, including [[https://github.com/magnars/dash.el][dash]],
[[https://github.com/magnars/s.el][s]] for string manipulation, and [[https://github.com/rejeep/f.el][f]] for file manipulation.
#+BEGIN_SRC emacs-lisp
(require 'cl)
(use-package dash
:ensure t
:config (eval-after-load "dash" '(dash-enable-font-lock)))
(use-package s
:ensure t)
(use-package f
:ensure t)
#+END_SRC
** Fill Mode
Automatically wrapping when you get to the end of a line (or the fill-region):
#+BEGIN_SRC emacs-lisp
(use-package fill
:bind (("C-c T f" . auto-fill-mode)
("C-c T t" . toggle-truncate-lines))
:init (add-hook 'org-mode-hook 'turn-on-auto-fill)
:diminish auto-fill-mode)
#+END_SRC
** Undo / redo
According to this article, I get better functionality than the redo+ plugin (which I can’t seem to get working well).
#+BEGIN_SRC emacs-lisp
(use-package undo-tree
:ensure t
:diminish undo-tree-mode
:init
(global-undo-tree-mode 1)
:config
(defalias 'redo 'undo-tree-redo)
:bind (("C-z" . undo) ; Zap to character isn't helpful
("C-S-z" . redo)))
#+END_SRC
End.
* Movement
** SMEX
#+BEGIN_SRC emacs-lisp
(use-package smex
:ensure t
:init (smex-initialize)
:bind ("M-x" . smex)
("M-X" . smex-major-mode-commands))
#+END_SRC
** IDO
#+BEGIN_SRC emacs-lisp
(use-package ido
:ensure t
:init (setq ido-enable-flex-matching t
ido-ignore-extensions t
ido-use-virtual-buffers t
ido-everywhere t)
:config
(ido-mode 1)
(ido-everywhere 1)
(add-to-list 'completion-ignored-extensions ".o")
(add-to-list 'completion-ignored-extensions ".elc")
(add-to-list 'completion-ignored-extensions "~")
(add-to-list 'completion-ignored-extensions ".bin")
(add-to-list 'completion-ignored-extensions ".bak")
(add-to-list 'completion-ignored-extensions ".obj")
(add-to-list 'completion-ignored-extensions ".map")
(add-to-list 'completion-ignored-extensions ".a")
(add-to-list 'completion-ignored-extensions ".ln")
(add-to-list 'completion-ignored-extensions ".mod")
(add-to-list 'completion-ignored-extensions ".gz")
(add-to-list 'completion-ignored-extensions ".aux")
(add-to-list 'completion-ignored-extensions ".tdo")
(add-to-list 'completion-ignored-extensions ".fmt")
(add-to-list 'completion-ignored-extensions ".swp")
(add-to-list 'completion-ignored-extensions ".pdfsync")
(add-to-list 'completion-ignored-extensions ".pdf")
(add-to-list 'completion-ignored-extensions ".vrb")
(add-to-list 'completion-ignored-extensions ".idx")
(add-to-list 'completion-ignored-extensions ".ind")
(add-to-list 'completion-ignored-extensions ".bbl")
(add-to-list 'completion-ignored-extensions ".toc")
(add-to-list 'completion-ignored-extensions ".blg")
(add-to-list 'completion-ignored-extensions ".snm")
(add-to-list 'completion-ignored-extensions ".ilg")
(add-to-list 'completion-ignored-extensions ".log")
(add-to-list 'completion-ignored-extensions ".out")
(add-to-list 'completion-ignored-extensions ".pyc")
(add-to-list 'completion-ignored-extensions ".DS_Store")
(add-to-list 'completion-ignored-extensions "-blx.bib")
(add-to-list 'completion-ignored-extensions ".run.xml")
(add-to-list 'completion-ignored-extensions ".fls")
(add-to-list 'completion-ignored-extensions ".fdb_latexmk")
(add-to-list 'completion-ignored-extensions ".bcf")
(add-to-list 'completion-ignored-extensions ".rel")
(add-to-list 'completion-ignored-extensions ".epub")
)
#+END_SRC
FLX package:
#+BEGIN_SRC emacs-lisp
(use-package flx-ido
:ensure t
:init (setq ido-enable-flex-matching t
ido-use-faces t)
:config (flx-ido-mode 1))
#+END_SRC
According to Ryan Neufeld, we could make IDO work vertically, which is much easier to read. For this, I use ido-vertically:
#+BEGIN_SRC emacs-lisp
(use-package ido-vertical-mode
:ensure t
:init ; I like up and down arrow keys:
(setq ido-vertical-define-keys 'C-n-C-p-up-and-down)
:config
(ido-vertical-mode 1))
#+END_SRC
This sorts an IDO filelist by mtime instead of alphabetically.
#+BEGIN_SRC emacs-lisp
(defun ido-sort-mtime ()
"Reorder the IDO file list to sort from most recently modified."
(setq ido-temp-list
(sort ido-temp-list
(lambda (a b)
(ignore-errors
(time-less-p
(sixth (file-attributes (concat ido-current-directory b)))
(sixth (file-attributes (concat ido-current-directory a))))))))
(ido-to-end ;; move . files to end (again)
(delq nil (mapcar
(lambda (x) (and (char-equal (string-to-char x) ?.) x))
ido-temp-list))))
(add-hook 'ido-make-file-list-hook 'ido-sort-mtime)
(add-hook 'ido-make-dir-list-hook 'ido-sort-mtime)
#+END_SRC
** Ace-window
#+BEGIN_SRC emacs-lisp
(use-package ace-window
:ensure t
:init
(setq aw-keys '(?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8))
:diminish ace-window-mode)
(global-set-key (kbd "C-x o") 'ace-window)
#+END_SRC
** Avy
#+BEGIN_SRC emacs-lisp
(use-package avy
:ensure t
:init (setq avy-background t))
(global-set-key (kbd "M-s") 'avy-goto-char-timer)
#+END_SRC
** Line Numbers
#+BEGIN_SRC emacs-lisp
(use-package linum
:ensure t
:init
(add-hook 'prog-mode-hook 'linum-mode)
(add-hook 'linum-mode-hook (lambda () (set-face-attribute 'linum nil :height 110)))
:config
(defun linum-fringe-toggle ()
"Toggles the line numbers as well as the fringe." (interactive)
(cond (linum-mode (fringe-mode '(0 . 0))
(linum-mode -1))
(t (fringe-mode '(8 . 0))
(linum-mode 1))))
:bind (("A-C-k" . linum-mode)
("s-C-k" . linum-mode)
("A-C-M-k" . linum-fringe-toggle)
("s-C-M-k" . linum-fringe-toggle)))
#+END_SRC
relative
#+BEGIN_SRC emacs-lisp
(use-package linum-relative
:ensure t
:config
(defun linum-new-mode ()
"If line numbers aren't displayed, then display them.
Otherwise, toggle between absolute and relative numbers."
(interactive)
(if linum-mode
(linum-relative-toggle)
(linum-mode 1)))
:bind ("A-k" . linum-new-mode)
("s-k" . linum-new-mode)) ;; For Linux
#+END_SRC
** Turn off mouse FIXME - why here
#+BEGIN_SRC emacs-lisp
(mouse-wheel-mode -1)
(global-set-key [wheel-up] 'ignore)
(global-set-key [wheel-down] 'ignore)
(global-set-key [double-wheel-up] 'ignore)
(global-set-key [double-wheel-down] 'ignore)
(global-set-key [triple-wheel-up] 'ignore)
(global-set-key [triple-wheel-down] 'ignore)
#+END_SRC
* Org-mode
** General setup
load org mode
#+BEGIN_SRC emacs-lisp
(use-package org
:init
(setq org-use-speed-commands t
org-return-follows-link t
org-completion-use-ido t
org-outline-path-complete-in-steps nil))
#+END_SRC
Directory, inbox ..
#+BEGIN_SRC emacs-lisp
(setq org-directory "~/Dropbox")
(defun org-file-path (filename)
"Return the absolute address of an org file, given its relative name."
(concat (file-name-as-directory org-directory) filename))
(setq org-index-file (org-file-path "/capture/inbox.org"))
(setq org-archive-location
(concat (org-file-path "archive.org") "::* From %s"))
#+END_SRC
Multiple files for agenda source:
#+BEGIN_SRC emacs-lisp
;; (setq org-agenda-files (list org-index-file))
(setq org-agenda-files '("~/Dropbox/capture"
"~/Dropbox/work"
"~/Dropbox/planning"
"~/Dropbox/life"))
#+END_SRC
Refile targets / create new targets if necessary
#+BEGIN_SRC emacs-lisp
;;(setq org-refile-targets '((org-agenda-files :maxlevel . 3)))
(setq org-refile-targets '(("~/Dropbox/work/work-todo.org" :maxlevel . 2)
("~/Dropbox/life/life-todo.org" :maxlevel . 2)
("~/Dropbox/org/gtd/tickler.org" :maxlevel . 2)))
(setq org-refile-use-outline-path 'file)
(setq org-refile-allow-creating-parent-nodes 'confirm)
(setq org-refile-allow-creating-parent-nodes 'confirm)
#+END_SRC
Drawers
#+BEGIN_SRC emacs-lisp
(setq org-log-into-drawer t)
;; Add the REPORT drawer
(setq org-drawers '("PROPERTIES" "CLOCK" "LOGBOOK" "REPORT"))
#+END_SRC
Hitting C-c C-x C-s will mark a todo as done and move it to an appropriate place
in the archive.
#+BEGIN_SRC emacs-lisp
(defun tl/mark-done-and-archive ()
"Mark the state of an org-mode item as DONE and archive it."
(interactive)
(org-todo 'done)
(org-archive-subtree))
;; (define-key org-mode-map (kbd "C-c C-x C-s") 'tl/mark-done-and-archive)
#+END_SRC
Record the time that a todo was archived.
#+BEGIN_SRC emacs-lisp
(setq org-log-done 'time)
#+END_SRC
** Capture
Capture templates..
#+BEGIN_SRC emacs-lisp
(setq org-capture-templates
(quote (("t" "todo" entry (file+headline org-index-file "Inbox")
"* TODO %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
("n" "note" entry (file+headline org-index-file "Inbox")
"* %?\n\n %i\n\n See: %a" :empty-lines 1)
("r" "respond" entry (file+headline org-index-file "Inbox")
"* TODO Respond to %:from on %:subject\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")
("m" "Mail" entry (file+headline org-index-file "Inbox")
"* TODO %?\n%a %:from %:fromname %:fromaddress" :prepend t :jump-to-captured t)
("p" "Daily Plan" plain (file+datetree "~/Dropbox/planning/daily-plan.org")
"+ [ ] The 3 most important tasks [/]
- [ ]
- [ ]
- [ ]
+ [ ] Other tasks that are in the system [/]
- [ ]
+ [ ] ToDos which are not tracked by my system [/]
- [ ] " :immediate-finish t)
)))
#+END_SRC
** Taking Meeting Notes
directly from https://github.com/howardabrams/dot-files/blob/master/emacs-org.org)
I’ve notice that while I really like taking notes in a meeting, I don’t always like the multiple windows I have opened, so I created this function that I can easily call to eliminate distractions during a meeting.
#+BEGIN_SRC emacs-lisp
(defun meeting-notes ()
"Call this after creating an org-mode heading for where the notes for the meeting
should be. After calling this function, call 'meeting-done' to reset the environment."
(interactive)
(outline-mark-subtree) ;; Select org-mode section
(narrow-to-region (region-beginning) (region-end)) ;; Only show that region
(deactivate-mark)
(delete-other-windows) ;; Get rid of other windows
(text-scale-set 3) ;; Text is now readable by others
(fringe-mode 0)
(message "When finished taking your notes, run meeting-done."))
#+END_SRC
Of course, I need an ‘undo’ feature when the meeting is over…
#+BEGIN_SRC emacs-lisp
(defun meeting-done ()
"Attempt to 'undo' the effects of taking meeting notes."
(interactive)
(widen) ;; Opposite of narrow-to-region
(text-scale-set 0) ;; Reset the font size increase
(fringe-mode 1)
(winner-undo)) ;; Put the windows back in place
#+END_SRC
End.
** Coding
Allow babel to evaluate C ...
#+BEGIN_SRC emacs-lisp
(org-babel-do-load-languages
'org-babel-load-languages
'((C . t)
(R . t)
(emacs-lisp . t)
(sh . t)
(makefile . t)
(latex .t)
))
#+END_SRC
Don’t ask before evaluating code blocks.
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil)
#+END_SRC
smart brackets in export
#+BEGIN_SRC emacs-lisp
(setq org-export-with-smart-quotes t)
#+END_SRC
Done.
** Export
Export packages...
#+BEGIN_SRC emacs-lisp
(require 'ox-latex)
(require 'ox-beamer)
#+END_SRC
Htmlize required for reveal...
#+BEGIN_SRC emacs-lisp
(use-package htmlize
:ensure t)
#+END_SRC
** Flyspell
Enable spell-checking in Org-mode.
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook 'flyspell-mode)
#+END_SRC
** Color and display
Use syntax highlighting in source blocks while editing.
#+BEGIN_SRC emacs-lisp
(setq org-src-fontify-natively t)
#+END_SRC
Make TAB act as if it were issued in a buffer of the language’s major mode.
#+BEGIN_SRC emacs-lisp
(setq org-src-tab-acts-natively t)
#+END_SRC
When editing a code snippet, use the current window rather than popping open a
new one (which shows the same information).
#+BEGIN_SRC emacs-lisp
(setq org-src-window-setup 'current-window)
#+END_SRC
** Image preview
Inline images support:
#+BEGIN_SRC emacs-lisp
(setq org-latex-create-formula-image-program 'imagemagick)
(add-to-list 'org-latex-packages-alist
'("" "tikz" t))
(eval-after-load "preview"
'(add-to-list 'preview-default-preamble "\\PreviewEnvironment{tikzpicture}" t))
(setq org-latex-create-formula-image-program 'imagemagick)
(setq org-confirm-babel-evaluate nil)
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
#+END_SRC
** Keybindings
Standard bindings
#+BEGIN_SRC emacs-lisp
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(define-key global-map "\C-cc" 'org-capture)
#+END_SRC
Quickly open index file
#+BEGIN_SRC emacs-lisp
(defun open-index-file ()
"Open the master org TODO list."
(interactive)
(find-file org-index-file)
(flycheck-mode -1)
(end-of-buffer))
(global-set-key (kbd "C-c i") 'open-index-file)
#+END_SRC
undef a key
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook
'(lambda ()
;; Undefine C-c [ and C-c ] since this breaks my
;; org-agenda files when directories are include It
;; expands the files in the directories individually
(org-defkey org-mode-map "\C-c[" 'undefined))
'append)
#+END_SRC
** Org-ref
#+BEGIN_SRC emacs-lisp
(use-package org-ref
:ensure t)
#+END_SRC
Define format for bibtex entries
#+BEGIN_SRC emacs-lisp
;; variables that control bibtex key format for auto-generation
;; I want firstauthor-year-title-words
;; this usually makes a legitimate filename to store pdfs under.
(setq bibtex-autokey-year-length 4
bibtex-autokey-name-year-separator "-"
bibtex-autokey-year-title-separator "-"
bibtex-autokey-titleword-separator "-"
bibtex-autokey-titlewords 2
bibtex-autokey-titlewords-stretch 1
bibtex-autokey-titleword-length 5)
#+END_SRC
Where are the refs?
#+BEGIN_SRC emacs-lisp
(setq reftex-default-bibliography '("~/org/bibliography/references.bib"))
;; see org-ref for use of these variables
(setq org-ref-bibliography-notes "~/org/bibliography/notes.org"
org-ref-default-bibliography '("~/org/bibliography/references.bib")
org-ref-pdf-directory "~/org/bibliography/bibtex-pdfs/")
#+END_SRC
** Latex templates
Latex templates
#+BEGIN_SRC emacs-lisp
(setq org-latex-listings t)
;;(setq org-latex-to-pdf-process '("xelatex %f && bibtex %f && xelatex %f && xelatex %f"))
(defun sk-latexmk-cmd (backend)
"When exporting from .org with latex, automatically run latex,
pdflatex, or xelatex as appropriate, using latexmk."
(when (org-export-derived-backend-p backend 'latex)
(let ((texcmd)))
;; default command: xelatex
(setq texcmd "jobname=$(basename %f | sed 's/\.tex//');latexmk -xelatex -shell-escape -quiet %f && mkdir -p latex.d && mv ${jobname}.* latex.d/. && mv latex.d/${jobname}.{org,pdf,fdb_latexmk,aux} .")
;; pdflatex -> .pdf
(if (string-match "LATEX_CMD: pdflatex" (buffer-string))
(setq texcmd "latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex %f"))
;; xelatex -> .pdf
(if (string-match "LATEX_CMD: xelatex" (buffer-string))
(setq texcmd "latexmk -pdflatex='xelatex -interaction nonstopmode' -pdf -bibtex -f %f"))
;; LaTeX compilation command
(setq org-latex-pdf-process (list texcmd))))
(org-add-hook 'org-export-before-processing-hook 'sk-latexmk-cmd)
(unless (boundp 'org-latex-classes)
(setq org-latex-classes nil))
#+END_SRC
** NHMRC project grant
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-latex-classes
'("NHMRC_project_grant"
"\\documentclass[12pt,table,names]{article}
\\usepackage{\\string~\"/.emacs.d/latex_templates/NHMRC_grant\"}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
#+END_SRC
** ARC Discovery Grant
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-latex-classes
'("ARC_discovery_grant"
"\\documentclass[12pt]{article}
\\usepackage{\\string~\"/.emacs.d/latex_templates/ARC_discovery\"}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")))
#+END_SRC
** Internal report
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-latex-classes
'("report"
"\\documentclass[12pt]{article}
\\usepackage{\\string~\"/.emacs.d/latex_templates/report\"}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
#+END_SRC
** Simple presentation
#+BEGIN_SRC emacs-lisp
(add-to-list 'org-latex-classes
'("simplepresentation"
"\\documentclass[aspectratio=169,18pt,t]{beamer}
\\usepackage{\\string~\"/.emacs.d/latex_templates/simple\"}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
("\\section{%s}" . "\\section*{%s}")
("\\begin{frame}[fragile]\\frametitle{%s}"
"\\end{frame}"
"\\begin{frame}[fragile]\\frametitle{%s}"
"\\end{frame}")))
#+END_SRC
end.
* Writing
** Writegood mode
This does not work - there is a wring gpg signature in melpa...
#+BEGIN_SRC emacs-lisp
(when (file-exists-p "/home/user/programs/writegood-mode")
(message "Loading writegood-mode")
(add-to-list 'load-path "/home/user/programs/writegood-mode")
(require 'writegood-mode)
(add-hook 'text-mode-hook 'writegood-mode)
(add-hook 'org-mode-hook 'writegood-mode)
)
#+END_SRC
this mode will improve various aspects of writing.
end..
* Programming
General programming settings..
** General
I like shallow indentation, but tabs are displayed as 8 characters by default. This reduces that.
#+BEGIN_SRC emacs-lisp
(setq-default tab-width 2)
#+END_SRC
Treating terms in CamelCase symbols as separate words makes editing a little
easier for me, so I like to use subword-mode everywhere.
#+BEGIN_SRC emacs-lisp
(global-subword-mode 1)
#+END_SRC
Compilation output goes to the *compilation* buffer. I rarely have that window
selected, so the compilation output disappears past the bottom of the window.
This automatically scrolls the compilation window so I can always see the
output.
#+BEGIN_SRC emacs-lisp
(setq compilation-scroll-output t)
#+END_SRC
** Auto Complete
#+BEGIN_SRC emacs-lisp
(use-package auto-complete
:ensure t
:commands auto-complete-mode
:init
(progn
(auto-complete-mode t))
:config
(progn
(use-package auto-complete-config)
(ac-set-trigger-key "TAB")
(ac-config-default)
(setq ac-delay 0.02)
(setq ac-use-menu-map t)
(setq ac-menu-height 50)
(setq ac-use-quick-help nil)
(setq ac-comphist-file "~/.emacs.d/ac-comphist.dat")
(setq ac-ignore-case nil)
(setq ac-dwim t)
(setq ac-fuzzy-enable t)
(use-package ac-dabbrev
:ensure t
:config
(progn
(add-to-list 'ac-sources 'ac-source-dabbrev)))
(setq ac-modes '(emacs-lisp-mode
lisp-mode
lisp-interaction-mode
c-mode
cc-mode
c++-mode
makefile-mode
sh-mode))))
(define-key ac-complete-mode-map "\C-n" 'ac-next)
(define-key ac-complete-mode-map "\C-p" 'ac-previous)
#+END_SRC
Headers
#+BEGIN_SRC emacs-lisp
(use-package auto-complete-c-headers
:ensure t)
(require 'auto-complete-config)
(ac-config-default)
; start yasnippet with emacs
; let's define a function which initializes auto-complete-c-headers and gets called for c/c++ hooks
(defun my:ac-c-header-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(add-to-list 'achead:include-directories '"/usr/include")
)
(add-hook 'c-mode-hook 'my:ac-c-header-init)
(semantic-mode 1)
; let's define a function which adds semantic as a suggestion backend to auto complete
; and hook this function to c-mode-common-hook
(defun my:add-semantic-to-autocomplete()
(add-to-list 'ac-sources 'ac-source-semantic)
)
(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
; turn on automatic reparsing of open buffers in semantic
(global-semantic-idle-scheduler-mode 1)
(global-semanticdb-minor-mode 1)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(setq-local imenu-create-index-function #'ggtags-build-imenu-index)
#+END_SRC
#+RESULTS:
: ggtags-build-imenu-index
** Yasnippet
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "M-/") 'hippie-expand)
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line))
#+END_SRC
Yasnippet
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1)
:config
(add-to-list 'yas-snippet-dirs (tl/emacs-subdirectory "snippets")))
#+END_SRC
** Comments
#+BEGIN_SRC emacs-lisp
(use-package smart-comment
:ensure t
:bind ("M-;" . smart-comment))
#+End_SRC
** Tags:
#+BEGIN_SRC example
(use-package etags
:init (setq tags-revert-without-query 1))
#+END_SRC
#+BEGIN_SRC example
(use-package ctags-update
:ensure t
:config
(add-hook 'prog-mode-hook 'turn-on-ctags-auto-update-mode)
:diminish ctags-auto-update-mode)
#+END_SRC
** C
ggtags
#+BEGIN_SRC emacs-lisp
(use-package ggtags
:ensure t
:commands (
ggtags-mode
ggtags-find-reference
ggtags-idutils-query
pop-tag-mark
) ; end :commands
:init
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode)
(ggtags-mode 1))))
:config
; This must be set to the location of gtags (global)
;;(setq ggtags-executable-directory "~/global-6.5.6/bin/")
; Allow very large database files
(setq ggtags-oversize-limit 104857600)
(setq ggtags-sort-by-nearness t)
(setq ggtags-use-idutils t)
(setq ggtags-use-project-gtagsconf nil)
:bind (
("M-," . pop-tag-mark)
;; ("M-/" . ggtags-find-reference)
("M-]" . ggtags-idutils-query)
:map ggtags-navigation-map
;Ergo
("M-u" . ggtags-navigation-previous-file)
("M-o" . ggtags-navigation-next-file)
("M-l" . ggtags-navigation-visible-mode)
("M-j" . ggtags-navigation-visible-mode)
("M-k" . next-error)
("M-i" . previous-error)
) ; end :bind
)
#+END_SRC
Smartparens
#+BEGIN_SRC emacs-lisp
(use-package smartparens
:ensure t
:init (add-hook 'C-mode-hook 'smartparens-mode))
#+END_SRC
Autocomplete
(use-package auto-complete
:ensure t)
(use-package auto-complete-c-headers
:ensure t)