-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.el
executable file
·3873 lines (3567 loc) · 129 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
;;; package --- emacs initialization script; -*- mode: emacs-lisp; coding: utf-8-unix -*-
;;; Commentary:
;; Load all configuration parts
;; TODO:
;; Check this init
;; https://github.com/alexmurray/dot_emacs.d/blob/master/init.el
;;; Code:
;; don't let Customize mess with my .emacs
(defun kb/emacs-subdirectory (dir)
"Return DIR as subdirectory of HOME."
(expand-file-name dir user-emacs-directory))
(setq custom-file (locate-user-emacs-file "custom.el"))
;; load custom but ignore error if doesn't exist
(load custom-file 'noerror 'nomessage)
;;
(setq user-full-name "Karol Barski")
(defconst kb/environment-script (locate-user-emacs-file "rc/environment.el"))
(load kb/environment-script 'noerror 'nomessage)
(add-to-list 'load-path (kb/emacs-subdirectory "rc"))
(add-to-list 'load-path (kb/emacs-subdirectory "site-lisp/org-addons"))
(when (file-exists-p (expand-file-name "rc-functions.el" (kb/emacs-subdirectory "rc")))
(load "~/.emacs.d/rc/rc-functions.el"))
(setq read-process-output-max (* 3 1024 1024))
(setq tab-width 4) ; default to 4 visible spaces to display a tab
(setq indicate-empty-lines t)
;; blink screen on bell
(setq visible-bell t)
;;(setq debug-on-error nil)
;; dim the ignored part of the file name
;;(file-name-shadow-mode 1)
;; minibuffer window expands vertically as necessary to hold the text that
;; you put in the minibuffer
(setq resize-mini-windows t)
;; do not consider case significant in completion (GNU Emacs default)
;; (setq completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
(setq read-buffer-completion-ignore-case t)
(setq mouse-highlight 10)
(setq make-pointer-invisible t)
;;--------------------------------------------------------------------------------
;; My customized emacs
;;--------------------------------------------------------------------------------
;; fancy streching cursor
(setq x-stretch-cursor nil)
;; (global-hl-line-mode -1)
;; use inactive face for mode-line in non-selected windows
(setq mode-line-in-non-selected-windows t)
;; Set the frame's title. %b is the name of the buffer. %+ indicates
;; the state of the buffer: * if modified, % if read only, or -
;; otherwise. Two of them to emulate the mode line. %f for the file
;; name. Incredibly useful!
(setq frame-title-format '((:eval (if (buffer-file-name)
(concat (abbreviate-file-name (buffer-file-name)) " %+%+ ")
"%b %+%+ %f"))))
(setq scroll-margin 10
scroll-conservatively 100000
scroll-preserve-screen-position 'always)
;;--------------------------------------------------------------------------------
;; Elpa setup
;;--------------------------------------------------------------------------------
(require 'cl-lib)
(defvar kb/package-archives ()
"Set of achives which will be finally set to package-achives.")
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'kb/package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
(add-to-list 'kb/package-archives (cons "org" (concat proto "://orgmode.org/elpa/")) t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'kb/package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")) t)
)
)
(customize-set-variable
'package-archives '(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(defvar straight-bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomesage))
;; <leaf-install-code>
(straight-use-package 'leaf)
(straight-use-package 'leaf-keywords)
;; </leaf-install-code>
(require 'leaf)
(leaf leaf-keywords
:doc "Additional leaf.el keywords for external packages."
:req "emacs-24.4" "leaf-3.5.0"
:tag "settings" "lisp" "emacs>=24.4"
:url "https://github.com/conao3/leaf-keywords.el"
:added "2025-01-16"
:emacs>= 24.4
:after leaf
;; :init
;; ;; optional packages if you want to use :hydra, :el-get, :blackout,,,
:require t
:config
;; initialize leaf-keywords.el
(leaf-keywords-init))
(leaf hydra
:doc "Make bindings that stick around."
:req "cl-lib-0.5" "lv-0"
:tag "bindings"
:url "https://github.com/abo-abo/hydra"
:added "2025-01-16"
:straight t
:after lv)
(leaf blackout
:doc "Better mode lighter overriding."
:req "emacs-26"
:tag "extensions" "emacs>=26"
:url "https://github.com/radian-software/blackout"
:added "2025-01-16"
:emacs>= 26
:straight t)
(leaf leaf-defaults
:doc "Awesome leaf config collections"
:req "emacs-26.1" "leaf-4.1" "leaf-keywords-1.1"
:tag "convenience" "emacs>=26.1"
:url "https://github.com/conao3/leaf-defaults.el"
:added "2022-12-28"
:emacs>= 26.1
:disabled t
:require t
:config (leaf-defaults-init))
;; (leaf async-await :el-get chuntaro/emacs-async-await)
;; (leaf promise :el-get chuntaro/emacs-promise)
;; (leaf iter2 :el-get doublep/iter2)
;; (leaf async :el-get jwiegley/emacs-async)
;; load no-littering as soon as possible during init so it can hook as many
;; paths as possible
(leaf no-littering
:straight t
:emacs>= 25.1
:require recentf no-littering
:defvar (no-littering-var-directory no-littering-etc-directory)
:config
(with-eval-after-load 'recentf
(add-to-list 'recentf-exclude no-littering-var-directory)
(add-to-list 'recentf-exclude no-littering-etc-directory)))
(leaf leaf-tree :straight t)
(leaf leaf-convert :straight t)
(leaf transient
:doc "Transient commands"
:req "emacs-25.1" "compat-29.1.3.4"
:tag "extensions" "emacs>=25.1"
:url "https://github.com/magit/transient"
:added "2023-02-19"
:emacs>= 25.1
:straight t
:after compat
:config
(leaf transient-dwim
:doc "Useful preset transient commands"
:req "emacs-26.1" "transient-0.1"
:tag "tools" "emacs>=26.1"
:url "https://github.com/conao3/transient-dwim.el"
:added "2025-01-21"
:emacs>= 26.1
:straight t
:bind (("M-=" . transient-dwim-dispatch))))
(leaf system-packages
:doc "functions to manage system packages"
:req "emacs-24.3"
:tag "emacs>=24.3"
:url "https://gitlab.com/jabranham/system-packages"
:added "2025-01-16"
:emacs>= 24.3
:straight t
:custom ((system-packages-package-manager . 'apt)
(system-packages-noconfirm . t)
(system-packages-use-sudo . t)))
(leaf cus-start
:doc "define customization properties of builtins"
:tag "builtin" "internal"
:custom ((user-full-name . "Karol Barski")
;; (user-login-name . "karolbarski")
(truncate-lines . t)
(menu-bar-mode . nil)
(tool-bar-mode . nil)
)
;; :config
;; (tool-bar-mode -1)
)
(leaf scroll-bar
:doc "window system-independent scroll bar support"
:tag "builtin" "hardware"
:added "2022-11-02"
:custom ((scroll-bar-mode . nil)
(horizontal-scroll-bar-mode . nil)
)
;; :config
;; (horizontal-scroll-bar-mode -1)
;; (scroll-bar-mode -1)
)
(leaf frame
;;--------------------------------------------------------------------------------
;; Default frame parameters
;;--------------------------------------------------------------------------------
:doc "multi-frame management independent of window systems"
:tag "builtin" "internal"
:added "2022-11-01"
;; :pre-setq
;; (kb/frame-config . '(;; (top . 1)
;; ;; (left . 1)
;; ;; (fullscreen . maximized)
;; (menu-bar-lines . 0) ; turn menus off
;; (tool-bar-lines . 0) ; disable toolbar
;; (scroll-bar-width . 10)
;; (vertical-scroll-bars . 'right)
;; ;; (background-mode . dark)
;; (font . "Hack")))
;; :setq ((default-frame-alist . kb/frame-config)
;; ;; (initial-frame-alist . kb/frame-config)
;; )
;; :custom (
;; (blink-cursor-mode . nil)
;; ;; turn off blinking cursor
;; (blink-cursor-blinks . 3)
;; (blink-cursor-delay . 1)
;; )
:push ((default-frame-alist . '(font . "Hack")))
:config
(blink-cursor-mode -1)
;; ;; (mapc 'frame-set-background-mode (frame-list))
;; ;; (fullscreen-restore . fullheight)
;; ;; (fullscreen . fullboth)
)
(leaf alloc
:tag "builtin"
:setq `(
(gc-cons-threshold . ,(* 100 1024 1024))
(read-process-output-max . ,(* 1024 1024))
(garbage-collection-messages . t)))
;; (leaf emacs-gc-stats
;; :doc "Collect Emacs GC statistics"
;; :req "emacs-25.1"
;; :tag "emacs>=25.1"
;; :url "https://git.sr.ht/~yantar92/emacs-gc-stats"
;; :added "2023-06-13"
;; :emacs>= 25.1
;; :straight t
;; :mode emacs-gc-stats-mode
;; :require emacs-gc-stats
;; :config
;; ;; (setq emacs-gc-stats-gc-defaults 'emacs-defaults) ; optional
;; ;; (setq gc-cons-threshold (* 800000 (seq-random-elt '(1 2 4 8 16 32 64 128))))
;; (emacs-gc-stats-mode +1)
;; )
(leaf battery
:doc "display battery status information"
:tag "builtin"
:added "2023-02-02"
:config
(display-battery-mode))
;; (leaf auto-compile
;; :straight t
;; :require t
;; :config
;; (auto-compile-on-load-mode)
;; (auto-compile-on-save-mode))
;; MuLe commands
(leaf mule-cmds
:doc "commands for multilingual environment"
:tag "builtin" "i18n" "mule"
:added "2022-12-08"
:config
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8))
;;--------------------------------------------------------------------------------
;; My emacs config
;;--------------------------------------------------------------------------------
(leaf startup
:doc "process Emacs shell arguments"
:tag "builtin" "internal"
:added "2022-11-01"
:custom ((inhibit-startup-screen . t)
(user-mail-address . "[email protected]")
))
(setopt line-spacing 0)
;; (help-char "? M-?")
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(keymap-set help-map "?" 'describe-key-briefly)
;; ("C-h" . 'delete-backward-char)
;; ("C-?" . 'delete-char)
;; ("ESC C-h" . 'backward-kill-word)
;; ("ESC C-?" . 'kill-word)
;; ("<f1>" . 'help-command)
;; ("ESC ?" . 'help-command)
;; ("ESC ? F" . 'view-emacs-FAQ)
;;--------------------------------------------------------------------------------
;; Emacs (simple) config
;;--------------------------------------------------------------------------------
(leaf simple
:doc "basic editing commands for Emacs"
:tag "builtin" "internal"
:added "2022-11-01"
:custom ((global-mark-ring-max . 5000) ; increase mark ring to contains 5000 entries
(mark-ring-max . 5000) ; increase kill ring to contains 5000 entries
(kill-ring-max . 5000) ; increase kill-ring capacity
(kill-whole-line . t)
(transient-mark-mode . nil)
(indent-tabs-mode . nil)
)
:bind (("C-;" . kill-whole-line)
("C-j" . kb/join-line))
:config
;; Join lines as in Vim
(defun kb/join-line()
"Join current and next line.
Remove tralinig spaces leaving only one. Similar to Vim Ctrl-j."
(interactive)
(join-line 'forward-line))
:config
(column-number-mode +1)
(line-number-mode +1)
(size-indication-mode t)
(put 'set-goal-column 'disabled nil)
)
;; remap C-H to backspace
;; (normal-erase-is-backspace-mode t)
;; remap C-H to backspace
(add-hook 'terminal-init-xterm-hook (lambda () (normal-erase-is-backspace-mode t)))
(leaf window
:doc "GNU Emacs window commands aside from those written in C"
:tag "builtin" "internal"
:added "2022-11-01"
:bind (("M-o" . other-window)))
(leaf files
:doc "file input and output commands for Emacs"
:tag "builtin"
:added "2022-11-01"
:custom ((large-file-warning-threshold . 100000000)
(mode-require-final-newline . t) ; add a newline to end of file)
)
)
(leaf indent
:doc "indentation commands for Emacs"
:tag "builtin"
:added "2022-11-01"
:custom ((tab-always-indent . 'complete)))
;; Use M-/ for `company` completion
;; (define-key input-decode-map "\e[1;2A" [S-up])
;; (key-valid-p "M-/")
(keymap-set input-decode-map "M-/" 'company-dabbrev)
(leaf page-break-lines
:doc "Display ^L page breaks as tidy horizontal lines"
:req "emacs-25.1"
:tag "faces" "convenience" "emacs>=25.1"
:url "https://github.com/purcell/page-break-lines"
:added "2025-01-16"
:emacs>= 25.1
:straight t
:config (global-page-break-lines-mode))
(leaf vc
:doc "drive a version-control system from within Emacs"
:tag "builtin"
:added "2022-11-01"
:custom ((vc-follow-symlinks . t))
)
(leaf help
:doc "help commands for Emacs"
:tag "builtin" "internal" "help"
:added "2022-11-01"
:custom ((temp-buffer-resize-mode . t))
)
;; image
(leaf image-file
:doc "support for visiting image files"
:tag "builtin"
:added "2025-01-16"
:custom
(auto-image-file-mode . 1))
;; time
(leaf time
:doc "display time, load and mail indicator in mode line of Emacs"
:tag "builtin"
:added "2023-01-31"
:custom ((display-time-format . "%H:%M %d/%m/%Y")
(display-time-24hr-format . t)
(display-time-day-and-date . t)
(display-time-default-load-average . 15))
:config
(display-time)
)
(leaf font-lock
;; kolorowanie składni
:doc "Electric font lock mode"
:tag "builtin" "faces" "languages"
:added "2022-11-01"
:custom ((font-lock-maximum-decoration . t))
:config (global-font-lock-mode t))
(leaf smerge-mode
:doc "Minor mode to resolve diff3 conflicts"
:tag "builtin"
:added "2022-11-01"
:init (setq-default smerge-command-prefix (kbd "C-c v"))
;; :custom (smerge-command-prefix . "C-c v")
)
(defun kb/set-buffer-eol-unix ()
"Set current buffer EOL type to unix."
(interactive)
(set-buffer-file-eol-type 'unix))
(defun kb/set-buffer-eol-dos ()
"Set current buffer EOL type to dos."
(interactive)
(set-buffer-file-eol-type 'dos))
(defun kb/set-buffer-eol-mac ()
"Set current buffer EOL type to mac."
(interactive)
(set-buffer-file-eol-type 'mac))
(defun kb/insert-random-number
(&optional arg)
"Insert a random number. Use prefix argument ARG to specify the range.
If called with a prefix argument, prompts for MIN and MAX values."
(interactive "P")
(let ((min 0)
(max 999))
(when arg
(setq min (read-number "Min value: " 0)
max (read-number "Max value: " 999)))
(insert (number-to-string (+ min (random (- max min)))))))
(global-set-key (kbd "C-c r") 'kb/insert-random-number)
(define-key global-map (kbd "C-a") 'prelude-move-beginning-of-line)
;; (define-key global-map (kbd "C-c i") 'indent-region-or-buffer)
;; (define-key global-map (kbd "M-o") 'prelude-smart-open-line)
;; (define-key global-map (kbd "%") 'match-parenthesis) ;; % key on paren moves cursor to matching paren
(define-key global-map (kbd "C-c T") 'kb/delete-trailing-whitespaces-and-untabify)
(define-key global-map (kbd "C-c u") 'kb/set-buffer-eol-unix)
(define-key global-map (kbd "C-c d") 'kb/set-buffer-eol-dos)
;; (define-key global-map (kbd "C-c m") 'kb/set-buffer-eol-mac)
(define-key global-map (kbd "C-c C-d") 'kb/insert-date-time)
(leaf insert-time-string
:bind (("C-c C-!" . insert-time-string))
)
(defun kb/update-env (fn)
"Update environment variables reading FN file.
To prepare FN file issue following command in session of which variables
should be imported.
`printenv -o > ~/env.txt'"
(interactive "fEnvironment file:")
(let ((str
(with-temp-buffer
(insert-file-contents fn)
(buffer-string))) lst)
(setq lst (split-string str "\000"))
(while lst
(setq cur (car lst))
(when (string-match "^\\(.*?\\)=\\(.*\\)" cur)
(setq var (match-string 1 cur))
(setq value (match-string 2 cur))
(setenv var value))
(setq lst (cdr lst)))))
(leaf kill-file-path
:doc "Copy file name into kill ring"
:req "emacs-26"
:tag "files" "emacs>=26"
:url "https://github.com/chyla/kill-file-path/kill-file-path.el"
:added "2024-02-19"
:emacs>= 26
:straight t
:bind
("C-c f" . kill-file-path)
)
;; (when (not (package-installed-p 'kill-file-path))
;; (defun kb/filename ()
;; "Copy the full path of the current buffer."
;; (interactive)
;; (kill-new (buffer-file-name (window-buffer (minibuffer-selected-window)))))
;; (define-key global-map (kbd "C-c f") 'kb/filename)
;; )
(leaf kill-or-bury-alive
:doc "Precise control over buffer killing"
:req "emacs-24.4"
:tag "convenience" "emacs>=24.4"
:url "https://github.com/mrkkrp/kill-or-bury-alive"
:added "2024-02-19"
:emacs>= 24.4
:straight t
:bind
(([remap kill-buffer] . #'kill-or-bury-alive)
;; ("C-c p" . #'kill-or-bury-alive-purge-buffers)
))
;; I know that string is in my Emacs somewhere!
;; (require 'cl)
(defgroup kb-config nil
"Custom options for KB config."
:group 'convenience
:link '(url-link :tag "Github" "https://github.com/lollinus/my-emacs-config"))
(defcustom kb/search-all-buffers-ignored-files (list (rx-to-string '(and bos (or ".bash_history" "TAGS") eos)))
"Files to ignore when searching buffers via \\[search-all-buffers]."
:type 'editable-list
:group 'kb-config)
;; (require 'grep)
;; (defun kb/search-all-buffers (regexp prefix)
;; "Searches file-visiting buffers for occurence of REGEXP. With
;; prefix > 1 (i.e., if you type C-u \\[search-all-buffers]),
;; searches all buffers."
;; (interactive (list (grep-read-regexp)
;; current-prefix-arg))
;; (message "Regexp is %s; prefix is %s" regexp prefix)
;; (multi-occur
;; (if (member prefix '(4 (4)))
;; (buffer-list)
;; (remove-if
;; (lambda (b) (some (lambda (rx) (string-match rx (file-name-nondirectory (buffer-file-name b)))) kb/search-all-buffers-ignored-files))
;; (remove-if-not 'buffer-file-name (buffer-list))))
;; regexp))
(leaf color-moccur
:doc "multi-buffer occur (grep) mode"
:tag "convenience"
:url "http://www.bookshelf.jp/elc/color-moccur.el"
:added "2022-11-01"
:disabled t
:straight t
:commands (isearch-moccur isearch-all)
:bind (("M-s O" . moccur)
(:isearch-mode-map
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))
:custom ((isearch-lazy-highlight . t))
;; :config
;; (leaf moccur-edit :straight t)
)
;; (global-set-key [f7] 'search-all-buffers)
;; (define-key global-map (kbd "") 'kb/update-env)
(leaf rect
;; string-insert-rectangle is useful but not binded to any key by default
:bind (("C-x r l" . 'rectangle-number-lines))
;; (define-key global-map (kbd "C-x r a") 'string-insert-rectangle) ;; use string-rectange instead "C-x r t"
)
(leaf whitespace
:doc "minor mode to visualize TAB, (HARD) SPACE, NEWLINE"
:tag "builtin"
:added "2022-11-01"
:custom (
;; (setq whitespace-style '(face trailing lines-tail newline empty indentation big-indent space-before-tab))
(whitespace-style . '(newline-mark newline))
(whitespace-line-column . nil)
(whitespace-display-mappings . '((space-mark 32 [183] [46])
(newline-mark 10 [9166 10])
(tab-mark 9 [9654 9] [92 9]))))
:bind (("C-c w w" . whitespace-mode))
:custom-face
(whitespace-space . '((t (:inherit whitespace-space :foreground "DimGrey" :background nil))))
(whitespace-newline . '((t (:inherit whitespace-newline :foreground "DimGrey" :background nil))))
(whitespace-indentation . '((t (:inherit whitespace-indentation :foreground "DimGrey" :background nil))))
:config
(global-whitespace-mode 1)
)
;; Set Theme depending if emacs frame is inside TTY o GUI
;;--------------------------------------------------------------------------------
(leaf doom-themes
:doc "an opinionated pack of modern color-themes"
:req "emacs-25.1" "cl-lib-0.5"
:tag "faces" "themes" "emacs>=25.1"
:url "https://github.com/doomemacs/themes"
:added "2022-11-04"
;; :emacs>= 25.1
:straight t
;; :defines (doom-themes-treemacs-theme)
:after all-the-icons ;; doom-atom requires all-the-icons
:custom
(doom-themes-enable-bold . t)
(doom-themes-enable-italic . t)
(doom-themes-treemacs-theme . "doom-atom")
:config
;; (load-theme 'doom-one t)
;; (load-theme 'doom-xcode t)
;; (when (fboundp doom-dark+-blue-modeline)
;; (setq doom-dark+-blue-modeline t)
;; (setq doom-dark+-padded-modeline nil)
;; )
(doom-themes-visual-bell-config)
;; (doom-themes-neotree-config)
(doom-themes-treemacs-config)
(doom-themes-org-config))
(leaf solarized-theme
:doc "The Solarized color theme"
:req "emacs-24.1"
:tag "solarized" "themes" "convenience" "emacs>=24.1"
:url "http://github.com/bbatsov/solarized-emacs"
:added "2022-11-04"
;; :emacs>= 24.1
:straight t)
(leaf solaire-mode
:doc "make certain buffers grossly incandescent"
:req "emacs-25.1" "cl-lib-0.5"
:tag "faces" "buffer" "window" "bright" "dim" "emacs>=25.1"
:url "https://github.com/hlissner/emacs-solaire-mode"
:added "2023-02-14"
:emacs>= 25.1
:straight t
:config
(solaire-global-mode))
;; (leaf modus-themes
;; :doc "Elegant, highly legible and customizable themes"
;; :req "emacs-27.1"
;; :tag "accessibility" "theme" "faces" "emacs>=27.1"
;; :url "https://git.sr.ht/~protesilaos/modus-themes"
;; :added "2023-02-10"
;; :emacs>= 27.1
;; :straight t)
(leaf doom-modeline
:straight t
:hook after-init-hook
:config
:custom (
(doom-modeline-hud . t)
(doom-modeline-buffer-file-name-style . 'truncate-with-project)
;; (setq doom-modeline-enable-word-count nil)
(doom-modeline-buffer-encoding . 'nondefault)
(doom-modeline-default-coding-system . 'utf-8)
(doom-modeline-default-eol-type . 0)
(doom-modeline-vcs-max-length . 24)
(doom-modeline-battery . t)
(doom-modeline-indent-info . t)
(doom-modeline-checker-simple-format . nil)))
(leaf nerd-icons
:doc "Emacs Nerd Font Icons Library. Required by doom-modeline"
:req "emacs-24.3"
:tag "lisp" "emacs>=24.3"
:url "https://github.com/rainstormstudio/nerd-icons.el"
:added "2023-06-15"
:emacs>= 24.3
:straight t
:config
;; (unless (file-exists-p (expand-file-name (concat (nerd-icons-fonts-subdirectory nerd-icons-font-names))))
(unless (file-exists-p (expand-file-name "~/.local/share/fonts/NFM.ttf"))
(nerd-icons-install-fonts t)))
(leaf nerd-icons-ibuffer
:doc "Display nerd icons in ibuffer"
:req "emacs-24.3" "nerd-icons-0.0.1"
:tag "ibuffer" "icons" "convenience" "emacs>=24.3"
:url "https://github.com/seagle0128/nerd-icons-ibuffer"
:added "2023-06-15"
:emacs>= 24.3
:straight t
:after nerd-icons
:hook ibuffer-mode-hook
:custom
(nerd-icons-ibuffer-icon . t)
(nerd-icons-ibuffer-color-icon . t)
(nerd-icons-ibuffer-icon-size . 1.0)
(nerd-icons-ibuffer-human-readable-size . t)
:config
;; A list of ways to display buffer lines with `nerd-icons'.
;; See `ibuffer-formats' for details.
;; nerd-icons-ibuffer-formats
)
(leaf circadian
:straight t
:custom
(calendar-latitude . 53.51)
(calendar-longitude . 14.57)
(circadian-themes . '((:sunrise . doom-monokai-machine)
("8:00" . tango-dark)
("15:15" . doom-bluloco-dark)
("15:45" . doom-ephemeral)
(:sunset . doom-badger)
("21:30" . doom-monokai-pro)))
:config
(circadian-setup)
)
(leaf treemacs-nerd-icons
:doc "Emacs Nerd Font Icons theme for treemacs"
:req "emacs-24.3" "nerd-icons-0.0.1" "treemacs-0.0"
:tag "lisp" "emacs>=24.3"
:url "https://github.com/rainstormstudio/treemacs-nerd-icons"
:added "2023-06-15"
:emacs>= 24.3
:straight t
:defun treemacs-load-theme
:after nerd-icons treemacs
:require t
:config
(treemacs-load-theme "nerd-icons"))
(defcustom kb/terminal-theme 'wombat
"Theme which should be activated when frame is open inside terminal."
:type 'string
:group 'kb-config)
;; (doom-one doom-snazzy)
;; (doom-moonlight doom-monokai-machine modus-vivendi-tinted misterioso)
(defcustom kb/window-theme 'doom-monokai-machine
"Theme which should be activated when frame is open inside GUI."
:type 'string
:group 'kb-config)
(defvar kb/theme-window-loaded nil)
(defcustom kb/theme-window-font (if (eq system-type 'windows-nt)
"Unifont"
;(set-frame-parameter nil 'font "Arial Unicode MS")
"Hack"
)
"Font to used by my configuration.
The font defined here is used when switching Emacs frame between
GUI and TTY as well when changing between themes."
:type 'face
:group 'kb-config
)
(defvar kb/theme-terminal-loaded nil)
(defvar kb/theme-original-font nil)
;; font configuration
(defun kb/set-window-font ()
"Function set screen font.
If Emacs is run in MS Windows then use Arial Unicode MS
On U*x systems Use Hack"
(setq kb/theme-original-font (frame-parameter nil 'font))
(set-frame-parameter nil 'font kb/theme-window-font)
;; (set-frame-font kb/theme-window-font nil t)
)
(defun kb/switch-font ()
"Function set screen font.
Set original font."
(interactive)
(if (and kb/theme-original-font (eq kb/theme-original-font (frame-parameter nil 'font)))
(kb/set-window-font)
(set-frame-parameter nil 'font kb/theme-original-font)))
(define-key global-map (kbd "C-c o") 'kb/switch-font)
;;--------------------------------------------------------------------------------
(defun kb/load-graphics-theme ()
"Function to load theme for GUI Emacs."
(interactive)
(unless kb/theme-window-loaded
(setq kb/theme-window-loaded (load-theme kb/window-theme t t))
(message "Theme `%S' loaded %S" kb/window-theme kb/theme-window-loaded))
kb/theme-window-loaded)
(defun kb/load-terminal-theme ()
"Function to load theme for TTY Emacs."
(interactive)
(unless kb/theme-terminal-loaded
(setq kb/theme-terminal-loaded (load-theme kb/terminal-theme t t))
(message "Theme `%S' loaded %S" kb/terminal-theme kb/theme-terminal-loaded))
kb/theme-terminal-loaded)
(defun kb/activate-frame-theme (frame)
"Activate theme depending on current FRAME window system.
If theme is'n loaded then it will be loaded at first"
(interactive)
(message "Activate frame theme")
(select-frame frame)
(cond ((window-system frame)
(message (format "Activate frame %s graphical-theme" frame))
(when (kb/load-graphics-theme)
(message "Activate frame theme: load-graphics-theme")
(enable-theme 'kb/window-theme))
(message "Activate frame theme: set-window-font")
(kb/set-window-font))
((kb/load-terminal-theme)
(message (format "Activate frame %s theme: terminal-theme" frame))
(enable-theme 'kb/terminal-theme)))
)
(defun kb/activate-theme (&optional frame)
"Set theme on active FRAME."
(interactive)
(message "Activate theme")
(let ((frame (or frame (selected-frame))))
(when (frame-focus-state frame)
(message (format "Activate theme for frame: %s" frame))
(kb/activate-frame-theme frame))
))
;; (kb/activate-theme)
;; (add-function :after after-focus-change-function #'kb/activate-theme)
;; (add-hook 'after-make-frame-functions-hook 'kb/load-frame-theme)
;; (frame-focus-state)
;; ( doom-modeline-update-env)
;; (beacon--blink-on-focus)
(leaf custom
:doc "tools for declaring and initializing options"
:tag "builtin" "faces" "help"
:added "2022-11-04"
:custom
(custom-safe-themes . t)
;; (custom-enabled-themes . '(doom-monokai-machine wombat tango-dark))
;; (custom-enabled-themes . '(doom-monokai-machine))
;; :config
;; (message "custom: load kb/window-theme")
;; (load-theme kb/window-theme t)
;; (kb/activate-theme)
;; (message "custom: set kb/set-window-font")
;; (kb/set-window-font)
)
;;--------------------------------------------------------------------------------
;; Programming modes
;;--------------------------------------------------------------------------------
(defconst kb/c-style
'("linux"
(fill-column . 100)
(c-basic-offset . 4)
(tab-width . 8)
(indent-tabs-mode . t))
"Style used for C source editing.")
(defun kb/c-mode-hook ()
"My style used while editing C sources."
(c-add-style "kb/c-style" kb/c-style t)
(turn-on-auto-fill))
(add-hook 'c-mode-hook 'kb/c-mode-hook)
(defconst kb/c++-style
'(
(fill-column . 120)
(c-basic-offset . 4)
(tab-width . 4)
(indent-tabs-mode . nil)
(c-offsets-alist . ((innamespace . 0)
(inline-open . 0)
(substatement-open . 0)
(statement-cont . +)))
(c-hanging-braces-alist . ((brace-list-open . before)
(brace-entry-open . before)
(substatement-open . before)
;; (namespace-open . before)
))
)
"Style used for C++ source editing.")
(defconst kb/c++-mavenir
'(
(fill-column . 100)
(c-basic-offset . 4)
(tab-width . 4)
(indent-tabs-mode . nil)
(c-offsets-alist . ((innamespace . 0)
(inline-open . 0)
(substatement-open . 0)
(arglist-intro . ++)
;; (func-decl-cont . ++)
(statement-cont . ++)
(statement-case-open . 0)
;; (statement-case-intro . 0)
(case-label . +)
))
(c-hanging-braces-alist . ((brace-list-open . before)
(brace-entry-open . before)
(substatement-open . before)
;; (namespace-open . before)
))
)
"Style used for C++ source editing at mavenir.")
(defun kb/c++-setup-symbol-compose ()
"Define additional symbol composition rules for C++ mode."
(push '("<=" . ?⩽) prettify-symbols-alist)
(push '(">=" . ?⩾) prettify-symbols-alist)
(push '("->" . ?→) prettify-symbols-alist)
(push '("!=" . ?≠) prettify-symbols-alist)
)
(defun kb/c++-mode-hook ()
"My style used while editing C++ sources."
(c-add-style "kb/c++-style" kb/c++-style t)
(auto-fill-mode)
(display-fill-column-indicator-mode)
(kb/c++-setup-symbol-compose)
)
(add-hook 'c++-mode-hook 'kb/c++-mode-hook)
(defun kb/cc-compile-command-hook ()
"Compile C/C++ files with gcc if makefile doesn't exist."
(unless (or (file-exists-p "makefile")
(file-exists-p "Makefile"))
(set (make-local-variable 'compile-command)
(let ((file (file-name-nondirectory buffer-file-name)))
(format "%s -c -o %s.o %s %s %s"
(or (getenv "CC") "g++")
(file-name-sans-extension file)
(or (getenv "CPPFLAGS") "-DDEBUG=9")
(or (getenv "CFLAGS") "-ansi -pedantic -Wall -g")
file)))))
;; (add-hook 'c++-mode 'kb/cc-compile-command-hook)
;; (font-lock-add-keywords 'c-mode '("\\<\\(and\\|or\\|not\\)\\>"))
(leaf hl-todo
:doc "Highlight TODO and similar keywords"
:req "emacs-25.1" "compat-28.1.1.0"
:tag "convenience" "emacs>=25.1"
:url "https://github.com/tarsius/hl-todo"
:added "2022-11-02"
:emacs>= 25.1
:straight t
:bind ((:hl-todo-mode-map
("C-c t p" . #'hl-todo-previous)