-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-org-config.el
951 lines (756 loc) · 31.2 KB
/
my-org-config.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
(load-theme 'modus-vivendi t)
;; (load-theme 'ef-night t)
(load-theme 'ef-cherie t)
(when (fboundp 'dired-mode)
(defun my-dired/command-map ()
(interactive)
(define-key xah-fly-command-map (kbd "k") #'dired-narrow-regexp))
(add-hook 'dired-mode-hook 'my-dired/command-map))
;;(load-theme 'ef-bio t)
;; Check if Emacs was started with the --debug-init flag
(if init-file-debug
;; Open the specific file if Emacs was started with --debug-init
(find-file "C:/Users/George/.emacs.d/my-org-config.org"))
;; (defun random-color-theme ()
;; (interactive)
;; (random t)
;; (funcall (car (nth (random (length color-themes)) color-themes))))
;; (random-color-theme)
;; (run-with-timer 1 (* 60 60) 'random-color-theme)
(marginalia-mode t)
(set-face-attribute 'default nil
:height 150)
(setq ivy-initial-inputs-alist nil)
;; (global-set-key (kbd "S-<return>") #'ivy-immediate-done) - only
(define-key minibuffer-local-map [S-<return>] #'ivy-immediate-done)
(global-prettify-symbols-mode 1)
(define-key global-map (kbd "C-<f5>") #'modus-themes-toggle)
(defun gh/mode-line-count-lines ()
(interactive)
(:eval (format "LS: %d"
(lambda ()
(when (region-active-p)
(count-lines (region-beginning)
(region-end)))))))
;;; Mode line
;; (setq mode-line-percent-position '(-3 "%p"))
;; (setq mode-line-position-column-line-format '(" %l,%c")) ; Emacs 28
;; (setq mode-line-defining-kbd-macro
;; (propertize " Macro" 'face 'mode-line-emphasis))
;; ;; Thanks to Daniel Mendler for this! It removes the square brackets
;; ;; that denote recursive edits in the modeline. I do not need them
;; ;; because I am using Daniel's `recursion-indicator':
;; ;; <https://github.com/minad/recursion-indicator>.
(setq-default mode-line-modes
(seq-filter (lambda (s)
(not (and (stringp s)
(string-match-p
"^\\(%\\[\\|%\\]\\)$" s))))
mode-line-modes))
(use-package recursion-indicator
:demand t
:config
(recursion-indicator-mode))
(setq minibuffer-depth-indicate-mode nil)
;; (setq mode-line-compact nil) ; Emacs 28
;; (setq-default mode-line-format
;; '("%e"
;; mode-line-front-space
;; mode-line-mule-info
;; mode-line-client
;; mode-line-modified
;; mode-line-remote
;; mode-line-frame-identification
;; mode-line-buffer-identification
;; " "
;; mode-line-position
;; mode-line-modes
;; " "
;; (vc-mode vc-mode)
;; " "
;; mode-line-misc-info
;; mode-line-end-spaces)) ;from Prot
;; (set-face-foreground 'mode-line "gray")
;; (set-face-background 'mode-line "black")
;; (set-face-foreground 'line-number "#565759")
;; (set-face-background 'line-number "#000000")
;;; Mode line
;; (setq mode-line-position-column-line-format '(" %l,%c")) ; Emacs 28
(setq mode-line-defining-kbd-macro
(propertize " kc" 'face 'mode-line-emphasis))
;1, spc l, C-g, j
;; super
;; spc spc
(savehist-mode 1)
(defun gh/check-parens ()
(interactive)
(check-parens)
(message "parens have been checked"))
(global-set-key (kbd "<f1>") 'gh/check-parens)
;; Enable debug on error
(toggle-debug-on-error 1)
;; Check if Emacs started with an error
(if (bound-and-true-p debug-on-error)
;; Open the specific file if Emacs started with an error
(find-file "/path/to/your/file"))
;(setq orderless-matching-styles orderless-flex)
(define-key process-menu-mode-map (kbd "C-k") 'joaot/delete-process-at-point)
(defun joaot/delete-process-at-point ()
(interactive)
(let ((process (get-text-property (point) 'tabulated-list-id)))
(cond ((and
process
(processp process))
(delete-process process)
(revert-buffer))
(t
(error
"no process at point!")))))
(global-set-key (kbd "M-t") #'transpose-words)
(global-set-key (kbd "C-,") #'embark-act)
;(orderless-literal orderless-regexp)
(setq default-directory "~/")
(add-to-list 'load-path "~/.emacs.d/lisp/")
(setq history-length t history-delete-duplicates t)
(require 'xah-fly-keys)
(xah-fly-keys-set-layout "colemak-dhm")
(xah-fly-keys 1)
;(setq xah-fly-use-control-key nil)
(autoload 'xah-elisp-mode "xah-elisp-mode" "xah emacs lisp major mode." t)
(xah-elisp-mode)
;; (global-set-key (kbd "C-[") #'xah-goto-matching-bracket)
(define-key xah-fly-command-map (kbd "'") #'xah-forward-right-bracket)
(define-key xah-fly-command-map (kbd "8") #'er/expand-region)
(define-key xah-fly-command-map (kbd "C-8") #'er/contract-region)
(define-key xah-fly-command-map (kbd "(") 'xah-backward-left-bracket)
(define-key xah-fly-command-map (kbd ")") 'xah-forward-right-bracket)
(define-key xah-fly-command-map (kbd "a") #'ignore)
(define-key xah-fly-command-map (kbd "U") #'scroll-down)
(define-key xah-fly-command-map (kbd "E") #'scroll-up)
(define-key xah-fly-command-map (kbd "<right>") #'forward-char)
(define-key xah-fly-command-map (kbd "<left>") #'backward-char)
(define-key xah-fly-command-map (kbd "K") #'isearch-forward-regexp)
(define-key xah-fly-command-map (kbd "C-K") #'isearch-backward-regexp)
(global-set-key (kbd "C-S-r") #'isearch-backward-regexp)
(define-key xah-fly-leader-key-map (kbd "z") #'jump-to-register)
(define-key xah-fly-leader-key-map (kbd "d") #'xah-shrink-whitespaces)
(define-key key-translation-map (kbd "ESC")
(kbd "C-g"))
;dhm
(global-set-key (kbd "C-S-<down>") #'end-of-defun)
(global-set-key (kbd "C-S-<up>") #'beginning-of-defun)
;; (define-minor-mode centered-point-mode
;; "Always center the cursor in the middle of the screen."
;; :lighter "..."
;; (cond (centered-point-mode (add-hook 'post-command-hook 'line-change))
;; (t (remove-hook 'post-command-hook 'line-change)))
;; )
;; (centered-point-mode 1)
(global-set-key (kbd "M-<f4>") 'save-buffers-kill-terminal)
(require 'key-chord)
(key-chord-mode 1)
(defun my-switch-to-previous-buffer ()
"Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(require 'expand-region)
(setq key-chord-one-key-delay 0.095 ;0.095
key-chord-two-keys-delay 0.032) ;was 0.032
;;Laptop
(key-chord-define-global "df" #'scroll-other-window-down)
(key-chord-define-global "cv" #'scroll-other-window)
(key-chord-define-global "jk" 'undo)
;; (key-chord-define-global "pp" (lambda () (interactive) (kill-word
;; 1))) ;only if Kinesis Advantage 2 is plugged in?
;; (key-chord-define-global "==" (lambda () (interactive) (kill-word 1)))
;; (key-chord-define-global "ff" (lambda () (interactive) (backward-kill-word ;; 1)))
;; (key-chord-define-global "--" (lambda () (interactive) (backward-kill-word ;; 1)))
(key-chord-define-global "-=" #'kill-word)
(key-chord-define-global "0-" #'backward-kill-word)
(key-chord-define-global "12"
(lambda ()
(interactive)
(find-file "c:/Users/George/.emacs.d/my-org-config.org")))
(key-chord-define-global "23"
(lambda ()
(interactive)
(find-file "c:/Users/George/.emacs.d/lisp/xah-elisp-mode.el")))
(key-chord-define-global "34"
(lambda ()
(interactive)
(find-file "c:/Users/George//OrgFiles/notes.org")))
(key-chord-define-global "90" 'xah-close-current-buffer)
(key-chord-define-global "89" 'xah-open-last-closed)
(key-chord-define-global "zx" 'eval-last-sexp)
(key-chord-define-global ",." #'avy-goto-char-timer)
(key-chord-define-global "ak" #'avy-kill-region)
(key-chord-define-global "ay" #'avy-copy-region)
(key-chord-define-global "am" #'avy-move-region)
(key-chord-define-global "as" #'execute-extended-command)
(key-chord-define-global "qw" #'my-switch-to-previous-buffer)
(key-chord-define-global "\\\\" #'iy-go-to-char)
(key-chord-define-global "''" #'iy-go-to-char-backward)
(global-set-key (kbd "M-'") #'iy-go-to-char)
;; (global-set-key (kbd "M-o") #'iy-go-to-char-backward)
;; Colemak-dhm
;; (key-chord-define-global "pp" (lambda () (interactive)))
;; (key-chord-define-global "==" (lambda () (interactive)))
;; (key-chord-define-global "ff" (lambda () (interactive)))
;; (key-chord-define-global "--" (lambda () (interactive)))
(key-chord-define-global "bj" #'undo)
;; (key-chord-define-global "12" (lambda () (interactive)))
;; (key-chord-define-global "23" (lambda () (interactive)))
;; (key-chord-define-global "34" (lambda () (interactive)))
;; (key-chord-define-global "90" #'xah-close-current-buffer)
;; (key-chord-define-global "89" #'xah-open-last-closed)
(key-chord-define-global "dh" #'eval-last-sexp)
(key-chord-define-global "ne" #'avy-goto-char-timer)
(key-chord-define-global "gm" #'execute-extended-command)
(key-chord-define-global "fp" #'my-switch-to-previous-buffer)
(key-chord-define-global "gn" #'delete-forward-char)
(key-chord-define-global "ai" #'forward-word)
(key-chord-define-global "an" #'backward-word)
;; (key-chord-define-global "op" #'kill-word)
;; (key-chord-define-global "of" #'backward-kill-word)
;; (key-chord-define-global "\\\\" #'iy-go-to-char)
;; (key-chord-define-global "''" #'iy-go-to-char-backward)
;; (key-chord-define-global "0a" #'backward-word)
;; (key-chord-define-global "1a" #'backward-word)
;; (key-chord-define-global "2a" #'backward-word)
;; (key-chord-define-global "3o" #'backward-word)
;; (key-chord-define-global "4o" #'backward-word)
;; (key-chord-define-global "5o" #'backward-word)
;; (key-chord-define-global "6a" #'backward-word)
;; (key-chord-define-global "7o" #'backward-word)
;; (key-chord-define-global "8o" #'backward-word)
;----
;play
(key-chord-define-global " s" #'eval-last-sexp)
(mapc
(lambda (keyscommand)
(key-chord-define-global (car keyscommand)
(cdr keyscommand)))
'(
("[f" . "{")
("]f" . "}")
("/j" . "?")
("\\j" . "|")))
;-----
(global-set-key (kbd "<C-kp-1>") (lambda () (interactive) (find-file "c:/Users/George/.emacs.d/my-org-config.org")))
(global-set-key (kbd "<C-kp-2>") (lambda () (interactive) (find-file "c:/Users/George/.emacs.d/lisp/xah-elisp-mode.el")))
(global-set-key (kbd "<C-kp-3>") (lambda ()(interactive)(find-file "c:/Users/George//OrgFiles/notes.org")))
;--------
;Examples:
;; (key-chord-define-global ",." "<>\C-b")
;; (key-chord-define-global "jk" 'dabbrev-expand)
;; (key-chord-define-global "4r" "$")
;("." repeat)
(setq scroll-preserve-screen-position 'always)
(setq w32-pass-rwindow-to-system t)
;; (setq gnus-select-method '(nnnil ""))
;; ;; (setq gnus-select-method '(nnimap "imap.google.com")
;; (setq message-send-mail-function 'smtpmail-send-it)
;; (setq send-mail-function 'smtpmail-send-it)
;; (setq gnus-message-archive-group "Gmail]/Sent mail")
;; (setq gnus-select-method
;; '(nnimap "gmail"
;; (nnimap-address "imap.gmail.com") ; it could also be imap.googlemail.com if that's your server.
;; (nnimap-server-port 993)
;; (nnimap-stream ssl)))
;; (setq smtpmail-smtp-server "mail.domain.com")
;; ;; machine imap.gmail.com login sacha@sachachua.com password mysecretapppassword
;; (setq user-full-name "George Hadow"
;; user-mail-address "georgehadow@gmail.com")
;; ;; (setq gnus-interactive-exit nil)
;; ;; (setq gnus-novice-user nil)
;; ;; (setq gnus-expert-user t)
;; ;; (global-set-key (kbd "DEL") #'gnus-summary-delete-article gnus-summary-mode-map)
;; ;; (setq gnus-secondary-select-method '(nntp news.gmane.io)) ;think this is wrong
;; ;; (add-to-list 'gnus-secondary-select-methods '(nntp "news.gmane.io"))
;from gpt
;; Gnus settings for Windows 11
(setq gnus-select-method '(nntp "news.gmane.io"))
(setq user-mail-address "georgehadow@gmail.com")
(setq user-full-name "George Hadow")
;; Use Windows 11's built-in TLS library for secure connections
(setq gnutls-program "gnutls-cli.exe")
(setq starttls-use-gnutls t)
;; Set the path to your Emacs installation folder
(setq exec-path (cons "C:/Program Files/Emacs/bin" exec-path))
(setenv "PATH" (concat "C:/Program Files/Emacs/bin;" (getenv "PATH")))
;; Set up the Gnus registry for Windows 11
(when (eq system-type 'windows-nt)
(setq gnus-registry-max-entries 500)
(setq gnus-registry-use-long-group-names t)
(setq gnus-registry-unfollowed-addresses '("root@localhost" "postmaster@localhost"
"mailer-daemon@localhost" "nobody@localhost"
"hostmaster@localhost" "news@localhost"
"newsfeeds@localhost" "usenet@localhost"
"ftp@localhost" "webmaster@localhost" "www@localhost"
"httpd@localhost")))
;; Add some key bindings for Gnus
(global-set-key (kbd "<C-f9>") 'gnus)
;; (global-set-key (kbd "<f10>") 'gnus-group-list-all-groups)
(setq message-send-mail-function 'smtpmail-send-it smtpmail-default-smtp-server "smtp.gmail.com"
smtpmail-smtp-server "smtp.gmail.com" smtpmail-smtp-service 587 smtpmail-starttls-credentials
'(("smtp.gmail.com" 587 nil nil)) smtpmail-auth-credentials '(("smtp.gmail.com" 587
"georgehadow@gmail.com" nil))
smtpmail-debug-info t)
(setq smtpmail-password "vxnrjygbxkdlfozv")
;; (setq smtp.gmail.com)
(setq user-mail-address "georgehadow@gmail.com")
(setq smtpmail-smtp-user "georgehadow@gmail.com")
(setq smtpmail-smtp-server "smtp.gmail.com")
(setq smtpmail-smtp-service 587)
(setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
(setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "georgehadow@gmail.com" nil)))
(setq smtpmail-default-smtp-server "smtp.gmail.com")
(setq smtpmail-smtp-server "smtp.gmail.com")
(setq smtpmail-smtp-service 587)
(setq smtpmail-debug-info t)
;; (add-to-list 'default-frame-alist '(fullscreen . maximized))
(global-set-key (kbd "C-h b") #'counsel-descbinds)
(require 'zoom-frm) ;had problems with minibuffer text becoming too small and possible freezing
; (global-set-key (kbd "C-+") #'zoom-frm-in)
; (global-set-key (kbd "C--") #'zoom-frm-out)
(setq enable-recursive-minibuffers t)
(minibuffer-depth-indicate-mode t)
(setq initial-scratch-message "")
(setq initial-major-mode 'xah-elisp-mode) ;disables scratch
(setq desktop-path '("~/")
;; initial-buffer-choice 'xah-new-empty-buffer
inhibit-startup-screen t
save-abbrevs 'silently
custom-file null-device)
(add-hook 'after-init-hook #'fancy-battery-mode)
(setq fancy-battery-show-percentage t)
(setq display-time-day-and-date nil)
(display-time-mode t)
(desktop-save-mode 1)
(fset 'yes-or-no-p 'y-or-n-p)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(defun gh/reset-local-mark-ring ()
(interactive)
(setq mark-ring nil)
(message "local mark ring reset"))
(defun gh/reset-global-mark-ring ()
(interactive)
(seq global-mark-ring nil)
(message "global mark ring reset"))
(global-set-key (kbd "C-<f12>") #'gh/reset-global-mark-ring)
(global-set-key (kbd "<f12>") #'gh/reset-local-mark-ring)
(global-set-key (kbd "<f7>") #'pop-global-mark)
(global-set-key (kbd "C-x C-x") #'eval-last-sexp)
(global-set-key (kbd "C-x C-s") #'eval-expression)
;; (defun gg ()
;; "DOCSTRING"
;; (interactive)
;; (insert ()))
(global-set-key (kbd "C-c <up>") #'org-previous-visible-heading)
(global-set-key (kbd "C-c <down>") #'org-next-visible-heading)
(global-set-key (kbd "<f10>") #'menu-bar-mode)
(smooth-scrolling-mode t) ;dnw with Linux?
(menu-bar-mode -1)
(put 'narrow-to-region 'disabled nil)
;; (global-set-key (kbd "C-<spc>") '(set-mark-command))
(set-face-attribute 'default nil
:height 170)
;; (global-set-key [next]
;; (lambda () (interactive)
;; (condition-case nil (scroll-up)
;; (end-of-buffer (goto-char (point-max))))))
;; (global-set-key [prior]
;; (lambda () (interactive)
;; (condition-case nil (scroll-down)
;; (beginning-of-buffer (goto-char (point-min))))))
(require 'package) ; Bring in to the environment all package management
;; A list of package repositories
(setq package-archives '(("elpa" . "https://elpa.gnu.org/packages/")
("elpa-devel" . "https://elpa.gnu.org/devel/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")))
(setq package-archive-priorities
'(("elpa" . 2)
("nongnu" . 1)))
(package-initialize) ; Initializes the package system and prepares it to be used
(unless package-archive-contents ; Unless a package archive already exists,
(package-refresh-contents)) ; Refresh package contents so that Emacs knows which packages to load
;; Initialize use-package on non-linux platforms
(unless (package-installed-p 'use-package) ; Unless "use-package" is installed, install "use-package"
(package-install 'use-package))
(require 'use-package) ; Once it's installed, we load it using require
;; Make sure packages are downloaded and installed before they are run
;; also frees you from having to put :ensure t after installing EVERY PACKAGE.
(setq use-package-always-ensure t)
(use-package
gcmh
:config (gcmh-mode 1))
;; Setting garbage collection threshold
(setq gc-cons-threshold 402653184 gc-cons-percentage 0.6)
(add-hook 'emacs-startup-hook
(lambda ()
(message "*** Emacs loaded in %s with %d garbage collections." (format "%.2f seconds"
(float-time
(time-subtract
after-init-time
before-init-time)))
gcs-done)))
;daemon as here https://scripter.co/emacsclient-on-windows/https://scripter.co/emacsclient-on-windows/
;his full setup https://github.com/kaushalmodi/.emacs.d/blob/6c7b77af6ea39fd6e016a873fad763a712547223/setup-files/setup-server.el
(when (equal window-system 'w32)
(setq server-use-tcp t))
;; Below needs to be set before you require 'server
(setq server-auth-dir (let ((dir (concat user-emacs-directory "server_" (format "%s_%s"
emacs-major-version
emacs-minor-version)
"_" (system-name) ; Use the var `system-name' directly
; if using emacs older than 25.1.
"/")))
(make-directory dir
:parents) dir))
(with-eval-after-load 'server (when (equal window-system 'w32)
;; Suppress error "directory ~/.emacs.d/server is unsafe". It is needed
;; needed for the server to start on Windows.
(defun server-ensure-safe-dir (dir)
"Noop"
t)))
(require 'server)
;; Start a server if (server-running-p) does not return t (e.g. if it
;; returns nil or :other)
(or (eq (server-running-p) t)
(server-start))
(require 'substitute)
;; If you like visual feedback on the matching target. Default is nil.
(setq substitute-highlight t)
;; Ifyou want a message reporting the matches that changed in the
;; given context. We don't do it by default.
(add-hook 'substitute-post-replace-hook #'substitute-report-operation)
;; We do not bind any keys. This is just an idea. The mnemonic is
;; that M-# (or M-S-3) is close to M-% (or M-S-5).
(let ((map global-map))
(define-key map (kbd "M-# s") #'substitute-target-below-point)
(define-key map (kbd "M-# r") #'substitute-target-above-point)
(define-key map (kbd "M-# d") #'substitute-target-in-defun)
(define-key map (kbd "M-# b") #'substitute-target-in-buffer))
(setq dired-guess-shell-alist-user '(("\\.\\(mp[34]\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv")))
;; "\\.\\(mp[34]\\|ogg\\|flac\\|webm\\|mkv\\)"
(regexp-opt '("mkv" "mp3" "mp4"))
(use-package
simple-httpd
:ensure t)
(dolist (mode '(eshell-mode-hook fundamental-mode-hook))
(add-hook mode
(lambda ()
(olivetti-mode))))
(vertico-mode 1)
(use-package
orderless
:ensure t
:custom (completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
(global-set-key (kbd "M-o") #'ivy-dispatching-done)
(use-package
saveplace
:init (save-place-mode))
(use-package
which-key
:ensure t
:config (which-key-mode))
;; (defvar my-mode-line-buffer-line-count nil)
;; (make-variable-buffer-local 'my-mode-line-buffer-line-count)
;; (setq-default mode-line-format
;; '(" " mode-line-modified
;; (list 'line-number-mode " ")
;; (:eval (when line-number-mode
;; (let ((str "L%l"))
;; (when (and (not (buffer-modified-p)) my-mode-line-buffer-line-count)
;; (setq str (concat str "/" my-mode-line-buffer-line-count)))
;; str)))
;; " %p"
;; (list 'column-number-mode " C%c")
;; " " mode-line-buffer-identification
;; " " mode-line-modes))
(setq-default mode-line-format '("%e" mode-line-front-space mode-line-mule-info mode-line-client
mode-line-modified mode-line-remote mode-line-auto-compile
mode-line-frame-identification mode-line-buffer-identification " "
(:eval (format-mode-line "%l"))
(vc-mode vc-mode) " " mode-line-modes mode-line-misc-info
mode-line-end-spaces))
(defun my-mode-line-count-lines ()
(setq my-mode-line-buffer-line-count (int-to-string (count-lines (point-min)
(point-max)))))
(add-hook 'find-file-hook #'my-mode-line-count-lines)
(add-hook 'after-save-hook #'my-mode-line-count-lines)
(add-hook 'after-revert-hook #'my-mode-line-count-lines)
(add-hook 'dired-after-readin-hook #'my-mode-line-count-lines)
(require 'iy-go-to-char)
;; (add-to-list 'mc/cursor-specific-vars 'iy-go-to-char-start-pos) wasn't working
;; (define-key xah-fly-command-map (kbd "\\"))
;; (define-key xah-fly-command-map (kbd "'"))
(global-set-key (kbd "C-c f") #'iy-go-to-char)
(global-set-key (kbd "C-c F") #'iy-go-to-char-backward)
(global-set-key (kbd "C-c ;") #'iy-go-to-or-up-to-continue)
(global-set-key (kbd "C-c ,") #'iy-go-to-or-up-to-continue-backward)
(setq emms-player-list '(emms-player-mpv) emms-info-functions '(emms-info-native))
(defun my-dired-mode-hook ()
(when (bound-and-true-p xah-fly-command-mode)
(define-key dired-mode-map (kbd "k") #'dired-narrow-regexp)))
(add-hook 'dired-mode-hook 'my-dired-mode-hook)
(use-package
dired-open
:config
;; Doesn't work as expected!
;;(add-to-list 'dired-open-functions #'dired-open-xdg t)
(setq dired-open-extensions '(("png" . "feh")
("mkv" . "mpv")))) ; FIXME:
;; (dired-open-by-extension); FIXME:
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
(define-key dired-mode-map (kbd "DEL") #'dired-up-directory)
;; (define-key dired-mode-map (kbd "") #'dired-narrow-regexp)
;; (define-key dired-mode-map (kbd "4") #'split-window-horizontally)
(define-key dired-mode-map (kbd "S-<backspace>") #'dired-unmark-backward)
(defun gh/dired-mode-setup ()
"to be run as hook for `dired-mode'."
(interactive)
(setq dired-dwim-target t dired-recursive-copies 'top delete-by-moving-to-trash t hl-line-mode t
dired-listing-switches "-agGXvho --group-directories-first" dired-recursive-deletes 'top)
(dired-hide-details-mode 1))
(defun gh/copy-path ()
"DOCSTRING"
(interactive)
(kill-new default-directory)
(message "'%s' copied to kill-ring" default-directory))
(global-set-key (kbd "C-P") #'gh/copy-path)
;; (add-hook 'calc-window-hook #'xah-fly-insert-mode-activate)
(add-hook 'dired-mode-hook #'gh/dired-mode-setup)
(add-hook 'dired-mode-hook #'xah-fly-command-mode-activate)
(add-hook 'org-capture-mode-hook #'xah-fly-insert-mode-activate)
(add-hook 'org-agenda-mode-hook #'xah-fly-insert-mode-activate)
(defun toggle-buffer-mode ()
"DOCSTRING"
(interactive)
(if (derived-mode-p 'org-mode)
(xah-elisp-mode)
(org-mode)
(org-show-all)))
(global-set-key (kbd "C-<f11>") #'toggle-buffer-mode)
(set-register ?n (cons 'file "c:/Users/George/OrgFiles/notes.org"))
(setq org-capture-templates '(("q" "Emacs question" entry (file+headline "notes.org"
"Emacs questions") "* %?")
;; ("t" "Todooo" entry (file+headline "~/OrgFiles/notes.org" "tototo")
;; "* TODO %?\n %i\n %a")
("j" "Journal" entry (file+datetree "~/OrgFiles/notes.org" "Journal")
"* %?\nEntered on %U\n %i\n %a")
("s" "SuperMemo question" entry (file+headline "~/OrgFiles/notes.org"
"SuperMemo questions")
"* %?")
("f" "Promt for imput" entry (file+headline "demo.org" "our f input")
"* %^{aa|bb|cc} %?")
("p" "Promt for imput" entry (file+headline "demo.org" "our f input")
"* %^{Please write here} %?")
("o" "options for prompt" entry (file+headline "demo.org"
"our f heading")
"* %^{Select option|ONE|TWO|THREE} %?")))
;; M-S-LEFT (org-table-delete-column)
(setq org-directory "~/OrgFiles")
(require 'org-bullets)
(add-hook 'org-mode-hook
(lambda ()
(org-bullets-mode 1)))
(setq org-confirm-babel-evaluate nil)
(require 'org-tempo)
(add-to-list 'org-structure-template-alist '("shg" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(setq org-structure-template-alist
'(("a" . "export ascii")
("c" . "center")
("C" . "comment")
("e" . "emacs-lisp\n")
("E" . "export")
("h" . "export html")
("l" . "export latex")
("q" . "quote")
("s" . "src")
("v" . "verse")))
(global-set-key (kbd "C-c a") #'org-agenda)
(setq-default org-catch-invisible-edits 'error)
(setq org-agenda-files '("~/OrgFiles/Tasks.org" "~/OrgFiles/notes.org"))
(setq org-catch-invisible-edits 'smart)
(setq org-list-demote-modify-bullet '(("+" . "-")
("-" . "+")
("*"
. "-")))
(add-to-list 'org-modules 'org-habit)
(setq org-todo-keywords '((sequence "todo(t)" "|" "delegated(l)" "done(d)")
(sequence "tofix(x)" "|" "fixed(d)")))
(defun check-cell ()
(interactive)
(let ((cell (org-table-get-field)))
(if (string-match "[[:graph:]]" cell)
(org-table-blank-field)
(insert "X")
(org-table-align))
(org-table-next-row)))
;; (org-table-move-cell-up '(0 . 0))
(define-key org-mode-map (kbd "M-n") #'check-cell)
(define-key org-mode-map (kbd "M-S-RET") #'org-insert-todo-heading)
(defun gh/flat-view ()
"flat view of current directory"
(interactive)
(if (equal dired-actual-switches "-al")
(dired default-directory "-lR")
(dired default-directory "-al")))
;; (defun toggle-buffer-mode ()
;; "DOCSTRING"
;; (interactive)
;; (if (derived-mode-p 'org-mode)
;; (xah-elisp-mode)
;; (org-mode)
;; (org-show-all)))
(define-key dired-mode-map (kbd "<f10>") #'gh/flat-view)
(defun gh/kill-line-into-insert-mode ()
"kill line into insert mode retain indenting of previous line"
(interactive)
(xah-cut-line-or-region)
;; (previous-line)
;; (xah-end-of-line-or-block)
;; (newline)
(open-line 1)
(xah-fly-insert-mode-activate))
(define-key xah-fly-command-map (kbd "X") #'gh/kill-line-into-insert-mode)
;; (define-key xah-fly-command-map (kbd "k") #'isearch-forward-regexp)
(defun gh/no-kill-ring-if-blank (str)
"DOCSTRING"
(interactive)
(unless (string-blank-p str) str))
(setq kill-transform-function #'gh/no-kill-ring-if-blank)
(defun my-q-insert-or-quit-window
(&optional
n)
(interactive "p")
(if buffer-read-only (quit-window)
(xah-reformat-lines)))
(defun gh/paste-clipboard-into-buffer ()
"Paste contents of clipboard into current buffer"
(interactive)
(xah-new-empty-buffer)
(yank))
(defun gh/delete-all-above-cursor ()
"DOCSTRING"
(interactive)
(set-mark (point))
(beginning-of-buffer)
(xah-cut-line-or-region)
(delete-forward-char 1))
(defun gh/delete-all-below-cursor ()
"DOCSTRING"
(interactive)
(set-mark (point))
(end-of-buffer)
(xah-cut-line-or-region)
(previous-line)
(next-line))
(defun fc-eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil (prin1 (eval (read (current-kill 0)))
(current-buffer))
(error
(message "Invalid expression")
(insert (current-kill 0)))))
(global-set-key (kbd "C-c e") #'fc-eval-and-replace)
(global-set-key (kbd "C-M-\\") #'gh/delete-all-above-cursor)
(global-set-key (kbd "C-M-.") #'gh/delete-all-below-cursor)
(global-set-key (kbd "C-n") #'gh/paste-clipboard-into-buffer)
(define-key xah-fly-command-map (kbd "q") #'my-q-insert-or-quit-window)
(defun lorem ()
"Insert a lorem ipsum."
(interactive)
(insert "Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do " "eiusmod tempor incididunt \nut labore et dolore magna aliqua.
Ut enim ad " "minim veniam, quis nostrud\n exercitation ullamco laboris
nisi ut " "aliquip ex ea commodo cons\nequat. Duis aute irure dolor in
" "reprehenderit in voluptate\n velit esse cillum dolore eu fugiat
nulla " "pariatur. Excepteur sint o\nccaecat cupidatat non proident,
sunt in " "culpa qui officia deserunt\n mollit anim id est laborum."))
(defun yt (word)
(interactive "sSearch Terms: ")
(browse-url (format "https://www.youtube.com/results?search_query=%s"
word)))
(defun my-dabbrav-repeat(kbd cmd)
;; Stolen from repeat.el it works but idk if there is any side effects- a quick test it seems okay.
(set-transient-map (let ((map (make-sparse-keymap)))
(define-key map kbd cmd) map)))
(defun my-dabbrav-undo()
"Helper function for `my-dabbrav-expand'."
(interactive)
(call-interactively 'undo)
(my-dabbrav-repeat (kbd "/") #'my-dabbrav-undo))
(defun my-dabbrav-expand()
"When bound this will `dabbrav-expand', and pressing '/' will
undo."
(interactive)
(call-interactively 'dabbrev-expand)
(my-dabbrav-repeat (kbd "/") 'my-dabbrav-undo))
;; You only have to set M-/ `my-dabbrav-expand' will take care of the rest.
(global-set-key (kbd "M-\\") #'my-dabbrav-expand)
(global-set-key (kbd "C-s") #'swiper)
(require 'multiple-cursors)
(define-key mc/keymap (kbd "<return>") nil)
;dhm
(global-set-key (kbd "M-n") #'mc/mark-all-dwim)
(global-set-key (kbd "M-l") #'mc/edit-lines)
(global-set-key (kbd "M-m") #'mc/mark-all-like-this)
(global-set-key (kbd "M-u") #'mc/mark-previous-like-this)
(global-set-key (kbd "M-e") #'mc/mark-next-like-this)
(global-set-key (kbd "M-y") #'mc/skip-to-previous-like-this)
(global-set-key (kbd "M-i") #'mc/skip-to-next-like-this)
(global-set-key (kbd "M-'") #'mc/insert-numbers)
;(global-set-key (kbd "S-<escape>") #'mc/keyboard-quit)
(global-set-key (kbd "M-a") #'mc/mark-all-dwim)
(global-set-key (kbd "M-s") #'mc/mark-all-like-this)
(global-set-key (kbd "M-<up>") #'mc/mark-previous-like-this)
(global-set-key (kbd "M-<down>") #'mc/mark-next-like-this)
(global-set-key (kbd "M-S-<up>") #'mc/skip-to-previous-like-this)
(global-set-key (kbd "M-S-<down>") #'mc/skip-to-next-like-this)
(require 'rainbow-delimiters)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(setq buffer-offer-save t)
;; ("B" backward-sexp)
;; ("A" beginning-of-defun)
;; ("E" end-of-defun)
;; ("W" kill-ring-save)
;; ("t" transpose-chars)
;; ("P" elpy-nav-move-line-or-region-up)
;; ("N" elpy-nav-move-line-or-region-down)
;; ("D" duplicate-current-line-or-region)
;; ("z" zap-to-char)
;; ("q" nil)
;; ("r" backward-delete-char-untabify)
;; ("l" recenter-top-bottom)
;; ("," set-mark-and-deactive)
;; ("m" counsel-mark-ring :color blue)
;; )
;; hydra ideas: avy, mark, highlighting and markdown
;; (setq vc-handled-backends '(Git))
(define-key diff-mode-map (kbd "M-b") #'(diff-hunk-prev))
(define-key diff-mode-map (kbd "M-<down>") #'(diff-hunk-next))
(setq str-list '(gazelle giraffe lion tiger))
;(setq exec-path (default-value 'exec-path))
(defun reset-keybinding-for-command-at-point ()
"Reset the keybinding for the command under the point to a new keybinding."
(interactive)
(let ((cmd (symbol-at-point)))
(when (commandp cmd)
(let ((key (where-is-internal cmd nil t)))
(when key
;; Unset the current keybinding for the command
(global-unset-key key)
;; Prompt the user to enter a new keybinding for the command
(let ((new-key (read-key-sequence "Enter new keybinding: ")))
(global-set-key new-key cmd)
(message "Keybinding for '%s' reset to '%s'." cmd (key-description new-key))))))))