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
|
* My emacs config
** Basic configs
#+BEGIN_SRC emacs-lisp
(setq x-alt-keysym 'meta)
(set-keyboard-coding-system 'utf-8)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(blink-cursor-mode 0)
(set-frame-font "mononoki Nerd Font:pixelsize=16" nil t)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'text-mode-hook 'display-line-numbers-mode)
(setq scroll-step 5)
(setq scroll-margin 3)
(setq echo-keystrokes 0.1)
(setq initial-scratch-message nil)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 20
kept-old-versions 5)
(server-start)
#+END_SRC
** MELPA and non-MELPA
#+BEGIN_SRC emacs-lisp
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/1"))
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(autoload 'mu4e "mu4e" "Launch mu4e and show the main window" t)
(add-to-list 'load-path "/home/jozan/.emacs.d/sunrise-commander/")
(autoload 'sunrise "sunrise.el" "qweqwe" t)
(add-to-list 'load-path "/home/jozan/.emacs.d/font-lock+")
(add-to-list 'load-path "/home/jozan/.emacs.d/all-the-icons/")
(add-to-list 'load-path "/home/jozan/.emacs.d/all-the-icons-dired/")
(add-to-list 'load-path "/home/jozan/.emacs.d/icons-in-terminal.el/")
(add-to-list 'load-path "/home/jozan/.emacs.d/gas-mode/")
(autoload 'gas-mode "gas-mode" "AT&T syntax for assembly code" t)
(add-to-list 'load-path "/home/jozan/.emacs.d/monk-8/")
(autoload 'monk "monk" "Cool CD player" t)
(setq package-enable-at-startup nil)
(setq package-check-signature nil)
(package-initialize)
#+END_SRC
** Some org
#+BEGIN_SRC emacs-lisp
;; set key for agenda
(require 'org)
(global-set-key (kbd "C-c a") 'org-agenda)
;;file to save todo items
(setq org-agenda-files (quote ("~/.emacs.d/org/todo/todo.org")))
;;set priority range from A to C with default A
(setq org-highest-priority ?A)
(setq org-lowest-priority ?C)
(setq org-default-priority ?A)
;;set colours for priorities
(setq org-priority-faces '((?A . (:foreground "#F0DFAF" :weight bold))
(?B . (:foreground "LightSteelBlue"))
(?C . (:foreground "OliveDrab"))))
;;open agenda in current window
(setq org-agenda-window-setup (quote current-window))
;;capture todo items using C-c C-t t
(define-key global-map (kbd "C-c C-t") 'org-capture)
(setq org-capture-templates
'(("t" "todo" entry (file+headline "/home/jozan/.emacs.d/org/todo/todo.org" "Tasks")
"* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")))
;;open agenda in current window
(setq org-agenda-window-setup (quote current-window))
;;warn me of any deadlines in next 7 days
(setq org-deadline-warning-days 7)
;;show me tasks scheduled or due in next fortnight
(setq org-agenda-span (quote fortnight))
;;don't show tasks as scheduled if they are already shown as a deadline
(setq org-agenda-skip-scheduled-if-deadline-is-shown t)
;;don't give awarning colour to tasks with impending deadlines
;;if they are scheduled to be done
(setq org-agenda-skip-deadline-prewarning-if-scheduled (quote pre-scheduled))
;;don't show tasks that are scheduled or have deadlines in the
;;normal todo list
(setq org-agenda-todo-ignore-deadlines (quote all))
(setq org-agenda-todo-ignore-scheduled (quote all))
;;sort tasks in order of when they are due and then by priority
(setq org-agenda-sorting-strategy
(quote
((agenda deadline-up priority-down)
(todo priority-down category-keep)
(tags priority-down category-keep)
(search category-keep))))
(org-babel-do-load-languages
'org-babel-load-languages '((C . t )))
(org-babel-do-load-languages
'org-babel-load-languages '((lisp . t)))
#+END_SRC
** Core packages
*** Evil mode
#+BEGIN_SRC emacs-lisp
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(require 'evil)
(require 'evil-org)
(require 'evil-magit)
(require 'evil-mu4e)
(require 'evil-collection)
(evil-mode t)
(evil-collection-init)
(setq evil-emacs-state-cursor '("#b16286" box))
(setq evil-normal-state-cursor '("#d79921" box))
(setq evil-visual-state-cursor '("#b16286" box))
(setq evil-insert-state-cursor '("#d79921" bar))
(setq evil-replace-state-cursor '("#cc241d" hbar))
(setq evil-operator-state-cursor '("#d79921" hbar))
(evil-define-key 'insert global-map (kbd "C-o") 'delete-other-windows)
(evil-define-key 'insert global-map (kbd "C-k") 'windmove-up)
(evil-define-key 'insert global-map (kbd "C-j") 'windmove-down)
(evil-define-key 'insert global-map (kbd "C-h") 'windmove-left)
(evil-define-key 'insert global-map (kbd "C-l") 'windmove-right)
(evil-define-key 'normal global-map (kbd "C-o") 'delete-other-windows)
(evil-define-key 'normal global-map (kbd "C-k") 'windmove-up)
(evil-define-key 'normal global-map (kbd "C-j") 'windmove-down)
(evil-define-key 'normal global-map (kbd "C-h") 'windmove-left)
(evil-define-key 'normal global-map (kbd "C-l") 'windmove-right)
(global-evil-leader-mode)
(evil-leader/set-leader ",")
(setq evil-leader/in-all-states 1)
(require 'evil-search-highlight-persist)
(global-evil-search-highlight-persist 1)
(evil-leader/set-key "SPC" 'evil-search-highlight-persist-remove-all)
#+END_SRC
*** Centaur tabs
#+BEGIN_SRC emacs-lisp
(require 'centaur-tabs)
(centaur-tabs-mode t)
(centaur-tabs-group-by-projectile-project)
(evil-define-key 'insert global-map (kbd "M-k") 'centaur-tabs-backward)
(evil-define-key 'insert global-map (kbd "M-j") 'centaur-tabs-forward)
(evil-define-key 'normal global-map (kbd "M-k") 'centaur-tabs-backward)
(evil-define-key 'normal global-map (kbd "M-j") 'centaur-tabs-forward)
(global-set-key (kbd "M-k") 'centaur-tabs-backward)
(global-set-key (kbd "M-j") 'centaur-tabs-forward)
(setq centaur-tabs-set-icons t
centaur-tabs-gray-out-icons 'buffer
centaur-tabs-set-close-button nil
centaur-tabs-set-modified-marker t
centaur-tabs-modified-marker "[+]"
centaur-tabs-height 1
centaur-tabs-style "bar"
centaur-tabs-set-bar 'left
centaur-tabs-change-fonts "DejaVu Sans Mono Nerd Font")
(defun centaur-tabs-hide-tab (x)
(let ((name (format "%s" x)))
(or
(string-prefix-p "*epc" name)
(string-prefix-p "*helm" name)
(string-prefix-p "*Helm" name)
(string-prefix-p "*Compile-Log*" name)
(string-prefix-p "*lsp" name)
(string-prefix-p "*elfeed-log*" name)
(string-prefix-p "*scratch*" name)
(string-prefix-p "*Messages*" name)
(string-prefix-p "todo.org" name)
(and (string-prefix-p "magit" name)
(not (file-name-extension name))))))
(add-hook 'dashboard-mode-hook #'centaur-tabs-local-mode)
(add-hook 'neotree-mode-hook #'centaur-tabs-local-mode)
(add-hook 'calendar-mode-hook #'centaur-tabs-local-mode)
(add-hook 'org-agenda-mode-hook #'centaur-tabs-local-mode)
(add-hook 'helpful-mode-hook #'centaur-tabs-local-mode)
(add-hook 'term-mode-hook #'centaur-tabs-local-mode)
#+END_SRC
*** Dashboard
#+BEGIN_SRC emacs-lisp
(require 'dashboard)
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title "Welcome back to Emacs, partner!"
dashboard-startup-banner 'official
dashboard-set-init-info nil
dashboard-set-footer nil
dashboard-center-content t
dashboard-show-shortcuts nil
dashboard-set-heading-icons t
dashboard-set-file-icons nil
dashboard-set-navigator t
show-week-agenda-p t)
(setq dashboard-items '((projects . 10)
(recents . 15)
(agenda . 5)))
(add-to-list 'evil-emacs-state-modes 'dashboard-mode)
#+END_SRC
*** Golden ratio
#+BEGIN_SRC emacs-lisp
;; (require 'golden-ratio)
;; (golden-ratio-mode 1)
;; (setq golden-ratio-adjust-factor .9
;; golden-ratio-wide-adjust-factor .9)
#+END_SRC
*** mu4e
#+BEGIN_SRC emacs-lisp
(require 'org-mime)
(require 'mu4e)
(setq mu4e-maildir (expand-file-name "/home/jozan/Maildir"))
(setq mu4e-get-mail-command "/usr/local/bin/mbsync -c /home/jozan/.emacs.d/mu4e/.mbsyncrc -a")
(setq mu4e-update-interval 300)
(setq mu4e-index-update-in-background t)
(setq mu4e-headers-auto-update t)
(setq mu4e-index-update-error-warning t)
(setq mu4e-compose-signature-auto-include nil)
(setq mu4e-compose-format-flowed t)
(setq mu4e-view-prefer-html t)
(add-to-list 'mu4e-view-actions
'("ViewInBrowser" . mu4e-action-view-in-browser) t)
;; enable inline images
(setq mu4e-view-show-images t)
;; use imagemagick, if available
(when (fboundp 'imagemagick-register-types)
(imagemagick-register-types))
;; every new email composition gets its own frame!
(setq mu4e-compose-in-new-frame t)
;; don't save message to Sent Messages, IMAP takes care of this
(setq mu4e-sent-messages-behavior 'delete)
(add-hook 'mu4e-view-mode-hook #'visual-line-mode)
;; <tab> to navigate to links, <RET> to open them in browser
(add-hook 'mu4e-view-mode-hook
(lambda()
;; try to emulate some of the eww key-bindings
(local-set-key (kbd "<RET>") 'mu4e~view-browse-url-from-binding)
(local-set-key (kbd "<tab>") 'shr-next-link)
(local-set-key (kbd "<backtab>") 'shr-previous-link)))
;; from https://www.reddit.com/r/emacs/comments/bfsck6/mu4e_for_dummies/elgoumx
(add-hook 'mu4e-headers-mode-hook
(defun my/mu4e-change-headers ()
(interactive)
(setq mu4e-headers-fields
`((:human-date . 25) ;; alternatively, use :date
(:flags . 6)
(:from . 22)
(:thread-subject . ,(- (window-body-width) 70)) ;; alternatively, use :subject
(:size . 7)))))
;; spell check
(add-hook 'mu4e-compose-mode-hook
(defun my-do-compose-stuff ()
"My settings for message composition."
(visual-line-mode)
(org-mu4e-compose-org-mode)
(use-hard-newlines -1)
(flyspell-mode)))
(require 'smtpmail)
;;rename files when moving
;;NEEDED FOR MBSYNC
(setq mu4e-change-filenames-when-moving t)
;;set up queue for offline email
;;use mu mkdir ~/Maildir/acc/queue to set up first
(setq smtpmail-queue-mail nil) ;; start in normal mode
;;from the info manual
(setq mu4e-attachment-dir "/home/jozan/Downloads")
(setq message-kill-buffer-on-exit t)
(setq mu4e-compose-dont-reply-to-self t)
(setq mu4e-completing-read-function 'completing-read)
;; (require 'org-mu4e)
;; convert org mode to HTML automatically
;; (setq org-mu4e-convert-to-html t)
;;from vxlabs config
;; show full addresses in view message (instead of just names)
;; toggle per name with M-RET
(setq mu4e-view-show-addresses 't)
;; don't ask when quitting
(setq mu4e-confirm-quit nil)
;; mu4e-context
(setq mu4e-context-policy 'pick-first)
(setq mu4e-compose-context-policy 'always-ask)
(setq mu4e-contexts
(list
(make-mu4e-context
:name "work" ;;for acc1-gmail
:enter-func (lambda () (mu4e-message "Entering context work"))
:leave-func (lambda () (mu4e-message "Leaving context work"))
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches
msg '(:from :to :cc :bcc) "bousset.rudy@gmail.com")))
:vars '((user-mail-address . "bousset.rudy@gmail.com")
(user-full-name . "Rudy Bousset")
(mu4e-sent-folder . "/acc1-gmail/[acc1].Sent Mail")
(mu4e-drafts-folder . "/acc1-gmail/[acc1].drafts")
(mu4e-trash-folder . "/acc1-gmail/[acc1].Trash")
(mu4e-compose-signature . (concat "Formal Signature\n" " "))
(mu4e-compose-format-flowed . t)
(smtpmail-queue-dir . "~/Maildir/acc1-gmail/queue/cur")
;; (message-send-mail-function . smtpmail-send-it)
(smtpmail-smtp-user . "bousset.rudy")
;; (smtpmail-starttls-credentials . (("smtp.gmail.com" 587 nil nil)))
;; (smtpmail-auth-credentials . (expand-file-name "~/.authinfo.gpg"))
(smtpmail-default-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-server . "smtp.gmail.com")
(smtpmail-smtp-service . 587)
(smtpmail-debug-info . t)
(smtpmail-debug-verbose . t)
(mu4e-maildir-shortcuts . ( ("/acc1-gmail/INBOX" . ?i)
("/acc1-gmail/[acc1].Sent Mail" . ?s)
("/acc1-gmail/[acc1].Trash" . ?t)
("/acc1-gmail/[acc1].All Mail" . ?a)
("/acc1-gmail/[acc1].Starred" . ?r)
("/acc1-gmail/[acc1].drafts" . ?d)
))))))
(require 'mu4e-alert)
(mu4e-alert-set-default-style 'libnotify)
(add-hook 'after-init-hook #'mu4e-alert-enable-notifications)
(add-hook 'after-init-hook #'mu4e-alert-enable-mode-line-display)
#+END_SRC
*** w3m
#+BEGIN_SRC emacs-lisp
(require 'w3m-load)
(setq w3m-home-page "https://start.duckduckgo.com/")
(setq w3m-default-display-inline-images t)
#+END_SRC
*** Origami mode
#+BEGIN_SRC emacs-lisp
(require 'origami)
(add-hook 'prog-mode-hook 'origami-mode)
#+END_SRC
*** NeoTree
#+BEGIN_SRC emacs-lisp
(require 'neotree)
(setq neo-vc-integration '(face))
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "SPC") 'neotree-quick-look)
(evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide)
(evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh)
(evil-define-key 'normal neotree-mode-map (kbd "n") 'neotree-next-line)
(evil-define-key 'normal neotree-mode-map (kbd "p") 'neotree-previous-line)
(evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle)
(evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle)
(evil-define-key 'normal neotree-mode-map (kbd "|") 'neotree-enter-vertical-split)
(evil-define-key 'normal neotree-mode-map (kbd "S") 'neotree-enter-vertical-split)
(evil-define-key 'normal neotree-mode-map (kbd "/") 'neotree-enter-horizontal-split)
(evil-define-key 'normal neotree-mode-map (kbd "s") 'neotree-enter-horizontal-split)
#+END_SRC
*** Helm, projectile
#+BEGIN_SRC emacs-lisp
(require 'helm-config)
(require 'helm-misc)
(require 'helm-projectile)
(require 'helm-locate)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(global-set-key (kbd "M-p") #'helm-projectile-switch-project)
(global-set-key (kbd "C-x C-b") #'helm-buffers-list)
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-z") 'helm-select-action)
(setq helm-quick-update t
helm-bookmark-show-location t
helm-buffers-fuzzy-matching t
helm-make-executable "/usr/local/bin/gmake"
helm-make-nproc 5
helm-split-window-in-side-p t)
(defun helm-my-buffers ()
(interactive)
(let ((helm-ff-transformer-show-only-basename nil))
(helm-other-buffer '(helm-c-source-buffers-list
helm-c-source-elscreen
helm-c-source-projectile-files-list
helm-c-source-ctags
helm-c-source-recentf
helm-c-source-locate)
"*helm-my-buffers*")))
(helm-mode 1)
(projectile-mode +1)
#+END_SRC
*** DOOM Modeline
#+BEGIN_SRC emacs-lisp
(setq display-time-string-forms
'((propertize (concat " " 24-hours ":" minutes " "))))
(require 'doom-modeline)
(doom-modeline-mode 1)
(setq doom-modeline-height 30)
(setq doom-modeline-project-detection 'projectile)
(setq doom-modeline-buffer-file-name-style 'truncate-upto-project)
(setq doom-modeline-icon (display-graphic-p))
(setq doom-modeline-major-mode-icon t)
(setq doom-modeline-major-mode-color-icon t)
(setq doom-modeline-buffer-state-icon t)
(setq doom-modeline-buffer-modification-icon t)
(setq doom-modeline-unicode-fallback t)
(setq doom-modeline-enable-word-count nil)
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-indent-info nil)
(setq doom-modeline-checker-simple-format t)
(setq doom-modeline-number-limit 99)
(setq doom-modeline-vcs-max-length 12)
(setq doom-modeline-persp-name t)
(setq doom-modeline-lsp t)
(setq doom-modeline-github nil)
(setq doom-modeline-github-interval (* 30 60))
(setq doom-modeline-modal-icon t)
(setq doom-modeline-mu4e t)
(setq doom-modeline-gnus nil)
(setq doom-modeline-irc t)
(setq doom-modeline-irc-stylize 'identity)
(setq doom-modeline-env-version t)
(setq doom-modeline-env-python-executable "python-shell-interpreter")
(setq doom-modeline-env-ruby-executable "ruby")
(setq doom-modeline-env-perl-executable "perl")
(setq doom-modeline-env-go-executable "go")
(setq doom-modeline-env-elixir-executable "iex")
(setq doom-modeline-env-rust-executable "rustc")
(setq doom-modeline-env-load-string "...")
(setq doom-modeline-before-update-env-hook nil)
(setq doom-modeline-after-update-env-hook nil)
(display-battery-mode)
(column-number-mode)
(display-time)
(doom-themes-neotree-config)
#+END_SRC
*** Colors and rainbows
#+BEGIN_SRC emacs-lisp
(require 'color-identifiers-mode)
(global-color-identifiers-mode)
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
#+END_SRC
*** Auto-complete
#+BEGIN_SRC emacs-lisp
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
#+END_SRC
*** C default style
#+BEGIN_SRC emacs-lisp
(setq c-default-style "bsd")
#+END_SRC
*** Autopair
#+BEGIN_SRC emacs-lisp
(require 'autopair)
(autopair-global-mode)
#+END_SRC
*** Paredit
#+BEGIN_SRC emacs-lisp
(require 'paredit)
(defadvice paredit-mode (around disable-autopairs-around (arg))
ad-do-it
(if (null ad-return-value)
(autopair-mode 1)
(autopair-mode -1)
))
(ad-activate 'paredit-mode)
#+END_SRC
*** Magit
#+BEGIN_SRC emacs-lisp
(require 'magit)
(defun my/magit-kill-buffers ()
"Restore window configuration and kill all Magit buffers.
Attribution: URL `https://manuel-uberti.github.io/emacs/2018/02/17/magit-bury-buffer/'"
(interactive)
(let ((buffers (magit-mode-get-buffers)))
(magit-restore-window-configuration)
(mapc #'kill-buffer buffers)))
(bind-key "q" #'my/magit-kill-buffers magit-status-mode-map)
(evil-define-key 'insert magit-status-mode-map (kbd "q") #'my/magit-kill-buffers)
(evil-define-key 'normal magit-status-mode-map (kbd "q") #'my/magit-kill-buffers)
#+END_SRC
*** Ranger
#+BEGIN_SRC emacs-lisp
(require 'ranger)
(ranger-override-dired-mode t)
(add-hook 'dired-mode-hook 'auto-revert-mode)
#+END_SRC
*** lldb
#+BEGIN_SRC emacs-lisp
(require 'realgud-lldb)
#+END_SRC
*** Lock windows
#+BEGIN_SRC emacs-lisp
(defun my/toggle-window-dedicated ()
"Control whether or not Emacs is allowed to display another
buffer in current window."
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window (not (window-dedicated-p window))))
"%s: locked"
"%s is up for grabs")
(current-buffer)))
(global-set-key (kbd "C-c t") 'my/toggle-window-dedicated)
#+END_SRC
*** evil nerd commenter
#+BEGIN_SRC emacs-lisp
(require 'evil-nerd-commenter)
(evilnc-default-hotkeys)
#+END_SRC
*** cargo
#+BEGIN_SRC emacs-lisp
(require 'cargo)
(add-hook 'rust-mode-hook 'cargo-minor-mode)
#+END_SRC
*** yasnippet
#+BEGIN_SRC emacs-lisp
(require 'yasnippet)
(require 'yasnippet-snippets)
(require 'yasnippet-classic-snippets)
(require 'helm-c-yasnippet)
(yas-reload-all)
(add-hook 'prog-mode-hook #'yas-minor-mode)
#+END_SRC
*** Tabs and stuff
#+BEGIN_SRC emacs-lisp
(defun minibuffer-keyboard-quit ()
"Abort recursive edit.
In Delete Selection mode, if the mark is active, just deactivate it;
then it takes a second \\[keyboard-quit] to abort the minibuffer."
(interactive)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
(abort-recursive-edit)))
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
(global-set-key [escape] 'evil-exit-emacs-state)
(defun my/insert-tab-char ()
(interactive)
(insert "\t"))
(define-key evil-insert-state-map [tab] 'my/insert-tab-char)
(setq my/tab-stop 4)
(setq-default indent-tabs-mode t)
(setq tab-always-indent 'complete)
(setq-default tab-width my/tab-stop)
(setq tab-width my/tab-stop)
(setq-default c-basic-offset my/tab-stop)
(setq-default cperl-indent-level my/tab-stop)
#+END_SRC
*** all the icons
#+BEGIN_SRC emacs-lisp
(require 'font-lock)
(require 'font-lock+)
(require 'all-the-icons)
(load "all-the-icons-dired.el")
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
#+END_SRC
*** minugs
#+BEGIN_SRC emacs-lisp
(require 'mingus)
(add-to-list 'evil-emacs-state-modes 'mingus-help-mode)
(add-to-list 'evil-emacs-state-modes 'mingus-playlist-mode)
(add-to-list 'evil-emacs-state-modes 'mingus-browse-mode)
#+END_SRC
*** elfeed
#+BEGIN_SRC emacs-lisp
(require 'url)
(require 'elfeed)
(require 'elfeed-org)
(elfeed-org)
(setq rmh-elfeed-org-files (list "~/.emacs.d/org/elfeed/elfeed.org"))
(defun my/elfeed-show-all ()
(interactive)
(bookmark-maybe-load-default-file)
(bookmark-jump "elfeed-all"))
(defun my/elfeed-show-news ()
(interactive)
(bookmark-maybe-load-default-file)
(bookmark-jump "elfeed-news"))
(defun my/elfeed-show-youtube ()
(interactive)
(bookmark-maybe-load-default-file)
(bookmark-jump "elfeed-youtube"))
(defun my/elfeed-load-db-and-open ()
(interactive)
(elfeed-db-load)
(elfeed)
(elfeed-search-update--force))
(defun my/elfeed-save-db-and-bury ()
(interactive)
(elfeed-db-save)
(kill-buffer "*elfeed-log*")
(kill-buffer "*elfeed-search*")
(kill-buffer "elfeed.org"))
(defun my/elfeed-v-mpv (url)
"Watch a video from URL in MPV"
(setq quality (completing-read "Max height resolution (0 for unlimited): " '("0" "360" "480" "720" "1080")))
(setq fmt (if (= 0 (string-to-number quality)) "" (format "--ytdl-format=bestvideo[height<=?%s]+bestaudio/best" quality)))
(async-shell-command (format "mpv \"%s\" \"%s\"" fmt url)))
(defun my/elfeed-view-mpv (&optional use-generic-p)
"Youtube-feed link"
(interactive "P")
(let ((entries (elfeed-search-selected)))
(cl-loop for entry in entries
do (elfeed-untag entry 'unread)
when (elfeed-entry-link entry)
do (my/elfeed-v-mpv it))
(mapc #'elfeed-search-update-entry entries)
(unless (use-region-p) (forward-line))))
(defun my/elfeed-d-download (url)
"Download media links"
(async-shell-command (format "cd ~/Downloads && curl -O \"%s\"" url)))
(defun my/elfeed-download-link (&optional use-generic-p)
"Download media links"
(interactive "P")
(let ((entries (elfeed-search-selected)))
(cl-loop for entry in entries
do (elfeed-untag entry 'unread)
when (elfeed-entry-link entry)
do (my/elfeed-d-download it))
(mapc #'elfeed-search-update-entry entries)
(unless (use-region-p) (forward-line))))
(define-key elfeed-search-mode-map (kbd "q") 'my/elfeed-save-db-and-bury)
(define-key elfeed-search-mode-map (kbd "A") 'my/elfeed-show-all)
(define-key elfeed-search-mode-map (kbd "N") 'my/elfeed-show-news)
(define-key elfeed-search-mode-map (kbd "Y") 'my/elfeed-show-youtube)
(define-key elfeed-search-mode-map (kbd "v") 'my/elfeed-view-mpv)
(define-key elfeed-search-mode-map (kbd "d") 'my/elfeed-download-link)
(define-key elfeed-search-mode-map (kbd "h") 'backward-char)
(define-key elfeed-search-mode-map (kbd "j") 'forward-line)
(define-key elfeed-search-mode-map (kbd "k") 'previous-line)
(define-key elfeed-search-mode-map (kbd "l") 'forward-char)
(add-to-list 'evil-emacs-state-modes 'elfeed-search-mode)
(add-to-list 'evil-emacs-state-modes 'elfeed-show-mode)
#+END_SRC
*** which-key
#+BEGIN_SRC emacs-lisp
(require 'which-key)
(which-key-mode)
#+END_SRC
*** shell-pop
#+BEGIN_SRC emacs-lisp
(require 'shell-pop)
(setq my/shell-pop-shell-type
(quote
("ansi-term" "*ansi-term*"
(lambda nil
(ansi-term shell-pop-term-shell)))))
(setq shell-pop-term-shell "/usr/local/bin/zsh")
(add-to-list 'evil-emacs-state-modes 'term-mode)
#+END_SRC
*** org-bullets
#+BEGIN_SRC emacs-lisp
(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
#+END_SRC
*** toc-org
#+BEGIN_SRC emacs-lisp
(require 'toc-org)
(add-hook 'org-mode-hook 'toc-org-mode)
;; enable in markdown, too
(add-hook 'markdown-mode-hook 'toc-org-mode)
(define-key markdown-mode-map (kbd "\C-c\C-o") 'toc-org-markdown-follow-thing-at-point)
#+END_SRC
** Compilation
*** Close window after errorless compilation
#+BEGIN_SRC emacs-lisp
(setq compilation-finish-function
(lambda (buf str)
(if (null (string-match ".*exited abnormally.*" str))
;;no errors, make the compilation window go away in a few seconds
(progn
(run-at-time
"0.5 sec" nil 'delete-windows-on
(get-buffer-create "*compilation*"))
(message "")))))
#+END_SRC
*** Compilation functions
#+BEGIN_SRC emacs-lisp
;; (defvar my/cargo-f5-minor-mode-map
;; (let ((map (make-sparse-keymap)))
;; (define-key map [f5] 'cargo-process-run)
;; map)
;; "my/cargo-f5-minor-mode keymap")
;; (define-minor-mode my/cargo-f5-minor-mode
;; "A minor mode to execute cargo run with F5 in rust-mode only"
;; :init-value t
;; :lighter " my/cargo")
;; (my/cargo-f5-minor-mode 0)
;; (defun my/roff-comp ()
;; ;; (interactive)
;; (defvar name)
;; (defvar ext)
;; (defvar exec)
;; (setq name (file-name-sans-extension buffer-file-name))
;; (setq ext (file-name-extension buffer-file-name))
;; (if (string-match "ms" ext)
;; (setq exec (format "%s%s%s%s%s%s%s" "nroff -ms " name "." ext " -Tpdf -Kutf8 -Wall > " name ".pdf")))
;; (if (string-match "ms" ext)
;; (shell-command exec)))
;; (add-hook 'after-save-hook 'my/roff-comp)
(defun my/exec-f5 ()
(interactive)
(defvar make)
(setq make "gmake -j5 asan")
(save-buffer)
(compile make)
(compilation-finish-function))
(defun my/exec-f6 ()
(interactive)
(defvar exec)
(setq exec "./a.out; ret=$?; echo \"\e[1;35m~>\"; if [ $ret -ne 0 ]; then echo -n \"\e[1;31m$ret\"; if [ $ret -eq 127 ]; then echo \" - Missing a.out, comipler error! \"; exit; elif [ $ret -eq 134 ]; then echo \" - Abort! \"; elif [ $ret -eq 138 ]; then echo \" - Bus error! \"; elif [ $ret -eq 139 ]; then echo \" - Segmentation fault! \"; fi; fi; echo \"\e[1;35m\n\n.emacs v1.5 Tilde Edition by Joe\"")
(async-shell-command exec))
#+END_SRC
** Other key bindings
#+BEGIN_SRC emacs-lisp
(global-set-key [f1] 'shell-pop)
(global-set-key [f2] 'neotree-toggle)
(global-set-key [f4] 'helm-make-projectile)
(global-set-key [f5] 'my/exec-f5)
(global-set-key [f6] 'my/exec-f6)
(global-set-key (kbd "C-x d") 'ranger)
(global-set-key (kbd "M-1") 'shell-command)
(global-set-key (kbd "M-7") 'async-shell-command)
;; (add-hook 'rust-mode-hook 'my/cargo-f5-minor-mode)
(shell-pop--set-shell-type 'my/shell-pop-shell-type my/shell-pop-shell-type)
#+END_SRC
|