-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot-emacs
863 lines (753 loc) · 31.3 KB
/
dot-emacs
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
; -*- emacs-lisp -*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This is Bryan Murdock's .emacs file.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; make it a little easier to split this into multiple files and load
;; those multiple files:
(defun load-user-file (file)
(interactive "f")
"Load a file in current user's configuration directory"
(load-file (expand-file-name file user-emacs-directory)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; settings and default modes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; I hate when I accidently kill emacs
(setq confirm-kill-emacs #'y-or-n-p)
;; Highlight matching parenthesis
(show-paren-mode t)
;; hitting delete will delete the highlighted region
(pending-delete-mode 1)
;; column number in the mode line
(column-number-mode 1)
;;;;; no silly tool bar at the top
(tool-bar-mode -1)
;;; taking the plunge and getting rid of the menu too
(menu-bar-mode -1)
;;; even more hardcore, no scrollbars
(scroll-bar-mode -1)
;; super hard-core, automatically revert buffers whenever they change
;; on disk:
(global-auto-revert-mode t)
;; enable ido-mode
(ido-mode t)
(ido-everywhere t)
;; got this advice from here:
;; http://emacsblog.org/2008/05/19/giving-ido-mode-a-second-chance/
(add-hook 'ido-setup-hook
(lambda ()
(define-key ido-completion-map [tab] 'ido-complete)))
;; recentf is great, but it cleans up tramp files too aggressively:
(setq recentf-auto-cleanup 'never)
(recentf-mode 1)
;; save periodically
(run-with-idle-timer 60 t 'recentf-save-list)
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
(global-set-key "\C-cr" 'ido-recentf-open)
;; With this, typing an abbreviations expands to something much more
;; (like a skeleton):
(setq-default abbrev-mode t)
(setq abbrev-file-name
"~/.emacs.d/abbrev-defs.el")
;;;;; scroll one line at a time ;;;;
(setq scroll-conservatively 5)
;; title bar shows name of current buffer and hostname
(setq frame-title-format '("emacs on " system-name ": %*%+ %b"))
;; don't show the startup message every time, I know I'm using emacs
;; thanks
(setq inhibit-startup-message t)
;; don't blink the cursor
(blink-cursor-mode -1)
(if (eq system-type 'darwin)
(setq ispell-program-name "/usr/local/bin/aspell")
)
(require 'ox-md)
;;;; use y or n instead of yes or no
(fset 'yes-or-no-p 'y-or-n-p)
;; paste where the cursor is, not where I'm pointing. Sometimes I
;; love it, sometimes I hate it...
(setq mouse-yank-at-point t)
;; Highlight current line
;(if (display-graphic-p)
(progn (global-hl-line-mode 1)
;; hard coded color for my tango-2 theme, may not look so
;; good with other themes :-(
(set-face-background 'hl-line "gray15"));)
;; use view mode for all read-only files
(setq view-read-only t)
;; hide show:
;;(hs-minor-mode t)
;; playing with eshell, this makes it pretty nifty:
;; (https://www.masteringemacs.org/article/complete-guide-mastering-eshell
;; and
;; https://www.8t8.us/blog/2016/06/05/enabling-eshell-smart-display-mode.html)
(require 'eshell)
(require 'em-smart)
(setq eshell-where-to-jump 'begin)
(setq eshell-review-quick-commands nil)
(setq eshell-smart-space-goes-to-end t)
(add-hook 'eshell-mode-hook
(lambda ()
(eshell-smart-initialize)))
;; make the eshell prompt close to my bash prompt, and update the
;; required prompt regexp:
(setq eshell-prompt-function
(lambda ()
(concat "["
(propertize (concat "@" (system-name))
'face `(:foreground "LightGoldenrod"))
" in "
(propertize (eshell/pwd) 'face `(:foreground "SkyBlue"))
"]\n"
(if (= (user-uid) 0) "# " "$ "))))
(setq eshell-highlight-prompt nil)
;; only has to recognize the last line of my multi-line prompt:
(setq eshell-prompt-regexp (concat "^" (regexp-quote "$ ")))
;; Fonts. Kind of a pain.
;; This gives me variable width font for text, fixed width for code
;; examples and stuff. Got this here:
;; https://emacs.stackexchange.com/questions/32300/monospace-font-for-calendar-buffer-and-tables-in-org-mode-proportional-font-i/32310
'(variable-pitch ((t (:height 200 :family "DejaVu Sans"))))
(defun set-buffer-variable-pitch ()
(interactive)
(variable-pitch-mode t)
(setq line-spacing 3)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit 'fixed-pitch)
(set-face-attribute 'org-block nil :inherit 'fixed-pitch)
(set-face-attribute 'org-verbatim nil :inherit 'fixed_pitch)
;; (set-face-attribute 'org-block-background nil :inherit 'fixed-pitch)
)
(add-hook 'org-mode-hook 'set-buffer-variable-pitch)
(add-hook 'eww-mode-hook 'set-buffer-variable-pitch)
(add-hook 'markdown-mode-hook 'set-buffer-variable-pitch)
(add-hook 'Info-mode-hook 'set-buffer-variable-pitch)
;; set default fonts for various computers I use:
(if (string-match "bryan-murdock" (system-name))
(set-frame-font
"-apple-Menlo-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1" nil t))
(if (string-match "malo" (system-name))
(set-frame-font
"-unknown-DejaVu Sans Mono-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1" nil t))
(if (string-match "bmurdock-laptop" (system-name))
(set-frame-font
"-PfEd-DejaVu Sans Mono-normal-normal-normal-*-22-*-*-*-m-0-iso10646-1"))
(if (string-match "bmurdock-vm" (system-name))
(set-frame-font
"-unknown-DejaVu Sans Mono Book-normal-normal-normal-*-20-*-*-*-m-0-iso10646-1"))
(if (string-match "msd" (system-name))
(set-frame-font
"-PfEd-DejaVu Sans Mono-normal-normal-normal-*-30-*-*-*-m-0-iso10646-1"))
(defun big-font()
(interactive)
(set-frame-font
"-PfEd-DejaVu Sans Mono-normal-normal-normal-*-30-*-*-*-m-0-iso10646-1"))
(defun small-font()
(interactive)
(set-frame-font
;; was 22, but my eyes are pretty good after LASIK, so trying this:
"-PfEd-DejaVu Sans Mono-normal-normal-normal-*-24-*-*-*-m-0-iso10646-1"))
(defun really-small-font()
(interactive)
(set-frame-font
"-PfEd-DejaVu Sans Mono-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1"))
(defun big-font-meslo()
(interactive)
(set-frame-font
"-PfEd-Meslo LG S DZ-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1"))
(defun small-font-meslo()
(interactive)
(set-frame-font
"-PfEd-Meslo LG S DZ-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1"))
(defun really-small-font-meslo()
(interactive)
(set-frame-font
"-PfEd-Meslo LG S DZ-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1"))
(defun big-font-inconsolata()
(interactive)
(set-frame-font
"-CYRE-Inconsolata-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1"))
(defun small-font-inconsolata()
(interactive)
(set-frame-font
"-CYRE-Inconsolata-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1"))
(defun really-small-font-inconsolata()
(interactive)
(set-frame-font
"-CYRE-Inconsolata-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1"))
(defun big-font-anon()
(interactive)
(set-frame-font
"-mlss-Anonymous Pro-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1"))
(defun small-font-anon()
(interactive)
(set-frame-font
"-mlss-Anonymous Pro-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1"))
(defun really-small-font-anon()
(interactive)
(set-frame-font
"-mlss-Anonymous Pro-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1"))
(defun big-font-non-mono()
(interactive)
(set-frame-font
"-PfEd-DejaVu Sans-normal-normal-normal-*-18-*-*-*-*-0-iso10646-1"))
(defun small-font-non-mono()
(interactive)
(set-frame-font
"-PfEd-DejaVu Sans-normal-normal-normal-*-16-*-*-*-*-0-iso10646-1"))
(defun really-small-font-non-mono()
(interactive)
(set-frame-font
"-PfEd-DejaVu Sans-normal-normal-normal-*-14-*-*-*-*-0-iso10646-1"))
;; ediff buffers sid-by-side, like it should:
(setq ediff-split-window-function 'split-window-horizontally)
;; also, don't pop-up a seperate frame, just make a new window:
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
;; allows you to undow changes to your window configureations (like
;; after an ediff session) by doing c-c left-arrow (or right-arrow for
;; a redo). Very handy:
(winner-mode t)
;; some people get upset if you use tabs instead of spaces, but I've
;; never seen anyone get upset for doing things the other way around,
;; so I decided to just use this (in short, uses spaces to indent
;; stuff, not tabs)
(setq-default indent-tabs-mode nil)
;; I'm playing with using more frames instead of windows, so that I
;; can use my (i3) window manager shortcuts to move around. I kept
;; confusing myself using one set of hot keys to switch emacs windows
;; and another to switch X windows. This makes emacs split frames
;; into windows less:
(setq same-window-regexps '("."))
;; Use cperl-mode instead of perl-mode (though I don't use perl much anymore)
(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
;; don't underline trailing whitespace (such an odd feature)
;; hmmmm...this doesn't work
(setq cperl-invalid-face nil)
;; modelsim do files are pretty-much TCL
(add-to-list 'auto-mode-alist '("\\.do?\\'" . tcl-mode))
;; xilinx ucf is kinda tcl, I think
(add-to-list 'auto-mode-alist '("\\.ucf?\\'" . tcl-mode))
;; conf mode for hgrc files
(add-to-list 'auto-mode-alist '("\\hgrc?\\'" . conf-mode))
;; conf mode for systemd files
(add-to-list 'auto-mode-alist '("\\.service?\\'" . conf-mode))
(add-to-list 'auto-mode-alist '("\\.timer?\\'" . conf-mode))
;; set the compilation buffer to always scroll to follow output as it
;; comes in.
(setq compilation-scroll-output 1)
;; enable this command that is disabled by default because it's
;; "confusing"
(put 'narrow-to-region 'disabled nil)
;; store backup files in ~/.backups-emacs/
(setq
;; don't clobber symlinks
backup-by-copying t
backup-directory-alist
;; don't litter my fs tree
'(("." . "~/.backups-emacs"))
delete-old-versions t
kept-new-versionhs 6
kept-old-versions 2
;; use versioned backups
version-control t)
;; This causes files that I'm editing to be saved automatically by the
;; emacs auto-save functionality. I'm hoping to break myself of the
;; c-x c-s twitch.
(add-hook 'auto-save-hook 'save-buffer-if-visiting-local-file)
;; save every 20 characters typed (this is the minimum)
(setq auto-save-interval 20)
;; save after 5 seconds of idle time (default is 30)
(setq auto-save-timeout 5)
;; I don't use WoMan much, but when I do, I don't want it to pop up a
;; new window (known as a frame in emacs land):
(setq woman-use-own-frame nil)
;; This is sweet! right-click, get a list of functions in the source
;; file you are editing
;; (http://emacs.wordpress.com/2007/01/24/imenu-with-a-workaround/#comment-51)
(global-set-key [mouse-3] `imenu)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Hooks and mode settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'c-mode-common-hook '(lambda ()
(setq c-basic-offset 4)
;; everyone at work seems to format
;; their code this way:
(c-set-style "stroustrup")))
;; I think this is messing up python-mode:
;; (setq electric-indent-mode t)
(setq electric-indent-mode nil)
;; ctags stuff (from:
;; http://kaushalmodi.github.io/2014/03/09/ctags-verilog-and-emacs/
(setq tags-revert-without-query t)
(setq large-file-warning-threshold 30000000)
(setq tags-case-fold-search nil)
;; fix emacs 24 bugs with tags. Came from:
;; https://groups.google.com/forum/#!msg/gnu.emacs.help/Ew0sTxk0C-g/vDRDdSagBAAJ
(defvar etags--table-line-limit 500)
(defun etags-tags-completion-table ()
(let (table
(progress-reporter
(make-progress-reporter
(format "Making tags completion table for %s..." buffer-file-name)
(point-min) (point-max))))
(save-excursion
(goto-char (point-min))
;; This regexp matches an explicit tag name or the place where
;; it would start.
(while (not (eobp))
(if (not (re-search-forward
"[\f\t\n\r()=,; ]?\177\\\(?:\\([^\n\001]+\\)\001\\)?"
;; Avoid lines that are too long (bug#20703).
(+ (point) etags--table-line-limit) t))
(forward-line 1)
(push (prog1 (if (match-beginning 1)
;; There is an explicit tag name.
(buffer-substring (match-beginning 1) (match-end 1))
;; No explicit tag name. Backtrack a little,
;; and look for the implicit one.
(goto-char (match-beginning 0))
(skip-chars-backward "^\f\t\n\r()=,; ")
(prog1
(buffer-substring (point) (match-beginning 0))
(goto-char (match-end 0))))
(progress-reporter-update progress-reporter (point)))
table))))
table))
(defun tags-completion-table ()
"Build `tags-completion-table' on demand.
The tags included in the completion table are those in the current
tags table and its (recursively) included tags tables."
(or tags-completion-table
;; No cached value for this buffer.
(condition-case ()
(let (current-table combined-table)
(message "Making tags completion table for %s..." buffer-file-name)
(save-excursion
;; Iterate over the current list of tags tables.
(while (visit-tags-table-buffer (and combined-table t))
;; Find possible completions in this table.
(setq current-table (funcall tags-completion-table-function))
;; Merge this buffer's completions into the combined table.
(if combined-table
(mapatoms
(lambda (sym) (intern (symbol-name sym) combined-table))
current-table)
(setq combined-table current-table))))
(message "Making tags completion table for %s...done"
buffer-file-name)
;; Cache the result in a buffer-local variable.
(setq tags-completion-table combined-table))
(quit (message "Tags completion table construction aborted.")
(setq tags-completion-table nil)))))
;; end ctags fixes
;; fix the tags keybinding that verilog-mode breaks
(defun my-verilog-hook ()
(setq verilog-indent-level 2
verilog-indent-level-module 2
verilog-indent-level-declaration 2
verilog-indent-level-behavioral 2
verilog-indent-level-directive 2
verilog-case-indent 2
verilog-highlight-p1800-keywords nil
verilog-indent-lists t
verilog-cexp-indent 2
verilog-align-ifelse t
)
;; don't let verilog mode take over pop-tag-mark:
(define-key verilog-mode-map "\M-*" nil)
;; electric-verilog-semi was driving me nuts:
(define-key verilog-mode-map ";" nil)
;; the (setq verilog-auto-indent-on-newline nil) below wasn't
;; stopping the auto indentation, but this does:
(define-key verilog-mode-map "\r" nil)
;; at least with emacs -nw tab was not being bound to smart-tab like
;; I wanted, this fixes it:
(define-key verilog-mode-map "\t" nil)
(setq verilog-auto-lineup 'ignore)
(setq verilog-auto-newline nil)
(setq verilog-auto-indent-on-newline nil)
(setq verilog-simulator "./sim.sh")
(setq verilog-tool `verilog-simulator)
;; this was indenting things incorrectly in verilog-mode, a quick
;; check showed it was fine for other modes.
(setq electric-indent-mode nil)
(verilog-set-compile-command)
;; fix word boundaries for verilog-mode:
(modify-syntax-entry ?_ "@" verilog-mode-syntax-table)
;; clear the incredibly extensive (and annoying to me)
;; verilog-mode-abbrev-table. Downside: any verilog specific
;; abbrevs that I do want need to go somewhere else, like
;; global-abbrev-table
(clear-abbrev-table verilog-mode-abbrev-table)
(defun verilog-list-methods()
(interactive)
(occur "\\( function \\| task \\)" nil)))
(add-hook 'verilog-mode-hook 'my-verilog-hook)
(add-to-list 'auto-mode-alist '("\\.svh?\\'" . verilog-mode))
(add-to-list 'auto-mode-alist '("\\.vh?\\'" . verilog-mode))
(add-to-list 'auto-mode-alist '("\\.f?\\'" . verilog-mode))
;; org-mode stuff
(setq org-log-done t)
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(setq org-return-follows-link t)
;; org-agenda
(if (or (string-match "brzo" system-name))
(setq org-agenda-files (list "~/Sync/clerk.org")))
;; view next 30 days by default, not just a week
(setq org-agenda-span 30)
;; needed for icalendar export?
(setq org-agenda-default-appointment-duration 1)
;; google calendar gets the timezone wrong, but the internet
;; (http://comments.gmane.org/gmane.emacs.orgmode/30210) says this
;; will fix it:
(setq org-icalendar-use-UTC-date-time t)
(setq org-icalendar-timezone "America/Denver")
;; fix some org-mode regressions (at least they are regressiosn in my
;; opinion)
(require 'org-tempo)
(setq org-src-window-setup 'current-window)
(setq org-capture-templates
'(("w" "work templates")
("wt" "Todo" entry (file+headline "~/Documents/notes.org" "Tasks")
"* TODO %?\n%i%a" :prepend t)
("wn" "Notes" entry (file+olp "~/Documents/notes.org" "Notes")
"* Note taken on %U\n%i%?link to origin: %a" :prepend t)
("h" "home templates")
("ht" "Todo" entry (file+headline "~/Documents/notes/everything.org" "Tasks")
"* TODO %?\n%i%a" :prepend t)
("hn" "Notes" entry (file+olp "~/Documents/notes/everything.org" "Notes")
"* Note taken on %U\n%i%?link to origin: %a" :prepend t)
("c" "clerk templates")
("ct" "Todo" entry (file+headline "~/Sync/clerk.org" "Current tasks")
"* TODO %?\n%i%a" :prepend t)
("cn" "Notes" entry (file+headline "~/Sync/clerk.org" "Notes")
"* Note taken on %U\n%i%?link to origin: %a" :prepend t)
))
;; The above template for home will put a note under Notes in
;; everything.org. The following makes it easy to refile notes under
;; a level 2 heading, like I usually do:
(setq org-refile-targets '((nil . (:maxlevel . 2))))
;; this puts refiled notes at the top, in reverse chronological order,
;; like I prefer:
(setq org-reverse-note-order t)
;; wrap long lines in text modes:
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
;; flyspell stuff, the last one is supposed to improve performance
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
(setq flyspell-issue-message-flag nil)
;; With this you can put graphviz dot source code in a
;; #+begin_src...#+end_src block, hit c-c c-c, and it will turn it
;; into an image and display it inline. You can also hit c-c c-v b to
;; process all the code blocks in a document. The images also get
;; generated and exported to your pdf/html/whatever with the rest of
;; your document. Pretty dang awesome. Found this here originally:
;; http://doc.norang.ca/org-mode.html#Publishing
;;
(add-hook 'org-babel-after-execute-hook 'bh/display-inline-images 'append)
;; The above also mentions ditaa that turns ascii art into pretty
;; pictures too.
;; (setq org-ditaa-jar-path "~/src/ditaa/ditaa0_9.jar")
(defun bh/display-inline-images ()
(condition-case nil
(org-display-inline-images)
(error nil)))
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t)))
;; end of graphviz dot magic
;; add support to org-mode for the IEEEtran latex class:
(eval-after-load 'org-latex
'(add-to-list 'org-export-latex-classes
'("IEEEtran"
"\\documentclass{IEEEtran}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
;; turns org blocks into LaTeX environments and HTML divs. See:
;; http://orgmode.org/worg/org-contrib/org-special-blocks.html
(require 'org-special-blocks nil t)
;; highlight long lines, from:
;; http://stackoverflow.com/questions/6344474/how-can-i-make-emacs-highlight-lines-that-go-over-80-chars
(defun highlight-long-lines ()
"highlights lines longer than 80 characters"
(interactive)
(highlight-lines-matching-regexp ".\\{81\\}" (quote hi-green)))
;; actually, this is more useful to me than the above
(defun show-long-lines ()
"goes to the next line longer than 80 characters"
(interactive)
(occur ".\\{81\\}"))
;; mac stuff:
(setq mac-option-key-is-meta nil)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
;; make opt key do Super so I can imitate i3 a little
(setq mac-option-modifier 'super)
(global-set-key (kbd "s-l") 'other-window)
(global-set-key (kbd "s-j") 'other-window)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Some custom key bindings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The EmacsManual says that the combination of C-c followed by a
;; plain letter, and the function keys f5 through f9 are reserved for
;; users. That means that you can expect that no other mode ever uses
;; these -- it does not mean that you are limited to these,
;; however. You can of course rebind any key you want.
;;
;; above from
;; http://www.emacswiki.org/cgi-bin/wiki.pl/KeyBindingDiscussion
;;
(global-set-key "\C-cd" 'insert-date) ;; that's ctrl-c d
(global-set-key [f3] '(lambda ()
(interactive)
(shrink-window-horizontally 10)))
(global-set-key [f4] '(lambda ()
(interactive)
(enlarge-window-horizontally 10)))
(global-set-key "\C-cg" 'goto-line)
(global-set-key "\C-x\C-v" 'view-file)
(global-set-key "\C-ceb" 'ediff-buffers)
(global-set-key "\C-cef" 'ediff)
(global-set-key "\C-csb" 'ispell-buffer)
(global-set-key "\C-csw" 'ispell-word)
(global-set-key "\C-csc" 'ispell-comments-and-strings)
(global-set-key "\C-csr" 'ispell-region)
(global-set-key "\C-co" 'occur)
;; so I don't have to reach across my split keyboard:
(global-set-key "\M-n" 'backward-word)
(global-set-key [C-tab] 'other-window)
(global-set-key [f5] 'eval-buffer)
(global-set-key [f7] 'revert-buffer)
(global-set-key [f8] 'start-or-end-macro)
(global-set-key [f9] 'call-last-kbd-macro)
(global-set-key [f10] 'color-theme-dark-blue2)
(global-set-key [f11] 'next-error)
(global-set-key [f12] 'compile)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Some handy functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun insert-date()
"Insert current date and time at point"
(interactive)
(insert (current-time-string)))
;;;;;; quick move cursor to top or bottom of screen ;;;;;
(defun point-to-top ()
"Put point on top line of window."
(interactive)
(move-to-window-line 0))
(global-set-key [?\C-,] 'point-to-top)
(defun point-to-bottom ()
"Put point at beginning of last visible line."
(interactive)
(move-to-window-line -1))
(global-set-key [?\C-.] 'point-to-bottom)
;; this is used by my auto-save hack:
(defun save-buffer-if-visiting-local-file (&optional args)
"Save the current buffer only if it is visiting a local
file (not scratch buffer, not tramp file)"
(interactive)
(if (and (buffer-file-name) (buffer-modified-p)
(not (tramp-tramp-file-p (buffer-file-name (current-buffer)))))
(save-buffer args)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Got these from Yegge:
;; http://steve.yegge.googlepages.com/my-dot-emacs-file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((not (= (count-windows) 2))
(message "You need exactly 2 windows to do this."))
(t
(let* ((w1 (car (window-list)))
(w2 (car (cdr (window-list))))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1)))))
;;
;; Never understood why Emacs doesn't have this function.
;;
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn (rename-file name new-name 1) (rename-buffer new-name) (set-visited-file-name new-name) (set-buffer-modified-p nil)))))) ;;
;; Never understood why Emacs doesn't have this function, either.
;;
(defun move-buffer-file (dir)
"Moves both current buffer and file it's visiting to DIR."
(interactive "DNew directory: ")
(let* ((name (buffer-name))
(filename (buffer-file-name))
(dir
(if (string-match dir "\\(?:/\\|\\\\)$")
(substring dir 0 -1) dir))
(newname (concat dir "/" name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(progn (copy-file filename newname 1) (delete-file filename) (set-visited-file-name newname) (set-buffer-modified-p nil) t))))
;; end yegge
(defun insert-file-name()
"Inserts the file name at the current point"
(interactive)
(insert (buffer-name)))
;; this entry:
;; http://www.emacsblog.org/2007/02/27/quick-tip-add-occur-to-isearch/,
;; linked to this:
;; http://blog.zenspider.com/archives/2007/02/new_category_emacs.html,
;; which gave me this awesome thing. Hit c-o while doing a c-s search
;; and it does an occur on what your searching for.
(define-key isearch-mode-map (kbd "C-o")
(lambda ()
(interactive)
(let ((case-fold-search isearch-case-fold-search))
(occur (if isearch-regexp isearch-string
(regexp-quote isearch-string))))))
;; Got this from: http://www.emacswiki.org/cgi-bin/wiki/MacroKey
(defun start-or-end-macro (arg)
"Starts or ends the defining of a keyboard macro, depending on
whether you are defining one at the moment or not"
(interactive "P")
(if defining-kbd-macro
(if arg
(end-kbd-macro arg)
(end-kbd-macro))
(start-kbd-macro arg)))
;; kill-matching-buffers-by-filename is handy when you have opened a
;; bunch of files from a certain directory, and now you are done
;; working on that group of files. Got this from:
;; http://keypod.net/wordpress/2008/08/30/emacs-kill-matching-buffers-by/
(defun act-on-buffers (pred action)
(let ((count 0))
(dolist(buffer (buffer-list))
(when (funcall pred buffer)
(setq count (1+ count))
(funcall action buffer)))
count))
(defun kill-matching-buffers-by (acc)
"Kill buffers whose name matches the input"
(let*
((re (read-string (format "kill buffers matching: ")))
(match (function
(lambda (buf)
(string-match re (funcall acc buf)))))
(kill #'(lambda (buf) (kill-buffer buf)))
(count (act-on-buffers match kill)))
(message "%d buffer(s) killed" count)))
(defun kill-matching-buffers-by-filename ()
(interactive)
(kill-matching-buffers-by #'(lambda (b) (or (buffer-file-name b) ""))))
;; imenu and ido, an awesome combo for navigating around a buffer.
;; This came from: http://www.emacswiki.org/emacs/ImenuMode#toc10 as
;; recommended here:
;; http://www.masteringemacs.org/articles/2011/01/14/effective-editing-movement/
(defun ido-goto-symbol (&optional symbol-list)
"Refresh imenu and jump to a place in the buffer using Ido."
(interactive)
(unless (featurep 'imenu)
(require 'imenu nil t))
(cond
((not symbol-list)
(let ((ido-mode ido-mode)
(ido-enable-flex-matching
(if (boundp 'ido-enable-flex-matching)
ido-enable-flex-matching t))
name-and-pos symbol-names position)
(unless ido-mode
(ido-mode 1)
(setq ido-enable-flex-matching t))
(while (progn
(imenu--cleanup)
(setq imenu--index-alist nil)
(ido-goto-symbol (imenu--make-index-alist))
(setq selected-symbol
(ido-completing-read "Symbol? " symbol-names))
(string= (car imenu--rescan-item) selected-symbol)))
(unless (and (boundp 'mark-active) mark-active)
(push-mark nil t nil))
(setq position (cdr (assoc selected-symbol name-and-pos)))
(cond
((overlayp position)
(goto-char (overlay-start position)))
(t
(goto-char position)))))
((listp symbol-list)
(dolist (symbol symbol-list)
(let (name position)
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(ido-goto-symbol symbol))
((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))
((stringp symbol)
(setq name symbol)
(setq position
(get-text-property 1 'org-imenu-marker symbol))))
(unless (or (null position) (null name)
(string= (car imenu--rescan-item) name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
(global-set-key "\M-i" 'ido-goto-symbol) ; or any key you see fit
;; display which function your cursor is in down in the mode line
(which-function-mode 1)
(setq-default header-line-format
'((which-func-mode ("" which-func-format " "))))
(setq mode-line-misc-info
;; We remove Which Function Mode from the mode line, because it's mostly
;; invisible here anyway.
(assq-delete-all 'which-func-mode mode-line-misc-info))
;; better which-func color (font-lock-function-name-face from my
;; tango-2 theme...hmm, is there a better way to get that color?):
(set-face-foreground 'which-func "#729fcf")
;; include directory name in buffers visiting files that have the same
;; name:
(require 'uniquify nil t)
(setq uniquify-buffer-name-style 'post-forward)
;; use tramp, a few tweaks for it:
(setenv "SSH_AUTH_SOCK" (concat (getenv "XDG_RUNTIME_DIR") "/ssh-agent.socket"))
(require 'tramp)
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
;; make bigger (like, 10) for better debugging, but keep low for
;; speed:
(setq tramp-verbose 2)
;; disable vc for tramp files, for speed
(setq vc-ignore-dir-regexp
(format "\\(%s\\)\\|\\(%s\\)"
vc-ignore-dir-regexp
tramp-file-name-regexp))
(setq custom-file "~/.config/emacs/customize-junk.el")
(load custom-file)
(load-user-file "skeletons.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Hopefully everything above this works for the basic emacs
;; distribution. Below is for downloaded stuff:
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load-user-file "external-packages.el")