-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinit.el
2131 lines (1819 loc) · 61.8 KB
/
init.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
;; -*- lexical-binding: t -*-
;;; Licence
;; Copyright (C) 2017 Samuel Barreto <[email protected]>
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;;
;;; Functions & Macros
(defmacro add-hook! (hook &rest body)
"Nicer add-hooking that prevents writing lambdas explicitely.
Add a lamdba containing BODY to hook HOOK."
(declare (indent 1))
`(add-hook ,hook
(lambda () ,@body)))
;;; Package.el
(defun sam--increase-gc-threshold! ()
(setq gc-cons-threshold most-positive-fixnum))
(defun sam--normal-gc-threshold! ()
(setq gc-cons-threshold 800000))
(add-hook! 'minibuffer-setup-hook
(sam--increase-gc-threshold!))
(add-hook! 'minibuffer-exit-hook
(sam--normal-gc-threshold!))
(sam--increase-gc-threshold!)
(add-hook! 'after-init-hook
;; restore after startup
(sam--normal-gc-threshold!))
(setq package-enable-at-startup nil)
(let ((default-directory "~/.emacs.d/elpa"))
(normal-top-level-add-subdirs-to-load-path))
(package-initialize t)
;; (require 'use-package)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(use-package package
:config
(setq package-check-signature nil)
(setq package-enable-at-startup nil)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("org" . "https://orgmode.org/elpa/")
("gnu" . "https://elpa.gnu.org/packages/")
("elpy" . "https://jorgenschaefer.github.io/packages/"))))
(use-package general :ensure t)
(use-package diminish)
(use-package bind-key)
;;; Sane default
(setenv "LANG" "en_US.UTF-8")
(setenv "LC_ALL" "en_US.UTF-8")
(setq
use-package-verbose nil ; use-package décrit les appels qu'il fait
delete-old-versions -1 ; supprime les vieilles versions des fichiers sauvegardés
version-control t ; enable le version control
vc-make-backup-files t ; backups file even when under vc
vc-follow-symlinks t ; vc suit les liens symboliques
auto-save-file-name-transforms
'((".*" "~/.emacs.d/auto-save-list/" t)) ; transforme les noms des fichiers sauvegardés
inhibit-startup-screen t ; supprime l'écran d'accueil
ring-bell-function 'ignore ; supprime cette putain de cloche.
sentence-end-double-space nil ; sentences does not end with double space.
default-fill-column 72
initial-scratch-message ""
save-interprogram-paste-before-kill t
help-window-select t ; focus help window when opened
tab-width 4 ; tab are 4 spaces large
auto-window-vscroll nil
)
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
(setq-default indent-tabs-mode nil
tab-width 4)
(prefer-coding-system 'utf-8) ; utf-8 est le systeme par défaut.
(defalias 'yes-or-no-p 'y-or-n-p) ; remplace yes no par y n
(show-paren-mode) ; highlight delimiters
(line-number-mode -1) ; display line number in mode line
(column-number-mode -1) ; display colum number in mode line
(save-place-mode) ; save cursor position between sessions
(delete-selection-mode 1) ; replace highlighted text with type
(setq initial-major-mode 'fundamental-mode)
;; supprime les caractères en trop en sauvegardant.
(add-hook! 'before-save-hook
(delete-trailing-whitespace))
;; rend les scripts executable par défault si c'est un script.
(add-hook! 'after-save-hook
(executable-make-buffer-file-executable-if-script-p))
(defvar my-font-for-light "DejaVu Sans Mono 11"
"Font for coding situations.")
;;; apparences
(when window-system
;; (set-frame-size (selected-frame) 85 61)
;; (add-to-list 'default-frame-alist '(height . 46))
;; (add-to-list 'default-frame-alist '(width . 85))
;; (fringe-mode '(4 . 0))
; reduce fringe size to 4 px
(setq-default line-spacing 6) ; increase between-line space.
;; change default font for current frame
(add-to-list 'default-frame-alist `(font . ,my-font-for-light))
(set-face-attribute 'default nil :font my-font-for-light))
(defvar parameters
'(window-parameters . ((no-other-window . t)
(no-delete-other-windows . t))))
(setq fit-window-to-buffer-horizontally t)
(setq window-resize-pixelwise t)
(setq frame-resize-pixelwise t)
(defun sam--set-initial-frame ()
"Set the default dimension and position of a new frame."
(let* ((a-width (* (display-pixel-width) 0.50))
(a-height (* (display-pixel-height) 0.60))
(a-left (truncate (/ (- (display-pixel-width) a-width) 2)))
(a-top (truncate (/ (- (display-pixel-height) a-height) 2))))
(set-frame-position (selected-frame) a-left a-top)
(set-frame-size (selected-frame)
(truncate a-width)
(truncate a-height)
t )))
(sam--set-initial-frame)
(setq
display-buffer-alist
`(("\\*Buffer List\\*" display-buffer-in-side-window
(side . top)
(slot . -1)
(window-height . 20)
(preserve-size . (nil . t)) ,parameters)
("\\*Tags List\\*" display-buffer-in-side-window
(side . right)
(slot . 1)
(window-width . fit-window-to-buffer)
(preserve-size . (t . nil)) ,parameters)
("\\*\\(?:help\\|grep\\|Completions\\)\\*"
display-buffer-in-side-window
(side . bottom)
(slot . -1)
(preserve-size . (nil . t))
,parameters)
("\\*\\(?:shell\\|compilation\\)\\*" display-buffer-in-side-window
(side . bottom)
(slot . 1)
(preserve-size . (nil . t))
,parameters)
("\\*Org Select\\*" display-buffer-in-side-window
(side . top)
(slot . -1)
(window-width . fit-window-to-buffer)
(preserve-size . (t . nil))
,parameters)))
;;; keybindings
(when (eq system-type 'darwin) ; mac specific bindings
(setq mac-right-command-modifier 'meta ; cmd de droite = meta
mac-command-modifier 'control ; cmd de gauche = control
mac-option-modifier 'super ; option de gauche = super
mac-right-option-modifier nil ; option de droite = carac spéciaux
mac-control-modifier 'hyper ; control de gauche = hyper (so does capslock)
ns-function-modifier 'hyper ; fn key = hyper
ns-right-alternate-modifier nil) ; cette touche n'existe pas.
(setq mac-pass-command-to-system nil) ; disable system call to commands like
; C-h (hide frame on macOS by default
(setq mac-pass-control-to-system nil) ; idem
(setq-default locate-command "mdfind")
(setq-default cursor-type 'box)
(setq delete-by-moving-to-trash t)
(defun system-move-file-to-trash (file)
"Use \"trash\" to move FILE to the system trash.
When using Homebrew, install it using \"brew install trash\"."
(call-process (executable-find "trash") nil nil nil file)))
;;; Packages
;;;; A
(use-package abbrev :defer t
:diminish ""
:init
(add-hook! 'text-mode-hook
(abbrev-mode))
;; tell emacs where to read abbrev definitions from...
(setq abbrev-file-name "~/dotfile/emacs/.abbrev_defs")
(setq save-abbrevs 'silently)
(setq only-global-abbrevs t)
(setq-default abbrev-mode t))
(use-package ace-window :ensure t
:commands (ace-window)
:config
(setq aw-keys '(?t ?s ?r ?n ?m ?a ?u ?i ?e))
(setq aw-background t)
(setq aw-ignore-current t))
(use-package ansi-color
:config
(defun display-ansi-colors ()
(interactive)
(let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max))))
(ignore-errors
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer)))
(use-package anzu
:defer 0.2
:ensure t
:diminish ""
:bind*
(("C-0" . anzu-query-replace-at-cursor)
("C-9" . anzu-replace-at-cursor-thing))
:config
(global-anzu-mode t)
(global-set-key [remap query-replace] 'anzu-query-replace)
(global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp))
(use-package auto-fill-mode
:diminish auto-fill-function
:commands turn-on-auto-fill
:init
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(diminish 'auto-fill-function ""))
(use-package autoinsert
:init
(auto-insert-mode)
(setq auto-insert-directory "~/dotfile/emacs/autoinsert"))
;; mainly to make autorevert disappear from the modeline
(use-package autorevert
:defer t
:diminish auto-revert-mode)
(use-package avy :ensure t
:after key-seq
:commands (avy-goto-word-or-subword-1
avy-goto-word-1
avy-goto-char-in-line
avy-goto-line
avy-goto-char)
:config
(key-seq-define-global "qé" #'avy-resume)
(key-seq-define-global "qp" #'avy-goto-word-1)
(key-seq-define-global "qe" #'avy-goto-char-in-line)
(key-seq-define-global "ql" #'avy-goto-line)
(setq avy-keys '(?a ?t ?u ?s ?i ?r ?e ?n ?p ?d ?é ?l))
(setq avy-all-windows nil)
(setq avy-styles-alist
'((avy-goto-char-in-line . post)
(avy-goto-word-or-subword-1 . post)
(avy-goto-word-1 . pre))))
;;;; B
(use-package bash-completion
:ensure t
:hook (shell-dynamic-complete-functions . bash-completion-dynamic-complete)
:config
(autoload 'bash-completion-dynamic-complete
"bash-completion"
"BASH completion hook"))
;; (use-package bioseq-mode
;; :load-path "~/.emacs.d/private/bioseq-mode"
;; :commands (bioseq-mode))
(use-package biblio
:ensure t
:after ivy-bibtex)
(use-package blank-mode
:ensure t
:commands blank-mode)
(use-package blink-cursor
:commands (blink-cursor-mode))
;;;; C
(use-package cc-mode
:ensure t
:mode (("\\.c\\'" . c-mode)
("\\.h\\'" . c-mode)
("\\.cpp\\'" . cpp-mode)
("\\.hpp\\'" . cpp-mode)))
(use-package cquery
:ensure t
:functions (sam|cquery-enable)
:hook (c-mode-hook . sam|cquery-enable)
:config
(defun sam|cquery-enable ()
(interactive)
(ignore-errors (lsp-cquery-enable)))
(setq company-transformers nil company-lsp-async t company-lsp-cache-candidates nil)
(setq cquery-extra-init-params '(:completion (:detailedLabel t)))
(setq cquery-sem-highlight-method 'font-lock)
(setq cquery-executable "/usr/local/bin/cquery"))
(use-package conf-mode
:mode (("DESCRIPTION" . conf-mode)
("\\.log\\'" . conf-mode)
("\\.toml\\'" . conf-toml-mode)))
(use-package command-log-mode
:ensure t
:commands (command-log-mode))
(use-package company
:ensure t
:diminish ""
:bind* (("C-c C-i" . company-mode))
:commands (company-mode)
:init
;; -- [2018-05-29 09:58] tentative de non utilisation de company.
;; (add-hook 'after-init-hook #'global-company-mode)
(defun set-local-company-backends! (backend)
"Add a backend to company locally."
(with-eval-after-load 'company
(setq-local company-backends
(pcase backend
((pred listp) (append backend company-backends))
((pred symbolp) (cons backend company-backends))
(_ company-backends)))))
(setq company-tooltip-align-annotations t)
(setq company-idle-delay 0.2
company-selection-wrap-around t
company-minimum-prefix-length 2
company-require-match nil
company-dabbrev-ignore-case nil
company-dabbrev-downcase nil
company-show-numbers t)
:config
;; (setq company-backends
;; (delete 'company-semantic company-backends))
(bind-keys :map company-active-map
("C-d" . company-show-doc-buffer)
("C-l" . company-show-location)
("C-n" . company-select-next)
("C-p" . company-select-previous)
("C-t" . company-select-next)
("C-s" . company-select-previous)
("TAB" . company-complete))
;; from https://github.com/syl20bnr/spacemacs/blob/master/layers/auto-completion/packages.el
(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
try-complete-lisp-symbol-partially
try-complete-lisp-symbol)))
(use-package company-bibtex
:ensure t
:after company
:config
(setq company-bibtex-bibliography '("~/Dropbox/bibliography/references.bib"))
(add-hook! 'latex-mode-hook
(set-local-company-backends! 'company-bibtex)))
(use-package company-childframe
:disabled t
:load-path "~/.emacs.d/private/company-childframe"
:after posframe
:config
(company-childframe-mode t)
(require 'desktop)
(push '(company-childframe-mode . nil) desktop-minor-mode-table))
(use-package company-statistics
:ensure t
:after company
:config
(company-statistics-mode))
(use-package counsel :ensure
:commands (counsel-load-theme
counsel-bookmark)
:bind* (("C-c i" . counsel-imenu)
("C-x C-f" . counsel-find-file)
("C-x C-b" . ivy-switch-buffer)
("C-c C-/" . counsel-rg)
("s-<backspace>" . ivy-switch-buffer)
("M-x" . counsel-M-x))
:config
(setq counsel-find-file-ignore-regexp
(concat "\\(?:\\`[#.]\\)\\|\\(?:[#~]\\'\\)"
"\\|\\.x\\'\\|\\.d\\'\\|\\.o\\'"
"\\|\\.aux\\'"))
(setq counsel-locate-cmd 'counsel-locate-cmd-mdfind)
(setq counsel-find-file-at-point t))
(use-package counsel-gtags
:ensure t
:hook (ggtags-mode . counsel-gtags-mode)
:bind (:map c-mode-map
("C-c g g" . counsel-gtags-dwim)
("C-c g s" . counsel-gtags-find-symbol)
("C-c g d" . counsel-gtags-find-definition)
("C-c g r" . counsel-gtags-find-reference)
("C-c g f" . counsel-gtags-find-file)
("C-c g c" . counsel-gtags-create-tags)
("C-c g u" . counsel-gtags-update-tags)))
(use-package css-mode :ensure t
:mode (("\\.css\\'" . css-mode)))
;;;; D
(use-package deadgrep
:load-path "~/.emacs.d/private/deadgrep"
:bind* (("C-c /" . deadgrep)))
(use-package define-word
:ensure t
:commands (define-word
define-word-at-point))
(use-package dired
:bind* (("C-x d" . dired-other-window)
("C-x C-d" . dired-side))
:commands (dired
dired-side)
:functions (dired-side)
:config
(defun dired-side ()
"Display `default-directory' in side window on left, hiding details."
(interactive)
(let ((buffer (dired-noselect default-directory)))
(with-current-buffer buffer (dired-hide-details-mode t))
(display-buffer-in-side-window
buffer `((side . left)
(slot . 0)
(window-width . fit-window-to-buffer)
(preserve-size . (t . nil)) ,parameters))))
(use-package dired-x
:bind* (("C-x C-'" . dired-jump))
:commands (dired-omit-mode)
:init
(add-hook! 'dired-load-hook
(load "dired-x"))
(add-hook! 'dired-mode-hook
(dired-omit-mode))
:config
(setq dired-omit-verbose nil)
(setq dired-omit-extensions
(cl-list* ".aux" ".fls" ".log" ".out" ".toc" ".fdb_latexmk" ".bbl" ".blg" ".bcf" ".run.xml" ".x" ".d" dired-omit-extensions))
(setq dired-omit-files (concat dired-omit-files
"\\|^\\..*$\\|^.DS_Store$\\|^.projectile$\\|^.git$")))
(let ((gls "/usr/local/bin/gls"))
(if (file-exists-p gls)
(setq insert-directory-program gls)))
(setq ls-lisp-use-insert-directory-program t)
(setq dired-listing-switches "-alh")
(setq dired-dwim-target t) ; guess copy target based on other dired window
(defun dired-view-other-window ()
"View the current file in another window (possibly newly created)."
(interactive)
(if (not (window-parent))
(split-window))
(let ((file (dired-get-file-for-visit))
(dbuffer (current-buffer)))
(other-window 1)
(unless (equal dbuffer (current-buffer))
(if (or view-mode (equal major-mode 'dired-mode))
(kill-buffer)))
(let ((filebuffer (get-file-buffer file)))
(if filebuffer
(switch-to-buffer filebuffer)
(view-file file))
(other-window -1))))
(defun dired-mkdir-date (dir-name)
"Make a directory with current date style"
(interactive "sDirectory content: ")
(mkdir (format "%s-%s" (format-time-string "%Y-%m-%d" (current-time)) dir-name))
(revert-buffer))
(defun dired-mkdir-date-rstyle (dir-name)
(interactive "sDirectory content: ")
(mkdir (format "%s.%s" dir-name (format-time-string "%Y%m%d" (current-time))))
(revert-buffer))
(bind-keys :map dired-mode-map
("SPC" . dired-view-other-window)
("." . hydra-dired-main/body)
("t" . dired-next-line)
("s" . dired-previous-line)
("r" . dired-find-file)
("c" . dired-up-directory)
("'" . eshell-here)
("8" . dired-mkdir-date)
("9" . dired-mkdir-date-rstyle)
("O" . sam|open-in-external-app)
("C-'" . shell)
("q" . (lambda () (interactive) (quit-window 4)))))
(use-package doom-modeline
:load-path "~/.emacs.d/private/doom-modeline/"
:init
(use-package shrink-path
:ensure t)
(use-package eldoc-eval
:ensure t
:commands (eldoc-in-minibuffer-mode))
:config
(doom-modeline-init)
(setq doom-modeline-height 20))
(use-package doom-themes
:ensure t
:config
(load-theme 'doom-one t)
(doom-themes-org-config))
;;;; E
(use-package ediff
:commands (ediff ediff3)
:config
(setq ediff-split-window-function #'split-window-horizontally
ediff-window-setup-function #'ediff-setup-windows-plain))
(use-package eldoc
:ensure t
:commands (turn-on-eldoc-mode)
:diminish ""
:init
(add-hook! 'emacs-lisp-mode-hook
(turn-on-eldoc-mode))
(add-hook! 'lisp-interaction-mode-hook
(turn-on-eldoc-mode)))
(use-package elfeed
:ensure t
:bind* (("<f6>" . elfeed)
("C-c E" . elfeed))
:config
;; increase title width to accomodate papers
(setq elfeed-search-title-max-width 120)
(setq elfeed-db-directory "~/dotfile/emacs/elfeed/")
(use-package elfeed-org
:ensure t
:init
(setq rmh-elfeed-org-files (list "~/dotfile/emacs/elfeed.org"))
:functions (elfeed-org-minor-mode)
:config
(elfeed-org)
(define-minor-mode elfeed-org-minor-mode
"Minor mode to interact with elfeed from the elfeed org mode
buffer."
:lighter " eorg"
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") #'elfeed-org-filter-entry)
map))
(defun elfeed-org-get-tags-not-properties (s)
(if (get-text-property 0 'inherited s)
(substring-no-properties s)
s))
(defun elfeed-org-filter-entry ()
(interactive)
(let* ((buf (elfeed-search-buffer))
(p (point))
(tag-at-point (org-get-tags-at p))
(tags (mapcar #'elfeed-org-get-tags-not-properties tag-at-point))
(clean-tags (delete rmh-elfeed-org-tree-id tags))
(tag-filter (mapconcat (lambda (x) (concat " +" x)) clean-tags ""))
(new-filter (concat (default-value 'elfeed-search-filter)
tag-filter)))
(elfeed-search-set-filter new-filter)
(unless (get-buffer-window buf 'visible)
(switch-to-buffer-other-window buf)
(switch-to-prev-buffer)))))
(defun elfeed-mark-all-as-read ()
(interactive)
(mark-whole-buffer)
(elfeed-search-untag-all-unread))
(bind-keys :map elfeed-search-mode-map
("N" . elfeed-next-tag)
("f" . hydra-elfeed-navigate/body)
("U" . elfeed-search-fetch)
("." . hydra-elfeed/body)
("R" . elfeed-mark-all-as-read))
(defvar counsel-elfeed-tags
'(("papers" . "+papers")
("biology" . "+bio")
("bioinfo" . "+bioinfo")
("computer science" . "+compsci")
("package update" . "+pkg")
("rstat" . "+rstat")
("emacs" . "+emacs")
("news" . "+news")
("communisme libertaire" . "+anar")
("communisme marxiste" . "+communisme"))
"This is a list of tag for elfeed filtering.")
(defun elfeed-update-filter (x)
(setf elfeed-search-filter
(concat "@6-months-ago +unread " x))
(elfeed-search-update :force))
(defun elfeed-next-tag ()
(interactive)
(let* ((elfeed-tag-list
(with-current-buffer
(find-file-noselect (expand-file-name (car rmh-elfeed-org-files)))
(org-mode)
(mapcar
(lambda (x) (concat "+" x))
(cdr (reverse (mapcar #'car (org-get-buffer-tags)))))))
(current-tag
(car (last (split-string elfeed-search-filter))))
(new-tag
(cadr (member current-tag elfeed-tag-list))))
(if new-tag
(elfeed-update-filter new-tag)
(elfeed-update-filter (car elfeed-tag-list)))))
(defun counsel-elfeed--update-tag (x)
"Update the elfeed filter with the last 10 char of ivy selection."
(elfeed-search-set-filter
(concat "@6-months-ago +unread " x)))
(defun counsel-elfeed-tag ()
"Shows a list of elfeed tags I like to browse."
(interactive)
(ivy-read "%d Elfeed tag: "
(with-current-buffer
(find-file-noselect (expand-file-name (car rmh-elfeed-org-files)))
(org-mode)
(mapcar
(lambda (x) (concat "+" x))
(cdr (reverse (mapcar #'car (org-get-buffer-tags))))))
:require-match t
:action #'counsel-elfeed--update-tag
:update-fn (lambda ()
(counsel-elfeed--update-tag (ivy-state-current ivy-last)))
:caller 'counsel-elfeed-tag
:sort t))
(setq-default elfeed-search-filter "@6-months-ago +unread"))
(use-package emacs-lisp-mode
:mode
(("*scratch*" . emacs-lisp-mode))
:init
(add-hook! 'emacs-lisp-mode-hook
(setq-local lisp-indent-function #'Fuco1/lisp-indent-function)
(set-local-company-backends! 'company-elisp))
(general-define-key
:keymaps 'emacs-lisp-mode-map
:prefix "ê"
"u" 'use-package-jump))
(use-package esup
:ensure t
:commands esup)
(use-package etymologie
:load-path "~/.emacs.d/private/etymologie"
:commands (etymologie))
(use-package exec-path-from-shell
:ensure t
:if (memq window-system '(mac ns))
:defer 1
:commands (exec-path-from-shell-initialize
exec-path-from-shell-copy-env)
:init
(setq exec-path-from-shell-check-startup-files nil)
:config
(exec-path-from-shell-initialize))
(use-package expand-region
:ensure t
:defines hydra-expand-region/body
:commands (er/expand-region
er/mark-word
er/mark-symbol
er/mark-symbol-with-prefix
er/mark-next-accessor
er/mark-method-call
er/mark-inside-quotes
er/mark-outside-quotes
er/mark-inside-pairs
er/mark-outside-pairs
er/mark-comment
er/mark-sentence
er/mark-paragraph
er/mark-url
er/mark-email
er/mark-defun)
:bind (("C-=" . er/expand-region)
("s-=" . hydra-expand-region/er/expand-region)
("C-°" . er/contract-region)
("s-°" . hydra-expand-region/er/contract-region))
:config
(setq expand-region-fast-keys-enabled nil)
(defhydra hydra-expand-region (:color red :hint nil)
"
^Expand region^ ^Cursors^
_c_: expand _n_: next
_r_: contract _p_: prev
_e_: exchange
_R_: reset
"
("c" er/expand-region)
("r" er/contract-region)
("e" exchange-point-and-mark)
("R" (lambda () (interactive)
(let ((current-prefix-arg '(0)))
(call-interactively #'er/contract-region))) :color blue)
("n" hydra-mc/mc/mark-next-like-this :color blue)
("p" hydra-mc/mc/mark-previous-like-this :color blue)
("q" nil "quit" :color blue)))
;;;; F
(use-package fastx
:load-path "~/.emacs.d/private/fastx"
:mode (("\\.fasta$" . fastx-mode)
("\\.fa$" . fastx-mode)
("\\.fst$" . fastx-mode)
("\\.fastq$" . fastq-mode)
("\\.fq$" . fastq-mode))
:bind (:map fastx-mode-map
("c" . fastx-hide-sequence)
("t" . fastx-next-sequence)
("s" . fastx-prev-sequence)
("r" . fastx-show-sequence)))
(use-package flx :ensure t)
(use-package flycheck
:disabled t
:ensure t
:commands (flycheck-mode)
:diminish (flycheck-mode . "ⓕ")
:config
(setq flycheck-highlighting-mode 'symbols))
(use-package flymake
:commands (flymake-mode
hydra-errors/body)
:functions (hydra-errors/body)
:config
(defhydra hydra-errors (:body-pre (flymake-mode)
:post (flymake-mode -1)
:hint nil)
"
Linting : [_n_]ext / [_p_]rev
Errors : [_t_]: next / [_s_]: prev
Totos : _C-n_: next / _C-p_: prev / _C-s_: search"
("n" flymake-goto-next-error)
("p" flymake-goto-prev-error)
("t" next-error)
("s" previous-error)
("C-n" hl-todo-next)
("C-p" hl-todo-previous)
("C-s" hl-todo-occur)))
(use-package flyspell
:bind* (("C-c M-f" . flyspell-mode)))
;;;; G
(use-package geiser
:mode (("\\.scm\\'" . scheme-mode))
:hook (scheme-mode . geiser-mode)
:commands (geiser-mode
connect-to-guile
geiser-connect
geiser)
:init
(setq geiser-active-implementations '(guile chez))
(setq geiser-guile-load-path '("/usr/local/Cellar/guile/2.2.2/share/guile/"))
(setq geiser-guile-load-init-file-p t)
(setq geiser-guile-manual-lookup-nodes '("Guile" "guile-2.2"))
(setq geiser-guile-binary "/usr/local/bin/guile")
:config
(require 'geiser-install))
;; gengetopt mode
(use-package ggo-mode
:ensure t
:mode ("\\.ggo\\'" . ggo-mode))
(use-package ggtags :ensure t
:commands (ggtags-mode)
:bind (:map ggtags-mode-map
("M-?" . ggtags-find-reference)))
(use-package goto-addr
:hook ((compilation-mode . goto-address-mode)
(prog-mode . goto-address-prog-mode)
(eshell-mode . goto-address-mode)
(shell-mode . goto-address-mode))
:bind (:map goto-address-highlight-keymap
("<RET>" . goto-address-at-point)
("M-<RET>" . newline))
:commands (goto-address-prog-mode
goto-address-mode))
(use-package goto-chg :ensure t
:commands (goto-last-change
goto-last-change-reverse))
(use-package gpl ; package to add gpl to file
:load-path "~/dotfile/emacs/emacs.d/private/gpl"
:commands (gpl-python gpl-cc-copyright-line gpl-pythonL
gpl-library-notice gpl-cL gpl-cc gpl-shL gpl-el
gpl-shS gpl-texinfo gpl-m4 gpl-insert-notice gpl-sh
gpl-ccL gpl-python-copyright-line gpl-test
gpl-c-copyright-line gpl-c))
(use-package grab-mac-link
:ensure t
:commands grab-mac-link)
;;;; H
(use-package helm-make
:bind* (("C-c C" . helm-make)
("C-c p c" . helm-make-projectile))
:config
(setq helm-make-completion-method 'ivy))
(use-package helpful
:ensure t
:init
(use-package shut-up :ensure t :defer t)
:bind (("C-h f" . helpful-callable)
("C-h v" . helpful-variable)
("C-h k" . helpful-key)
:map emacs-lisp-mode-map
("C-c C-d" . helpful-at-point)))
(use-package highlight-indent-guides
:ensure t
:commands (highlight-indent-guides-mode)
:config
(setq highlight-indent-guides-method 'character))
(use-package highlight-indentation
:ensure t
:defer t)
(use-package hideshow
:diminish (hs-minor-mode . "")
:hook ((prog-mode . hs-minor-mode)
(latex-mode . hs-minor-mode))
:bind* (("s-h" . hs-toggle-hiding)))
(use-package hl-todo
:ensure t
:hook (prog-mode . hl-todo-mode)
:commands (hl-todo-previous
hl-todo-next
hl-todo-occur))
(use-package htmlize
:ensure t
:defer t)
(use-package hungry-delete
:ensure t
:diminish ""
:defer 2
:config
(global-hungry-delete-mode))
(use-package hydra :ensure t
:config
(setq hydra-is-helpful t))
(use-package hy-mode
:ensure t
:mode ("\\.hy\\'" . hy-mode))
;;;; I
(use-package ibuffer
:ensure t
:bind* (("C-x b" . ibuffer))
:commands ibuffer
:init
(add-hook! 'ibuffer-hook
(ibuffer-switch-to-saved-filter-groups "Default"))
:config
(use-package ibuffer-vc :ensure t
:config
(setq ibuffer-vc-set-filter-groups-by-vc-root t))
(define-key ibuffer-mode-map "." 'hydra-ibuffer-main/body)
(general-define-key
:keymaps 'ibuffer-mode-map
"." 'hydra-ibuffer-main/body
"t" 'next-line
"s" 'previous-line
"r" 'ibuffer-visit-buffer
"c" 'ibuffer-backward-filter-group
"p" 'ibuffer-backward-filter-group
"n" 'ibuffer-forward-filter-group)
;; Use human readable Size column instead of original one
(define-ibuffer-column size-h
(:name "Size" :inline t)
(cond
((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
(t (format "%8d" (buffer-size)))))
;; Modify the default ibuffer-formats
(setq ibuffer-formats
'((mark modified read-only " "
(name 18 18 :left :elide)
" "
(size-h 9 -1 :right)