-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit.el
More file actions
3610 lines (3110 loc) · 130 KB
/
init.el
File metadata and controls
3610 lines (3110 loc) · 130 KB
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; -*-
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
(require 'init-utils)
(defvar personal-directory "~/SynologyDrive/Sylvain/")
(defvar projects-directory "~/SynologyDrive/Sylvain/projects")
;; Add personal site-lisp to load-path
(defvar personal-emacs-directory "~/SynologyDrive/Sylvain/emacs/")
(defvar site-lisp-directory (expand-file-name "site-lisp" personal-emacs-directory ))
;; Add .emacs.d/site-lisp to load path and all sub-directories
(add-to-list 'load-path (concat user-emacs-directory "site-lisp"))
(define-on-macro "knuth")
(define-on-macro "zbook")
(define-on-macro "zouzou")
(modify-all-frames-parameters '((fullscreen . maximized)))
;; Disable dialog box, tool bar...
(setopt use-file-dialog nil)
(setopt use-dialog-box nil)
(menu-bar-mode -1)
(when (display-graphic-p)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(horizontal-scroll-bar-mode -1)
(tooltip-mode -1))
(line-number-mode)
(column-number-mode)
(size-indication-mode)
(setopt inhibit-startup-screen t)
(defun display-startup-echo-area-message ()
(message "Let the hacking begin!"))
(setopt visible-bell nil)
;; Use gtklp
(when (executable-find "gtklp")
(setopt lpr-command "gtklp")
(setq ps-lpr-command "gtklp"))
;; No disabled command like timer-list
(setq disabled-command-function nil)
;; No confirmation because of openwith
(setopt large-file-warning-threshold nil)
(setopt ring-bell-function #'ignore)
;; Don't make backups
(setopt make-backup-files nil)
;; Don't create auto-save files, just save the file
(setopt auto-save-default nil)
(setopt auto-save-visited-interval 60)
(setopt auto-save-visited-predicate (lambda () (not (derived-mode-p 'message-mode))))
(auto-save-visited-mode +1)
;; No lockfiles
(setopt create-lockfiles nil)
(mouse-wheel-mode 1)
(defvar elpaca-installer-version 0.12)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-sources-directory (expand-file-name "sources/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1 :inherit ignore
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca-activate)))
(let* ((repo (expand-file-name "elpaca/" elpaca-sources-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (<= emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let* ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(let ((load-source-file-function nil)) (load "./elpaca-autoloads"))))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
;; Install use-package support
(elpaca elpaca-use-package
;; Enable use-package :ensure support for Elpaca.
(elpaca-use-package-mode))
;; Block until current queue processed.
(elpaca-wait)
(setopt elpaca-verbosity 1)
(use-package emacs
:ensure nil
:custom
(use-package-always-ensure t)
(use-package-verbose nil)
(use-package-hook-name-suffix "")
(use-package-always-defer t))
;; https://github.com/emacscollective/no-littering
(use-package no-littering ; help keeping ~/.emacs.d clean
:demand
:preface
(defun change-base-dir (file)
"Change base directory from `user-emacs-directory' into `personal-emacs-directory'."
(setq file (abbreviate-file-name (expand-file-name file)))
(if (not (string-prefix-p personal-emacs-directory file))
(if (string-prefix-p user-emacs-directory file)
(expand-file-name (substring file (length user-emacs-directory)) personal-emacs-directory)
(user-error "File %s not in `user-emacs-directory'" file))
file))
(defun set-no-littering-base-dir (&rest vars)
(mapc (lambda (var)
(if (not (boundp var))
(user-error "Unbounded variable `%s'" var)
(if (not (featurep 'no-littering))
(user-error "Package `no-littering' not loaded")
(set var (change-base-dir (symbol-value var))))))
vars)))
(load (expand-file-name "personal.el" personal-emacs-directory) :noerror)
;; No confirmation when loading theme
(setopt custom-safe-themes t)
;; Loading zenburn theme
;; http://github.com/bbatsov/zenburn-emacs
(use-package zenburn-theme ; A low contrast color theme for Emacs.
:demand
:if (on-zouzou)
:if (window-system)
:config
(load-theme 'zenburn t))
(use-package server
:ensure nil
:if (window-system)
:demand
:config
(unless (server-running-p)
(server-start)))
;; http://github.com/bbatsov/solarized-emacs
(use-package solarized ; The Solarized color theme, ported to Emacs.
:demand
:if (or (on-zbook) (on-knuth))
:if (window-system)
:ensure solarized-theme
:config
(setopt solarized-use-variable-pitch nil)
(setopt solarized-scale-org-headlines nil)
(load-theme 'solarized-dark t))
(use-package emacs
:disabled
:demand
:if (or (on-zbook) (on-knuth))
:if (window-system)
:ensure nil
:config
(load-theme 'modus-vivendi t))
;; https://github.com/nashamri/spacemacs-theme
(use-package spacemacs-theme ; Color theme with a dark and light versions
:disabled
:init
(load-theme 'spacemacs-dark t))
(require 'init-elisp)
(require 'init-bindings)
(require 'init-editing)
(require 'init-fill)
(require 'init-find-file)
(require 'init-latex)
(require 'init-auctex)
(require 'init-desktop)
(require 'init-dired)
(require 'init-erc)
(require 'init-hippie-expand)
(require 'init-ibuffer)
(require 'init-isearch)
(require 'init-org)
(require 'init-scratch)
(require 'init-wcheck)
(require 'init-yasnippet)
(require 'init-ess)
(require 'init-password)
(use-package abbrev
:ensure nil
:init
;; Silently save abbrevs on quitting emacs
(setopt save-abbrevs 'silently))
;; https://github.com/minad/affe
(use-package affe ; Asynchronous Fuzzy Finder for Emacs
:disabled
:demand :after orderless
:bind ("M-g f" . affe-grep)
:custom (affe-count 100)
:config
;; Configure Orderless
(setq affe-regexp-function #'orderless-pattern-compiler
affe-highlight-function #'orderless--highlight)
;; Manual preview key for `affe-grep'
(consult-customize affe-grep :preview-key (kbd "C-o")))
;; https://github.com/Wilfred/ag.el
(use-package ag ; A front-end for ag ('the silver searcher'), the C ack replacement.
:disabled
:if (and (executable-find "ag")
(not (executable-find "rg")))
:bind ("M-g f" . ag-search-current-directory)
:config
;; http://github.com/mhayashi1120/Emacs-wgrep/raw/master/wgrep-ag.el
(use-package wgrep-ag ; Writable ag buffer and apply the changes to files
:bind (:map wgrep-mode-map
("C-x s" . wgrep-save-all-buffers)))
(setq ag-arguments (list "--smart-case" "--stats" "--hidden" "--all-text"))
(setq ag-group-matches nil)
(defun ag-search-current-directory (string)
(interactive (list (ag/read-from-minibuffer "Ag search string")))
(let ((current-prefix-arg last-prefix-arg))
(ag/search string default-directory))))
;; https://github.com/xenodium/agent-shell
(use-package agent-shell ; Native agentic integrations for Claude Code, Gemini CLI, etc
:config
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.8))
(add-hook 'agent-shell-section-functions
(lambda (section)
(when (and (map-nested-elt section '(:body :start))
(map-nested-elt section '(:body :end)))
(require 'org)
;; Silence org-element warnings (hacky!!)
(let ((major-mode 'org-mode))
(save-excursion
(save-restriction
(narrow-to-region (map-nested-elt section '(:body :start))
(map-nested-elt section '(:body :end)))
(org-format-latex
(concat org-preview-latex-image-directory "markdown-overlays")
(point-min) (point-max)
temporary-file-directory
'overlays nil 'forbuffer org-preview-latex-default-process))))))))
;; https://github.com/jwiegley/alert
(use-package alert ; Growl-style notification system for Emacs
:config
(alert-add-rule :style 'libnotify))
;; https://github.com/domtronn/all-the-icons.el
(use-package all-the-icons ; A library for inserting Developer icons
:ensure (all-the-icons :type git :host github :repo "domtronn/all-the-icons.el" :branch "svg" :files (:defaults "svg")))
;; https://github.com/emacsorphanage/anzu
(use-package anzu ; Display incremental search stats in the modeline.
:disabled
:config
(global-anzu-mode 1)
:diminish anzu-mode)
(use-package app-launcher
:ensure '(app-launcher :host github :repo "SebastienWae/app-launcher")
:after embark
:bind
(:map embark-file-map
("x" . app-launcher-external-open-file))
:preface
(autoload-after app-launcher-external-open-file app-launcher)
:config
(defun app-launcher-external-open-file (file)
(interactive (list (read-file-name (format "Open file : "))))
(let* ((candidates (app-launcher-list-apps))
(selected (completing-read
"Run app: "
(lambda (str pred flag)
(if (eq flag 'metadata)
'(metadata
(annotation-function . (lambda (choice)
(funcall
app-launcher--annotation-function
choice))))
(complete-with-action flag candidates str pred)))
(lambda (x y)
(if nil
t
(cdr (assq 'visible y))))
t nil 'app-launcher nil nil))
(exec (cdr (assq 'exec (gethash selected app-launcher--cache))))
(command (mapconcat
(lambda (chunk)
(cond
((or (equal chunk "%U")
(equal chunk "%F")
(equal chunk "%u")
(equal chunk "%f"))
(if file (shell-quote-argument (expand-file-name file)) ""))
(t chunk)))
(split-string exec)
" ")))
(message "Opening with \"%s\"" command)
(call-process-shell-command command nil 0 nil))))
;; http://nschum.de/src/emacs/auto-dictionary/
(use-package auto-dictionary ; automatic dictionary switcher for flyspell
:bind (("C-c w l" . adict-change-dictionary)
("C-c w g" . adict-guess-dictionary))
:init
(add-hook 'flyspell-mode-hook #'auto-dictionary-mode))
(use-package auto-update-timeline
:load-path (lambda () (list (expand-file-name "timeline-paper" projects-directory)))
:commands notes-update-timeline)
(use-package auto-export-notes
:load-path (lambda () (list (expand-file-name "auto-export-notes" projects-directory))))
;; https://github.com/alpha22jp/atomic-chrome
(use-package atomic-chrome ; Edit Chrome text area with Emacs using Atomic Chrome
:demand
:custom
(atomic-chrome-url-major-mode-alist '(("overleaf\\.com" . LaTeX-mode)
("github\\.com" . gfm-mode)))
(atomic-chrome-extension-type-list '(ghost-text))
:config
(atomic-chrome-start-server))
(use-package auth-source-org
:ensure `(auth-source-org
:repo ,(expand-file-name "auth-source-org" projects-directory)))
;; https://github.com/abo-abo/avy
(use-package avy ; tree-based completion
:custom
(avy-timeout-seconds .5)
(avy-style 'at)
(avy-background t)
:bind* ("M-h" . avy-goto-char-timer))
;; https://github.com/DamienCassou/beginend
(use-package beginend ; Redefine M-< and M-> for some modes
:disabled
:demand
:diminish beginend-global-mode
:config
(dolist (mode beginend-modes) (diminish (cdr mode)))
(beginend-global-mode))
;; https://github.com/minad/cape
(use-package cape ; Completion At Point Extensions
:demand
:init
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file))
;; https://github.com/emacs-citar/citar
(use-package citar ; Citation-related commands for org, latex, markdown
:preface
(autoload-after citar-open-current citar)
(autoload-after citar-open-or-cite citar)
:bind (("C-c b" . citar-open-or-cite)
("C-c n o" . citar-open-current)
:map citar-map
;; Allow to open resources with selected application
("O" . citar-open-external))
:custom
(citar-bibliography (list (expand-file-name "recherche/biblio/refs.bib" personal-directory)))
(citar-library-paths (list (expand-file-name "recherche/biblio" personal-directory)))
;; Org-roam notes
(citar-notes-paths (list (expand-file-name "recherche/notes" personal-directory)))
;; Don't prompt me, always use default cite command with no extra argument
(citar-latex-prompt-for-cite-style nil)
(citar-latex-prompt-for-extra-arguments nil)
:config
(if (not (executable-find "bibtool"))
(display-warning :warning "bibtool not installed"))
(defun citar-cache--update-bibliography-advice (bib &optional props)
"Advice function to run bibtool to sort entries before citar loads it."
(let* ((bib (expand-file-name "recherche/biblio/refs.bib" personal-directory))
(command (format "bibtool -r biblatex -s --sort.format='{%%s(dateadded)}' --sort.reverse=on -i %s -o %s -- print.line.length=1000" bib bib)))
(shell-command command)))
(advice-add #'citar-cache--update-bibliography :before #'citar-cache--update-bibliography-advice)
(defun citar-open-current (&optional arg)
"Open files associated to a BibTeX key taken from the current visited filename."
(interactive "P")
(if-let*
((buf-name (if (eq major-mode 'dired-mode) (dired-get-filename) (buffer-file-name)))
(key (file-name-base buf-name)))
(citar--library-file-action key (if arg #'citar-file-open #'citar-file-open-external))
(user-error "Not a buffer visiting a file")))
(defun citar-open-or-cite ()
(interactive)
(call-interactively
(if (citar--get-major-mode-function 'insert-citation)
'citar-insert-citation 'citar-open)))
(defun orb-citar-edit-note-template (citekey _entry)
"Use `org-roam-bibtex' to open a note file.
This function is used in `citar-open-note-function'."
(require 'org-roam-bibtex)
(if-let ((tmpl (assoc "r" org-roam-capture-templates)))
(let ((org-roam-capture-templates (list tmpl)))
(orb-edit-note citekey))
(error "No template with key `r' found in `org-roam-capture-templates'")))
;; Use org-roam-bibtex to open a note
(setopt citar-note-format-function #'orb-citar-edit-note-template)
(defun citar-open-external (key-or-keys)
(citar--library-file-action key-or-keys #'citar-file-open-external))
(when (require 'all-the-icons nil t)
(setq citar-indicators
(list (citar-indicator-create
:symbol (all-the-icons-icon-for-file "foo.pdf")
:function #'citar-has-files
:tag "has:files")
(citar-indicator-create
:symbol (all-the-icons-icon-for-file "foo.txt")
:function #'citar-has-notes
:tag "has:notes")))))
;; https://github.com/emacs-citar/citar
(use-package citar-embark ; Citar/Embark integration
:demand :after citar embark
:config
(citar-embark-mode))
;; https://github.com/emacs-citar/citar-org-roam
(use-package citar-org-roam ; Citar/org-roam integration
:demand :after citar org-roam org-roam-bibtex
:no-require
:custom
(citar-org-roam-subdir nil)
(citar-org-roam-capture-template-key "r")
:config
(citar-org-roam-mode)
;; Taken from citar wiki
(citar-register-notes-source
'orb-citar-source (list :name "Org-Roam Notes"
:category 'org-roam-node
:items #'citar-org-roam--get-candidates
:hasitems #'citar-org-roam-has-notes
:open #'citar-org-roam-open-note
:create #'orb-citar-edit-note
:annotate #'citar-org-roam--annotate))
;; Not in custom because changed by `citar-org-roam-mode'
(setopt citar-notes-source 'orb-citar-source))
;; https://github.com/proofit404/blacken
(use-package blacken ; Reformat python buffers using the "black" formatter
:disabled t)
(use-package bookmark
:ensure nil
:after no-littering
:custom
(bookmark-fringe-mark nil)
(bookmark-default-file (change-base-dir bookmark-default-file))
(bookmark-watch-bookmark-file 'silent)
(bookmark-save-flag 1)
:preface
;; Support for placeholder in filename of bookmarks
(defun bookmark-get-filename-advice (bookmark-name-or-record)
(if-let ((spec (bookmark-prop-get bookmark-name-or-record 'spec))
(filename (bookmark-prop-get bookmark-name-or-record 'filename)))
(progn (if (symbolp spec)
(setq spec (funcall spec)))
(format-spec filename spec))
(bookmark-prop-get bookmark-name-or-record 'filename)))
(advice-add #'bookmark-get-filename :override #'bookmark-get-filename-advice)
(defun bookmark-spec ()
`((?a . ,(UTC-autumn-from-time (current-time)))
(?p . ,(UTC-spring-from-time (current-time)))
(?s . ,(UTC-semester-from-time (current-time)))))
;; Support for dynamically generated bookmarks
(defun bookmark-not-generated (bmk-record)
(null (bookmark-prop-get bmk-record 'generated)))
(defun bookmark-save-filter (oldfun &optional parg file make-default)
"Don't save generated bookmarks"
(let ((bookmark-alist (seq-filter #'bookmark-not-generated bookmark-alist)))
(funcall oldfun parg file make-default)))
(advice-add 'bookmark-save :around #'bookmark-save-filter)
(defun bookmark-add-generated-bookmarks (file &optional overwrite no-msg default)
"Import bookmarks generated from specific directories."
(let ((directory (expand-file-name "enseignements" personal-directory)))
(bookmark-import-new-list
(mapcar (lambda (dir)
`(,dir
(filename . ,(expand-file-name dir directory))
(position . 0)
(generated . t)))
(directory-files directory nil "^\\(A\\|P\\)[0-9]\\{4\\}"))))
(let ((directory (expand-file-name "Documents" personal-directory)))
(bookmark-import-new-list
(mapcar (lambda (dir)
`(,dir
(filename . ,(expand-file-name dir directory))
(position . 0)
(generated . t)))
(directory-files directory nil "^[0-9]\\{4\\}")))))
(advice-add 'bookmark-load :after #'bookmark-add-generated-bookmarks))
;; https://gitlab.kitware.com/cmake/cmake.git
(use-package cmake-mode) ; major-mode for editing CMake sources
;; http://company-mode.github.io/
(use-package company ; Modular text completion framework
:disabled
:diminish company-mode
:defines
(company-dabbrev-ignore-case company-dabbrev-downcase)
:bind
(:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous)
("<tab>" . company-complete-common-or-cycle)
:map company-search-map
("C-p" . company-select-previous)
("C-n" . company-select-next))
:custom
(company-idle-delay 0)
(company-echo-delay 0)
(company-minimum-prefix-length 1)
:hook
(elpaca-after-init-hook . global-company-mode))
;; https://github.com/tumashu/company-posframe
(use-package company-posframe ; Use a posframe as company candidate menu
:disabled
:custom (company-posframe-show-indicator t)
:hook (company-mode-hook . company-posframe-mode))
(use-package compile
:ensure nil
:custom
;; Move point to first error
(compilation-scroll-output 'first-error))
;; https://github.com/minad/consult
(use-package consult ; Consulting completing-read
:init
;; Use Consult to select xref locations with preview
(setopt xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
:bind (([remap list-buffers] . consult-buffer)
("C-x l" . consult-locate)
("M-g i" . consult-imenu)
("M-g f" . consult-find)
("M-g m" . consult-mark)
("M-g g" . consult-ripgrep)
("M-g l" . consult-goto-line)
("C-c h" . consult-history)
([remap bookmark-jump] . consult-bookmark)
([remap yank-pop] . consult-yank-pop)
([remap keep-lines] . consult-keep-lines))
:custom
(completion-in-region-function #'consult-completion-in-region)
;; Remove filter in dot files
(consult-find-args "find .")
:config
(setopt consult-ripgrep-args (concat consult-ripgrep-args " --hidden" " --no-ignore-vcs"))
(defvar consult-known-projects
`(:narrow (?p . "Projects")
:name "Projects"
:hidden nil
:category project
:face consult-file
:state ,#'consult--file-state
:enabled ,(lambda () consult-project-function)
:items ,#'project-known-project-roots)
"Consult-buffer source for projects.")
(add-to-list 'consult-buffer-sources 'consult-known-projects 'append))
;; https://github.com/karthink/consult-dir
(use-package consult-dir ; Consult based directory picker
:demand :after vertico
:bind
(:map vertico-map
("M-." . consult-dir)
("M-j" . consult-dir-jump-file)))
(use-package consult-mu
:ensure (consult-mu :type git :host github :repo "armindarvish/consult-mu" :files (:defaults "extras/*.el"))
:after (consult mu4e)
:custom
;;maximum number of results shown in minibuffer
(consult-mu-maxnum 200)
;;show preview when pressing any keys
(consult-mu-preview-key 'any)
;;do not mark email as read when previewed
(consult-mu-mark-previewed-as-read nil)
;;do not amrk email as read when selected. This is a good starting point to ensure you would not miss important emails marked as read by mistake especially when trying this package out. Later you can change this to t.
(consult-mu-mark-viewed-as-read nil)
;; open the message in mu4e-view-buffer when selected.
(consult-mu-action #'consult-mu--view-action))
;; https://github.com/jgru/consult-org-roam
(use-package consult-org-roam ; Consult integration for org-roam
:diminish
:demand :after org-roam
:bind
("C-c n g" . consult-org-roam-search)
:custom
(consult-org-roam-grep-func #'consult-ripgrep)
(consult-org-roam-buffer-enabled nil) ;; too slow
:config
(consult-org-roam-mode 1)
;; Eventually suppress previewing for certain functions
(consult-customize
consult-org-roam-forward-links
:preview-key (kbd "M-."))
:bind
;; Define some convenient keybindings as an addition
("C-c n e" . consult-org-roam-file-find)
("C-c n b" . consult-org-roam-backlinks)
("C-c n l" . consult-org-roam-forward-links)
("C-c n r" . consult-org-roam-search))
;; https://codeberg.org/jao/consult-recoll
(use-package consult-recoll ; Recoll queries using consult
:bind ("M-g t" . consult-recoll))
;; https://github.com/minad/corfu
(use-package corfu ; Completion Overlay Region FUnction
:demand
:custom
(corfu-cycle t)
:config
(global-corfu-mode))
;; https://github.com/abo-abo/swiper
(use-package counsel ; Various completion functions using Ivy
:disabled
:demand
:bind (("C-x l" . counsel-locate)
:map counsel-find-file-map
("<right>" . counsel-down-directory)
("<left>" . counsel-up-directory)
:map ivy-minibuffer-map
("M-y" . ivy-next-line))
:custom ((counsel-yank-pop-separator
"\n────────────────────────────────────────────────────────\n"))
:config
;; Remaps some built-in emacs functions
(counsel-mode))
;; https://github.com/radian-software/ctrlf
(use-package ctrlf ; Emacs finally learns how to ctrl+F
:disabled
:demand
:init
(defun ctrlf-yank-word-or-char ()
(interactive)
(let ((input (field-string (point-max))) yank)
(when (or ctrlf--match-bounds (= (length input) 0))
(with-current-buffer (window-buffer (minibuffer-selected-window))
(setq yank (buffer-substring-no-properties
(or (and ctrlf--match-bounds
(cdr ctrlf--match-bounds))
ctrlf--current-starting-point)
(progn (forward-word) (point)))))
(goto-char (field-end (point-max)))
(insert yank))))
:bind (:map ctrlf-minibuffer-mode-map ("C-w" . ctrlf-yank-word-or-char))
:config
(ctrlf-mode +1))
;; https://github.com/astoff/devdocs.el
(use-package devdocs) ; Emacs viewer for DevDocs
;; http://github.com/rejeep/drag-stuff
(use-package drag-stuff ; Drag stuff (lines, words, region, etc...) around
:diminish drag-stuff-mode
:bind (([C-M-S-up] . drag-stuff-up)
([C-M-S-down] . drag-stuff-down)
("C-M-;" . drag-stuff-left)
("C-M-'" . drag-stuff-right))
:config
;; https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-drag-stuff.el
;; http://emacs.stackexchange.com/a/13942/115
(defvar modi/drag-stuff--point-adjusted nil)
(defvar modi/drag-stuff--point-mark-exchanged nil)
(defun modi/drag-stuff--adj-pt-pre-drag ()
"If a region is selected AND the `point' is in the first column, move
back the point by one char so that it ends up on the previous line. If the
point is above the mark, exchange the point and mark temporarily."
(when (region-active-p)
(when (< (point) (mark)) ; selection is done starting from bottom to up
(exchange-point-and-mark)
(setq modi/drag-stuff--point-mark-exchanged t))
(if (zerop (current-column))
(progn
(backward-char 1)
(setq modi/drag-stuff--point-adjusted t))
;; If point did not end up being on the first column after the
;; point/mark exchange, revert that exchange.
(when modi/drag-stuff--point-mark-exchanged
(exchange-point-and-mark) ; restore the original point and mark loc
(setq modi/drag-stuff--point-mark-exchanged nil)))))
(defun modi/drag-stuff--rst-pt-post-drag ()
"Restore the `point' to where it was by forwarding it by one char after
the vertical drag is done."
(when modi/drag-stuff--point-adjusted
(forward-char 1)
(setq modi/drag-stuff--point-adjusted nil))
(when modi/drag-stuff--point-mark-exchanged
(exchange-point-and-mark) ; restore the original point and mark loc
(setq modi/drag-stuff--point-mark-exchanged nil)))
(add-hook 'drag-stuff-before-drag-hook #'modi/drag-stuff--adj-pt-pre-drag)
(add-hook 'drag-stuff-after-drag-hook #'modi/drag-stuff--rst-pt-post-drag))
;; https://github.com/spotify/dockerfile-mode
(use-package dockerfile-mode) ; Major mode for editing Docker's Dockerfiles
;; https://github.com/jacktasia/dumb-jump
(use-package dumb-jump ; jump to definition for multiple languages without configuration.
:after xref
:hook (xref-backend-functions . dumb-jump-xref-activate)
:custom
(dumb-jump-prefer-searcher 'rg))
;; ediff settings
(use-package ediff-diff
:ensure nil
:custom
;; Ignore whitespace in diff
(ediff-diff-options "-w"))
(use-package ediff-util
:ensure nil
:hook (ediff-keymap-setup-hook . add-d-to-ediff-mode-map)
:config
(defun ediff-copy-both-to-C (&optional arg)
"In ediff, copy A and then B to C."
(interactive "P")
(let* ((first (if arg 'B 'A))
(second (if arg 'A 'B))
(merge (concat
(ediff-get-region-contents ediff-current-difference first ediff-control-buffer)
(ediff-get-region-contents ediff-current-difference second ediff-control-buffer))))
(if ediff-3way-job
(ediff-copy-diff ediff-current-difference nil 'C nil merge)
(ediff-copy-diff ediff-current-difference nil 'A nil merge)
(ediff-copy-diff ediff-current-difference nil 'B nil merge))))
(defun add-d-to-ediff-mode-map ()
"Add key 'd' for 'copy both to C' functionality in ediff."
(define-key ediff-mode-map "d" #'ediff-copy-both-to-C)))
(use-package ediff-wind
:ensure nil
:preface
(defalias 'ediff-buffer-with-file 'ediff-current-file)
;; Show all in org files with ediff
(defun ediff-outline-show-all ()
(if (eq major-mode 'org-mode)
(outline-show-all)))
:hook
(ediff-prepare-buffer-hook . ediff-outline-show-all)
;; Restore window configuration after quit
(ediff-before-setup-hook . (lambda () (window-configuration-to-register 'ediff)))
(ediff-quit-hook . (lambda () (jump-to-register 'ediff)))
:custom
;; No separate frame for ediff control buffer
(ediff-window-setup-function 'ediff-setup-windows-plain))
;; https://github.com/joaotavora/eglot
(use-package eglot ; The Emacs Client for LSP servers
:ensure nil
:hook (python-mode-hook . eglot-ensure)
:custom
(eglot-autoshutdown t)
(eglot-events-buffer-size 0)
(eglot-extend-to-xref nil)
(eglot-ignored-server-capabilities
'(:hoverProvider
:documentHighlightProvider
:documentFormattingProvider
:documentRangeFormattingProvider
:documentOnTypeFormattingProvider
:colorProvider
:foldingRangeProvider))
(eglot-sync-connect nil)
(eglot-stay-out-of '(yasnippet)))
(use-package electric
:ensure nil
:demand
:config
(electric-indent-mode 1))
;; https://github.com/davidshepherd7/electric-operator
(use-package electric-operator ; Automatically add spaces around operators
:after ess
:hook ((ess-r-mode-hook inferior-ess-r-mode-hook) . electric-operator-mode)
:custom
(electric-operator-R-named-argument-style 'spaced))
(use-package elec-pair
:if (or (on-zbook) (on-knuth))
:ensure nil
:demand
:config
(electric-pair-mode))
;; https://github.com/skeeto/elfeed
(use-package elfeed ; an Emacs Atom/RSS feed reader
:custom
(elfeed-search-title-max-width 120)
(elfeed-db-directory (change-base-dir elfeed-db-directory))
(elfeed-enclosure-default-dir (change-base-dir elfeed-enclosure-default-dir))
:init
;; Update elfeed periodically
(run-at-time nil (* 4 60 60) #'elfeed-update))
;; https://github.com/remyhonig/elfeed-org
(use-package elfeed-org ; Configure elfeed with one or more org-mode files
:demand :after (:all org elfeed)
:custom
(rmh-elfeed-org-files (list (expand-file-name "elfeed.org" personal-emacs-directory)))
:config
(elfeed-org))
;; https://github.com/sp1ff/elfeed-score
(use-package elfeed-score ; Gnus-style scoring for Elfeed
:demand :after elfeed
:custom
(elfeed-score-serde-score-file (change-base-dir elfeed-score-serde-score-file))
:config
(setopt elfeed-score-serde-score-file (change-base-dir elfeed-score-serde-score-file))
(define-key elfeed-search-mode-map "=" elfeed-score-map)
(elfeed-score-enable))
;; https://github.com/jorgenschaefer/elpy
(use-package elpy ; Emacs Python Development Environment
:demand :after python
:bind (:map python-mode-map ("C-c C-c" . elpy-shell-send-group-and-step-or-region))
:config
(defun elpy-send-region-or-buffer-and-step ()
(interactive "P")
(if (use-region-p)
(elpy-shell--flash-and-message-region (region-beginning) (region-end))
(elpy-shell--flash-and-message-region (point-min) (point-max)))
(elpy-shell--send-region-or-buffer-internal)
(if (use-region-p)
(goto-char (region-end))
(goto-char (point-max))))
(defun elpy-shell-send-group-and-step-or-region (&optional go)
(interactive)
(if (region-active-p)
(elpy-shell-send-region-or-buffer-and-step)
(elpy-shell-send-group-and-step))))
;; https://github.com/syohex/emacs-emamux
(use-package emamux ; Interact with tmux
:preface
(autoload-after emamux:switch-cd emamux)
:bind ("C-z" . emamux:switch-cd)
:config
(defun emamux:display-message (message)
(with-temp-buffer
(emamux:tmux-run-command t "display-message" "-p" message)
(string-trim (buffer-string))))
(defun emamux:switch-cd (&optional arg)
(interactive)
(let* ((current-command (emamux:display-message "#{pane_current_command}"))
(chdir-command
(cond ((string= current-command "R")
(format "setwd(\"%s\")" (file-truename default-directory)))
((string-match "python[23]?" current-command)
(format "import os; os.chdir(\"%s\")" (file-truename default-directory)))
(t (format "cd \"%s\"" (file-truename default-directory))))))
(let ((new-pane-id (emamux:current-active-pane-id)))
(emamux:tmux-run-command nil "send-keys" "-t" new-pane-id "C-u" "C-k" chdir-command "C-m")))))
;; https://github.com/oantolin/embark
(use-package embark ; Conveniently act on minibuffer completions
:after vertico
:bind
(("C-," . embark-act)
("C-;" . embark-dwim)
("C-x C-p" . embark-act)
(:map vertico-map
("C-c C-o" . embark-export)
("C-c C-c" . embark-act))
(:map embark-file-map
("S" . sudo-edit-find-file)))
:custom
(embark-prompter #'embark-completing-read-prompter)
(embark-indicators '(embark-minimal-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator))
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
;; https://github.com/oantolin/embark
(use-package embark-consult ; Consult integration for Embark
:demand :after (embark consult)
:hook
(embark-collect-mode-hook . consult-preview-at-point-mode))
;; https://github.com/hrs/engine-mode
(use-package engine-mode ; Define and query search engines from within Emacs.
:disabled
:bind* ("C-c /" . engine-mode-hydra/body)
:config
(engine-mode t)
(defengine duckduckgo
"https://duckduckgo.com/?q=%s"
:keybinding "d")
(defengine stack-overflow
"https://stackoverflow.com/search?q=%s"
:keybinding "s")
(defengine google
"https://google.com/search?q=%s"
:keybinding "g")
(defengine wikipedia
"http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"
:keybinding "w")
(defengine rfcs
"http://pretty-rfc.herokuapp.com/search?q=%s"
:keybinding "r")