-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
1308 lines (1065 loc) · 51.3 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
;; -*- coding: utf-8 -*-
;;; init.el --- Where all the magic begins
;;
;; Part of the Emacs Starter Kit
;;
;; This is the first thing to get loaded.
;;,-----------------------------
;;| Technomancy's recommendation
;;`-----------------------------
;; This avoids many
;; [common](https://glyph.twistedmatrix.com/2015/11/editor-malware.html)
;; [problems](https://github.com/melpa/melpa/issues/2342) with `package.el`, and
;; it allows you to seamlessly roll back upgrades which introduce breaking
;; changes as well as guaranteeing that all machines you work on share the same
;; versions.
;; in:
;; /media/dgm/blue/documents/programming/emacs/CoolEmacsGuys/technomancy/emacs-starter-kit/README.markdown
;; where it says "ini.el", it originally says "my-autoload.el".
;; (defun pnh-reinit-libs ()
;; (interactive)
;; (let ((generated-autoload-file (concat user-emacs-directory "init.el")))
;; (dolist (d (directory-files (concat user-emacs-directory "lib") t "^[^\.]"))
;; (dolist (f (directory-files d t "\\.el$"))
;; (byte-compile-file f))
;; (update-directory-autoloads d))))
;; (dolist (l (directory-files (concat user-emacs-directory "lib") nil "^[^\.]"))
;; (add-to-list 'load-path (concat user-emacs-directory "lib/" l))
;; (autoload (internl) (concat l ".el")))
;; (when (not (file-exists-p (concat user-emacs-directory "init.el")))
;; (pnh-reinit-libs))
;; (load (concat user-emacs-directory "init.el"))
;; DGM: I've commented out because I've created the "lib" directory BUT I don't know what is meant to be in the
;; "my-autoload.el" file
;; But this produces this:
;; Warning (initialization): An error occurred while loading ‘/home/dgm/.emacs.d/init.el’:
;; error: Recursive load, /home/dgm/.emacs.d/init.el, /home/dgm/.emacs.d/init.el, /home/dgm/.emacs.d/init.el, /home/dgm/.emacs.d/init.el, /home/dgm/.emacs.d/init.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; John Wiegley's setup tweaked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst emacs-start-time (current-time))
(defvar file-name-handler-alist-old file-name-handler-alist)
(setq package-enable-at-startup nil
file-name-handler-alist nil
message-log-max 16384
gc-cons-threshold 402653184 ;; 402.653.184
gc-cons-percentage 0.6
auto-window-vscroll nil)
;;; original bit by JW (though with =gc-cons-percentage= on)
;;; Alphapapa suggests 10 or 100MB (100000000) at most.
;;; Another use says 300\MBOX{}
;;; Originally, I found that 3000000 (3 MB) was okay
(add-hook 'after-init-hook
`(lambda ()
(setq file-name-handler-alist file-name-handler-alist-old
gc-cons-threshold (* 2 1000 1000)) ;; originally 10MB or 10000000 or 10.000.000
;; originally. This setting is by DW
;;gc-cons-percentage 0.1)
(garbage-collect)) t)
;; DW: Now set the garbage collection threshold lower. 2MB
;; (setq gc-cons-threshold (* 5 1000 1000))
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;; However, I comment it out because with emacs 27 we get a message
;; saying this is not needed any more.
;; (package-initialize)
;; (require 'cl) ;; deprecated
(require 'cl-lib)
(require 'ffap)
(require 'ansi-color)
;; Native compilation
(when (string= (system-name) "lenovo")
(setq package-native-compile t))
(when (fboundp 'native-compile-async)
(setq comp-deferred-compilation t
comp-deferred-compilation-black-list '("/mu4e.*\\.el$")))
;; Use 6 of the 8 cores for asynchronous compilation
(setq comp-async-jobs-number 6)
;; Compile everything under these directories using 6 cores
;; (native-compile-async "~/.emacs.d/" 6 t)
;; (native-compile-async "~/.emacs.d/elpa/" 6 t)
;;; DGM on 5th August 2019 trying to fix <(file-error
;;; "https://elpa.gnu.org/packages/archive-contents" "Bad Request")>
;;; Tip from:
;;; https://www.reddit.com/r/emacs/comments/cdei4p/failed_to_download_gnu_archive_bad_request/
;;; Apparently it is a bug in emacs
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;;; Tip 1 from Ambrevar's init.el
;; I guess responsiveness is improved by a low gc-cons-threshold, but
;; speed is improved by a high gc-cons-threshold.
;; from: https://www.reddit.com/r/emacs/comments/55ork0/is_emacs_251_noticeably_slower_than_245_on_windows/
;;; Speed up init.
;;Temporarily reduce garbage collection during startup. Inspect `gcs-done'.
;; (defun ambrevar/reset-gc-cons-threshold ()
;; (setq gc-cons-threshold (car (get 'gc-cons-threshold 'standard-value))))
;; ;; 511 (setq gc-cons-threshold (* 64 1024 1024))
;; ;;(setq gc-cons-threshold (* 64 1024 1024))
;; (setq gc-cons-threshold 800000)
;; (add-hook 'after-init-hook 'ambrevar/reset-gc-cons-threshold)
;; ;;Temporarily disable the file name handler.
;; (setq default-file-name-handler-alist file-name-handler-alist)
;; (setq file-name-handler-alist nil)
;; (defun ambrevar/reset-file-name-handler-alist ()
;; (setq file-name-handler-alist
;; (append default-file-name-handler-alist
;; file-name-handler-alist))
;; (cl-delete-duplicates file-name-handler-alist :test 'equal))
;; (add-hook 'after-init-hook 'ambrevar/reset-file-name-handler-alist)
;; (setq gc-cons-percentage 0.1)
;; ;(run-with-idle-timer 5 t #'garbage-collect)
;; (setq garbage-collection-messages t)
;;; Tip 2 from Ambrevar's init.el
;;; Avoid the "loaded old bytecode instead of newer source" pitfall.
(setq load-prefer-newer t)
(setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))
(setq dotfiles-dir (file-name-directory (or load-file-name (buffer-file-name))))
(setq autoload-file (concat dotfiles-dir "loaddefs.el"))
;; (setq package-user-dir (concat dotfiles-dir "elpa")) ;; if enabled
;; this with exwm, then it blocks emacs
;; original config about custom-file
;; (setq custom-file (concat dotfiles-dir "custom.el"))
;; (add-to-list 'load-path (expand-file-name
;; "lisp" (expand-file-name
;; "org" (expand-file-name
;; "src" dotfiles-dir))))
;; daviwil's alternative. Apparently, he got it from Ambrevar too!
;; Keep customization settings in a temporary file (thanks Ambrevar!)
(setq custom-file
(if (boundp 'server-socket-dir)
(expand-file-name "custom.el" server-socket-dir)
(expand-file-name (format "emacs-custom-%s.el" (user-uid)) temporary-file-directory)))
(load custom-file t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; use-package ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;From https://github.com/danielmai/.emacs.d/blob/master/init.el
;;; Set up package. Originally in =starter-kit.org= but when I
;;; downloaded everything anew from the github repository =use-package=
;;; didn't work until I moved this here.
;;; DGM on 2 Oct 2019: changing all http's to https as per: https://www.reddit.com/r/emacs/comments/aug9in/failed_to_verify_signature_archivecontentssig/
;;; DGM on 6 nov 2019: added this line to be able to load emacs or else
;;; I had a signature fail message. I have to solve this
(setq package-check-signature nil)
;; We require the <package.el> package to bring in the environment all the package management functions
(require 'package)
(setq package-archives '(
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("gnu" . "https://elpa.gnu.org/packages/")))
;; From DW. In the very first load, check if there is a package archive cloned
;; in your computer. Unless the archive exists, refresh the package list so that
;; future calls to packages functions know which packages you're referring to.
(unless package-archive-contents
(package-refresh-contents))
;; Initialise the packages, avoiding a re-initialisation?
(when (boundp 'package-pinned-packages)
(setq package-pinned-packages
'((org-plus-contrib . "org"))))
;; Emacs 27: Warning (package): Unnecessary call to ‘package-initialize’ in init
;; file. Typically this initializes the package system and preprares it to be
;; used.
;; (package-initialize)
;;; Add support to package.el for pre-filtering available packages
(defvar package-filter-function nil
"Optional predicate function used to internally filter packages used by package.el.
The function is called with the arguments PACKAGE VERSION ARCHIVE, where
PACKAGE is a symbol, VERSION is a vector as produced by `version-to-list', and
ARCHIVE is the string name of the package archive.")
(defadvice package--add-to-archive-contents
(around filter-packages (package archive) activate)
"Add filtering of available packages using `package-filter-function', if non-nil."
(when (or (null package-filter-function)
(funcall package-filter-function
(car package)
(funcall (if (fboundp 'package-desc-version)
'package--ac-desc-version
'package-desc-vers)
(cdr package))
archive))
ad-do-it))
(defvar melpa-exclude-packages
;; '(slime magit)
'()
"Don't install Melpa versions of these packages.")
;; Don't take Melpa versions of certain packages
(setq package-filter-function
(lambda (package version archive)
(and
(not (memq package '(eieio)))
(or (not (string-equal archive "melpa"))
(not (memq package melpa-exclude-packages))))))
;; Make sure `use-package' is available (used to configure the rest of the packages)
;; Bootstrap use-package
;; Install use-package if it's not already installed.
(unless (or (package-installed-p 'use-package)
(package-installed-p 'diminish))
(package-refresh-contents)
(package-install 'use-package)
(package-install 'diminish))
;; Configure `use-package' prior to loading it.
(setq use-package-enable-imenu-support t)
(setq use-package-minimum-reported-time 0)
(setq use-package-verbose t)
(setq use-package-compute-statistics t)
;; From use-package README
(eval-when-compile
(require 'use-package))
(require 'use-package)
(setq-default use-package-minimum-reported-time 0)
(setq use-package-minimum-reported-time 0)
(eval-and-compile (setq-default use-package-verbose t))
(eval-and-compile (setq use-package-verbose t))
(setq use-package-always-ensure t) ;; The :ensure keyword causes the package(s) to be installed automatically if not already present on your system
;; Other options from Prot(eval-and-compile
;; (setq use-package-always-ensure nil)
;; (setq use-package-always-defer nil)
;; (setq use-package-always-demand nil)
;; (setq use-package-expand-minimally nil)
;; More Prot Stuff
;; The following is VERY IMPORTANT. Write hooks using their real name
;; instead of a shorter version: after-init ==> `after-init-hook'.
;;
;; This is to empower help commands with their contextual awareness,
;; such as `describe-symbol'.
;; (setq use-package-hook-name-suffix nil)
;;; Garbage collection the automated way
;;; my system collapsed when I used it!!
;; (use-package gcmh
;; :ensure t
;; :init
;; (gcmh-mode 1))
(use-package bind-key)
;; tip from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810640
(setq tramp-ssh-controlmaster-options nil)
(setq-default tramp-ssh-controlmaster-options nil)
;; tramp package from
;; https://github.com/danielmai/.emacs.d/blob/master/config.org
;; TRAMP (Transparent Remote Access, Multiple Protocols) is a package for editing remote files, similar to AngeFtp or efs. Whereas the others use FTP to connect to the remote host and to transfer the files, TRAMP uses a remote shell connection (rlogin, telnet, ssh). It can transfer the files using rcp or a similar program, or it can encode the file contents (using uuencode or base64) and transfer them right through the shell connection.
;; Tramp was formerly called RCP or rcp.el.
(use-package tramp
:defer t)
;; Do this to quicken startup:
;; https://emacs.stackexchange.com/questions/14708/debugging-slowness-in-init-file-not-hostname-related
;; because I was getting the startup process tripped until I did this.
;;;;;;;;;; commented out by dgm on January the 10th as i rather go for
;;;;;;;;;;;; the nil option
;;;;;;;;;;;; (setq tramp-ssh-controlmaster-options "")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; async ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; activate for all packages. Advised in Helm's wiki
;; also, uncle dave says: Lets us use asynchronous processes wherever
;; possible, pretty useful.
(use-package async
:init (dired-async-mode 1)
:config
(setq async-bytecomp-allowed-packages '(all))
)
;; Deal with the "Failed to verify signature archive-contents.sig"
;; (use-package gnu-elpa-keyring)
(use-package gnu-elpa-keyring-update)
;; (setq package-check-signature nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; exwm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Sacha says: (server-start) permits the use of emacsclient,
;; emacsclient, and org-protocol.
;; emacs --daemon, which starts a server automatically but with --daemon, Emacs doesn't start off
;; in a graphical environment.
;; dgm comments out on Nov 13th 2019 to try and stop emacs from
;; creating new frames
;; (server-start)
(require 'server)
(or (server-running-p) (server-start))
;; When stating the client from .xinitrc, =save-buffer-kill-terminal= will =force-kill= Emacs before it can run through =kill-emacs-hook=.
(global-set-key (kbd "C-x C-c") 'save-buffers-kill-emacs)
;; (defun efs/exwm-update-class ()
;; (exwm-workspace-rename-buffer exwm-class-name))
(use-package cl-generic)
(use-package xelb)
(use-package exwm
:init
(load "/home/dgm/.emacs.d/src/ambrevar/functions.el")
(require 'functions)
(defun ambrevar/exwm-rename-buffer-to-title ()
(exwm-workspace-rename-buffer exwm-title))
(add-hook 'exwm-update-title-hook 'ambrevar/exwm-rename-buffer-to-title)
(add-hook 'exwm-floating-setup-hook 'exwm-layout-hide-mode-line)
(add-hook 'exwm-floating-exit-hook 'exwm-layout-show-mode-line)
(defun ambrevar/exwm-start-in-char-mode ()
(when (string-prefix-p "emacs" exwm-instance-name)
(exwm-input-release-keyboard (exwm--buffer->id (window-buffer)))))
(add-hook 'exwm-manage-finish-hook 'ambrevar/exwm-start-in-char-mode)
(defun exwm-async-run (name)
(interactive)
(start-process name nil name))
(defun daedreth/launch-browser ()
(interactive)
(exwm-async-run "chromium"))
;; recall it doesn't prompt for anything. You just have to enter your password.
(defun daedreth/lock-screen ()
(interactive)
(exwm-async-run "slock"))
(defun ambrevar/exwm-start (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command))
(defun rotate-windows ()
"Rotate your windows" (interactive) (cond ((not (> (count-windows) 1)) (message "You can't rotate a single window!"))
(t
(setq i 1)
(setq numWindows (count-windows))
(while (< i numWindows)
(let* (
(w1 (elt (window-list) i))
(w2 (elt (window-list) (+ (% i numWindows) 1)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2))
)
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1)
(setq i (1+ i)))))))
;; When window "class" updates, use it to set the buffer name
;; (add-hook 'exwm-update-class-hook #'efs/exwm-update-class)
;; Wallpaper function
(defun efs/set-wallpaper ()
(interactive)
(start-process-shell-command
"feh" nil "feh --bg-scale /home/dgm/Pictures/500350.jpg"))
;; "feh" nil "feh --bg-scale /home/dgm/Pictures/500350.jpg"
;; "feh" nil "feh --bg-scale /home/dgm/Pictures/fedora-jules-verne-nautilus-submarine-1920x1080.jpg"
;; Mordickay and Rigby
;; Function to run apps in background
(defun efs/run-in-background (command)
(let ((command-parts (split-string command "[ ]+")))
(apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
;; External apps to run before EXWM starts
(efs/run-in-background "nm-applet")
(efs/run-in-background "pasystray")
(efs/run-in-background "blueman-applet")
;; (efs/run-in-background "redshift")
;; ("Evince" (exwm-workspace-move-window 3))
;; ("okular" (exwm-workspace-move-window 3))
(defun efs/configure-window-by-class ()
(interactive)
(pcase exwm-class-name
("Firefox-esr" (exwm-workspace-move-window 3))
("Chromium" (exwm-workspace-move-window 3))
("Spotify" (exwm-workspace-move-window 3)) ;; don't know why it doesn't work
;; for Spotify
("Gnome-terminal" (exwm-workspace-move-window 0))
("Amule" (exwm-workspace-move-window 0))
("Arandr" (exwm-workspace-move-window 0))))
(defun efs/update-displays ()
(efs/run-in-background "autorandr --change --force")
;; (efs/set-wallpaper)
(message "Display config: %s"
(string-trim (shell-command-to-string "autorandr --current"))))
(defun efs/exwm-init-hook ()
;; Make workspace 1 be the one where we land at startup
(exwm-workspace-switch-create 4))
(require 'exwm-config)
;; (require 'exwm-systemtray)
(require 'exwm-randr)
;; necessary to configure exwm manuall
:config
;; fringe size, most people prefer 1 (uncle dave's setup)
;; (fringe-mode 3) ;; commented out on 14 march 21 to use a different setting
;; in <starter-kit-misc.org>
(exwm-config-default)
(setq window-divider-default-bottom-width 2
window-divider-default-right-width 2)
(window-divider-mode)
;; Polybar is in charge of the tray now
;; (exwm-systemtray-enable)
;; (setq exwm-systemtray-height 16)
(setq exwm-workspace-number 10
exwm-layout-show-all-buffers t ;; allow an EXWM buffer to be displayed
;; in any workspace. If I choose it, then I move that buffer to the
;; workspace from which I am calling it (changed to t on 11 april 2021).
exwm-workspace-show-all-buffers t) ;; if t, allows showing buffers on
;; other workspaces. (changed to t on 11 april 2021).
;; But DW has it set to t.
;; What DW is trying to do is to automatically move windows between workspaces.
;; On 08/01/21
;; I change it to nil as having it set to t doesn't let me call firefox
;; windows in workspaces other than 3
;; When EXWM starts up, do some extra confifuration
(add-hook 'exwm-init-hook #'efs/exwm-init-hook)
;; For global bindings that work even in X buffers, use <exwm-input-set-key>
;; Also, these keybindings work while your're running EXWM (for normal EXWM
;; buffers. Not for external buffers). You don't have to
;; re-start it, as you would if you used exwm-input-global-keys (which updates
;; only after you restart exwm).
;; Commented by DGM on 25 dic 2020
;; other workspaces.
;; (dotimes (i 10)
;; (exwm-input-set-key (kbd (format "s-%d" i))
;; `(lambda ()
;; (interactive)
;; (exwm-workspace-switch-create ,i))))
;; Configure windows as they're created
(add-hook 'exwm-manage-finish-hook #'efs/configure-window-by-class)
;; Media keys
(exwm-input-set-key
(kbd "<XF86AudioRaiseVolume>")
(lambda ()
(interactive) (start-process-shell-command
"pactl" nil "pactl set-sink-volume 0 +5% && pactl set-sink-volume 1 +5%")))
(exwm-input-set-key
(kbd "<XF86AudioLowerVolume>")
(lambda ()
(interactive) (start-process-shell-command
"pactl" nil "pactl set-sink-volume 0 -5% && pactl set-sink-volume 1 -5%")))
(exwm-input-set-key
(kbd "<XF86AudioMute>")
(lambda ()
(interactive) (start-process-shell-command
"pactl" nil "pactl set-sink-mute 0 toggle && pactl set-sink-mute 1 toggle")))
(defun display-backlight-brightness ()
(message "Backlight at %s"
(car (split-string
(shell-command-to-string "xbacklight -get")
"\\." t))))
(exwm-input-set-key
(kbd "<XF86MonBrightnessUp>")
(lambda ()
(interactive)
(start-process-shell-command
"xbacklight" nil "xbacklight -inc 5")
(display-backlight-brightness)
))
(exwm-input-set-key
(kbd "<XF86MonBrightnessDown>")
(lambda ()
(interactive)
(start-process-shell-command
"xbacklight" nil "xbacklight -dec 5")
(display-backlight-brightness)))
;; possibly the culprit of not seeint the minibuffer prompt??
;; (set-frame-parameter (selected-frame) 'fullscreen 'maximized)
;; (add-to-list 'default-frame-alist '(fullscreen . maximized))
;; Redshift off
(exwm-input-set-key (kbd "s-\)")
(lambda () (interactive) (start-process-shell-command "redshift" nil "redshift" "-x")))
;; Redshift no
;; -PO 3500 -m randr
(exwm-input-set-key (kbd "s-\(")
(lambda () (interactive) (start-process-shell-command "redshift" nil "redshift" "-O 3500 -P")))
;; I comment this out as I think the next caters for it.
;; (push ?\s- exwm-input-prefix-keys)
;; These keys should always pass through to Emacs.
(setq exwm-input-prefix-keys
'(?\C-x
?\C-u
?\C-h
?\C-\;
?\M-x
?\M-:
?\C-\M-j ;; Buffer list (ivy)
?\C-\M-k ;; Browser list
?\s-o ;; Buffer list (helm)
?\s-e ;; Launch external programs
;;?\M-s-up ;; enlarge-window. Don't know why this syntax doesn't work
;;?\M-s-down ;; shrink-window
?\M-&
?\M-`
?\s-\;
?\C-q))
;; (add-to-list 'exwm-input-prefix-keys ?\C-q)
;; Ctrl+Q will enable the next key to be sent directly
(define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)
(setq exwm-input-simulation-keys
'(
;; movement
([?\C-b] . [left])
([?\M-b] . [C-left])
([?\C-f] . [right])
([?\M-f] . [C-right])
([?\C-p] . [up])
([?\C-n] . [down])
([?\C-a] . [home])
([?\C-e] . [end])
([?\M-v] . [prior])
([?\C-v] . [next])
([?\C-d] . [delete])
([?\C-k] . [S-end delete])
([?\M-h] . [S-end select])
([?\M-d] . [C-S-right ?\C-x])
([M-backspace] . [C-S-left ?\C-x])
;; escape
([?\C-g] . [escape])
;; cut/paste.
([?\C-w] . [?\C-x])
([?\M-w] . [?\C-c])
([?\C-y] . [?\C-v])
;; search
([?\C-s] . [?\C-f])))
;; Set up global key kindings. These always work, no matter the input state!
;; Keep in mind that changing this list after EXWM initializes has no effect.
;; Though it is true that this other way of doing it worked as well
;; (exwm-input-set-key (kbd "s-<left>") #'windmove-left)
;; (exwm-input-set-key (kbd "s-<down>") #'windmove-down)
;; (exwm-input-set-key (kbd "s-<up>") #'windmove-up)
;; (exwm-input-set-key (kbd "s-<right>") #'windmove-right)
;; (exwm-input-set-key (kbd "s-&") #'ambrevar/exwm-start)
;; (exwm-input-set-key (kbd "s-:") #'ambrevar/toggle-window-split)
;; (exwm-input-set-key (kbd "s-;") #'rotate-windows)
(setq exwm-input-global-keys
`(
;; Reset to line mode (C-c C-k switches to char-mode via
;; exwm-input-release-keyboard
([?\s-r] . exwm-reset)
;; Move between windows
([s-left] . windmove-left)
([s-right] . windmove-right)
([s-up] . windmove-up)
([s-down] . windmove-down)
;; ([s-prior] . rotate-windows)
;; launch applications via shell command
([?\s-&] . ambrevar/exwm-start)
([?\s-w] . exwm-workspace-switch)
([?\s-:] . ambrevar/toggle-window-split)
([?\s-\;] . rotate-windows) ;; este no funciona bien, no se por que.
;; 's-N': Switch to certain workspace with Super (Win) plus a number
;; (0-9)
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 9))))
(exwm-enable)
;; (start-process-shell-command "xrandr" nil "xrandr --output eDP-1 --mode 1366x768 --pos 1920x312 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal");
;; xrandr commented out as now <autorandr> takes care of all this.
(when (string= (system-name) "toshiba")
(exwm-randr-enable)
(start-process-shell-command "xrandr" nil "xrandr --output eDP-1 --mode 1366x768 --pos 1920x312 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal")
;; (setq exwm-randr-workspace-monitor-plist
;; '(0 "eDP-1"))
;; React to display connectivity changes, do initial display update
(add-hook 'exwm-randr-screen-change-hook #'efs/update-displays)
(efs/update-displays))
(when (string= (system-name) "lenovo")
(exwm-randr-enable)
(start-process-shell-command "xrandr" nil "xrandr --dpi 270 --output eDP-1 --primary --mode 3840x2160 --pos 0x0 --rotate normal")
;; (when (string= (system-name) "lenovo")
;; (exwm-randr-enable)
;; (start-process-shell-command "xrandr" nil "--dpi 270 --fb 7680x4320 \
;; --output eDP-1 --mode 3840x2160 --pos 0x0 --rotate normal \
;; --output HDMI-1-0 --primary --mode 1920x1080 --scale 2x2 --pos 3840x0 --rotate normal")
;; React to display connectivity changes, do initial display update
(add-hook 'exwm-randr-screen-change-hook #'efs/update-displays)
(efs/update-displays))
;; for officePC
(when (string=(system-name) "officePC")
(exwm-randr-enable)
;;(setq exwm-randr-workspace-output-plist '(0 "VGA1"))
(setq exwm-randr-workspace-monitor-plist '(0 "HDMI-1"))
(add-hook 'exwm-randr-screen-change-hook
(lambda ()
(start-process-shell-command
;; "xrandr" nil "xrandr --output HDMI-2 --left-of LVDS1 --auto")))
"xrandr" nil "xrandr --output HDMI-1 --auto")))
(defun exwm-change-screen-hook ()
(let ((xrandr-output-regexp "\n\\([^ ]+\\) connected ")
default-output)
(with-temp-buffer
(call-process "xrandr" nil t nil)
(goto-char (point-min))
(re-search-forward xrandr-output-regexp nil 'noerror)
(setq default-output (match-string 1))
(forward-line)
(if (not (re-search-forward xrandr-output-regexp nil 'noerror))
(call-process "xrandr" nil nil nil "--output" default-output "--auto")
(call-process
"xrandr" nil nil nil
"--output" (match-string 1) "--primary" "--auto"
"--output" default-output "--off")
(setq exwm-randr-workspace-output-plist (list 0 (match-string 1))))))))) ;;; este parentesis cierra el call a use-package to install exwm
;; (use-package exwm-edit)
;; Check for start-up errors. See =~/.profile=
(let ((error-logs (directory-files "~" t "errors.*log$")))
(when error-logs
(warn "Error during system startup. See %s." (mapconcat 'identity error-logs ", "))
(when (daemonp)
;; Non-daemon Emacs already brings up the *Warning* buffer.
(setq initial-buffer-choice
(lambda () (get-buffer "*Warnings*"))))))
(use-package delight)
;;; changed to <nil> on March, 15th, 2021
;;; debug options from https://github.com/ch11ng/exwm/wiki
(setq debug-on-error nil)
;; (setq debug-on-quit t)
(setq edebug-all-forms nil)
;; ;; Common Lisp compatability
(require 'cl-lib)
;; ;; Temporary workaround for eshell bug in 24.3.1
;; ;; http://zpcat.blogspot.com/2013/08/configure-eshell-mode-after-upgrade.html
(require 'esh-mode)
;; ;; Package Locations
(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
(let* ((my-lisp-dir "~/.emacs.d/")
(default-directory my-lisp-dir))
;; (setq load-path (cons my-lisp-dir load-path))
(normal-top-level-add-subdirs-to-load-path)))
;; ;; Load up Org Mode and Babel
;; ;; load up the main file
;; ;; org-mode windmove compatibility
(require 'org)
(org-babel-load-file (expand-file-name "starter-kit.org" dotfiles-dir))
;; This tells Emacs to open all .org files in org-mode (http://sachachua.com/blog/2007/12/emacs-getting-things-done-with-org-basic/)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
;;; Higher garbage collection threshold
;; (setq gc-cons-threshold 20000000)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;; The Power of UTF8 ;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Enable UTF-8 by default. From: lopez-ibanez.eu/dotemacs.html
(prefer-coding-system 'utf-8)
;;; other stuff from https://github.com/izahn/emacs-starter-kit
;;; kjh says that setting this coding system prevents emacs from choking on melpa file listings
;;; see also https://masteringemacs.org/article/working-coding-systems-unicode-emacs
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; backwards compatibility as default-buffer-file-coding-system
;; is deprecated in 23.2. (Petersen's way. I commented it out now and
;; leave it as it was originally)
;; (if (boundp 'buffer-file-coding-system)
;; (setq-default buffer-file-coding-system 'utf-8)
;; (setq default-buffer-file-coding-system 'utf-8))
;; originally I had (setq buffer-file-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq buffer-file-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8)
;; Treat clipboard input as UTF-8 string first; compound text next, etc.
;; (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;; next version as in Sacha Chua's dotfiles
(when (display-graphic-p)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
;; UTF-8 as default encoding (permanently choose a encoding system in
;; emacs for opening and saving). See http://ergoemacs.org/emacs/emacs_encoding_decoding_faq.html
(set-language-environment 'utf-8)
(setq locale-coding-system 'utf-8)
(unless (eq system-type 'windows-nt)
(set-selection-coding-system 'utf-8))
;; DGM on 4 October 2019 following Bern Hansen
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
;; DGM on 3 December 2020: default input method
;; tip from: https://emacs.stackexchange.com/questions/418/setting-and-activating-the-default-input-method
(setq default-input-method "spanish-prefix")
(defvar use-default-input-method t)
(make-variable-buffer-local 'use-default-input-method)
(defun activate-default-input-method ()
(interactive)
(if use-default-input-method
(activate-input-method default-input-method)
(inactivate-input-method)))
(add-hook 'after-change-major-mode-hook 'activate-default-input-method)
(add-hook 'minibuffer-setup-hook 'activate-default-input-method)
(defun inactivate-default-input-method ()
(setq use-default-input-method nil))
(add-hook 'c-mode-hook 'inactivate-default-input-method)
(add-hook 'prog-mode-hook 'inactivate-default-input-method)
;;;;;;; dgm on 13 December 2018 to try and not get the conflict with utf-8-emacs
;; from https://stackoverflow.com/questions/24904208/emacs-windows-org-mode-encoding
;; (modify-coding-system-alist 'file "" 'utf-8-unix) ;; this is the line that the guys in stackoverflow say fix everything
;; (setq coding-system-for-read 'utf-8)
;; (setq coding-system-for-write 'utf-8)
;;; Tuhdo's setup for the records
;; (set-terminal-coding-system 'utf-8)
;; (set-keyboard-coding-system 'utf-8)
;; (set-language-environment "UTF-8")
;; (prefer-coding-system 'utf-8)
;; Note in =starter-kit-org.org= there are two more lines on the coding system for the org mode case.
;; other stuff from
;; https://superuser.com/questions/410100/how-to-make-emacs-accept-utf-8-from-the-keyboard
;; (setq default-process-coding-system '(utf-8-unix . utf-8-unix))
;; (setq default-sendmail-coding-system 'utf-8-unix)
;;;;;;;;;;;;;;;;;;;;;;;;;;; PATH ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; https://github.com/purcell/exec-path-from-shell
(use-package exec-path-from-shell)
(setq-default exec-path-from-shell-arguments nil)
(setq exec-path-from-shell-arguments nil)
(setq exec-path-from-shell-check-startup-files t)
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
;;;;;;;;;;;;;;;;;;;;;;;;
;; Autoloads: Dropbox ;;
;;;;;;;;;;;;;;;;;;;;;;;;
;; Autostart Dropbox
(call-process-shell-command "(sleep 10s && ~/.dropbox-dist/dropboxd) &" nil 0)
;;;;;;;;;;;;;;;;;;;;;
;; Local variables ;;
;;;;;;;;;;;;;;;;;;;;;
;; From https://alhassy.github.io/init/
;; Let's always load local variables that we've marked as safe. ( I tend to use loads of such locals! )
(setq enable-local-variables :safe)
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with <open> and enter text in its buffer.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ambrevar stuff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Emacs config
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Prerequisites
;; (let ((minver "26.1"))
;; (when (version< emacs-version minver)
;; (error "Your Emacs is too old -- this config requires v%s or higher" minver)))
;; ;;; Speed up init.
;; ;;; Temporarily reduce garbage collection during startup. Inspect `gcs-done'.
;; (defun ambrevar/reset-gc-cons-threshold ()
;; (setq gc-cons-threshold (car (get 'gc-cons-threshold 'standard-value))))
;; (setq gc-cons-threshold (* 64 1024 1024))
;; (add-hook 'after-init-hook 'ambrevar/reset-gc-cons-threshold)
;; ;;; Temporarily disable the file name handler.
;; (setq default-file-name-handler-alist file-name-handler-alist)
;; (setq file-name-handler-alist nil)
;; (defun ambrevar/reset-file-name-handler-alist ()
;; (setq file-name-handler-alist
;; (append default-file-name-handler-alist
;; file-name-handler-alist))
;; (cl-delete-duplicates file-name-handler-alist :test 'equal))
;; (add-hook 'after-init-hook 'ambrevar/reset-file-name-handler-alist)
;; ;;; Avoid the "loaded old bytecode instead of newer source" pitfall.
;; (setq load-prefer-newer t)
;; ;;; Store additional config in a 'lisp' subfolder and add it to the load path so
;; ;;; that `require' can find the files.
;; ;;; This must be done before moving `user-emacs-directory'.
;; (add-to-list 'load-path (expand-file-name "lisp/" user-emacs-directory))
;; ;;; Move user-emacs-directory so that user files don't mix with cache files.
;; (setq user-emacs-directory "~/.cache/emacs/")
;; ;;; Site Lisp folder for local packages and development.
;; ;; We need to roll it out manually since we want it first in the `load-path',
;; ;; while `normal-top-level-add-subdirs-to-load-path' appends it to the very end.
;; (defun ambrevar/package-refresh-load-path (path)
;; "Add every non-hidden sub-folder of PATH to `load-path'."
;; (when (file-directory-p path)
;; (dolist (dir (directory-files path t "^[^\\.]"))
;; (when (file-directory-p dir)
;; (setq load-path (add-to-list 'load-path dir))
;; (dolist (subdir (directory-files dir t "^[^\\.]"))
;; (when (file-directory-p subdir)
;; (setq load-path (add-to-list 'load-path subdir))))))))
;; (let ((site-lisp (expand-file-name "site-lisp/" "~/.local/share/emacs/")))
;; (add-to-list 'load-path site-lisp)
;; (ambrevar/package-refresh-load-path site-lisp))
;; ;;; Local config. See below for an example usage.
;; (load "local-before" t)
;; (require 'functions)
;; (require 'main)
;; ;; (require 'visual)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;; Assembly
;; (push 'nasm-mode package-selected-packages)
;; ;;; ChangeLog
;; (defun ambrevar/change-log-set-indent-rules ()
;; (setq tab-width 2 left-margin 2))
;; (add-hook 'change-log-mode-hook 'ambrevar/change-log-set-indent-rules)
;; ;;; Diff
;; ;;; TODO: In diff-mode, both `[[` and `C-M-a` do not go back to previous index
;; ;;; once they are at the beginning of an index.
;; (nconc package-selected-packages '(ztree))
;; ;;; Dired
;; ;;; Dired is loaded after init.el, so configure it only then.
;; ;;; TODO: Improve dired-du:
;; ;;; - Hangs when the `ls` time format is changed.
;; ;;; - Cache recursive results.
;; (nconc package-selected-packages '(dired-du))
;; (with-eval-after-load 'dired (require 'init-dired))
;; ;;; Daemons.
;; (nconc package-selected-packages '(daemons))
;; ;;; Eshell
;; ;;; Extend completion.
;; (nconc package-selected-packages '(fish-completion bash-completion
;; pcomplete-extension pcmpl-args pcmpl-git))
;; (nconc package-selected-packages '(esh-autosuggest))
;; (with-eval-after-load 'eshell (require 'init-eshell))
;; (autoload 'ambrevar/eshell-or-new-session "eshell")
;; ;;; Expand region.
;; (nconc package-selected-packages '(expand-region))
;; (when (require 'expand-region nil t)
;; (global-set-key (kbd "C-=") 'er/expand-region))
;; ;;; Helm
;; (nconc package-selected-packages '(helm helm-descbinds helm-ls-git))
;; (when (require 'helm-config nil t) (require 'init-helm))
;; ;;; Highlight
;; (nconc package-selected-packages '(hl-todo))
;; (when (require 'hl-todo nil t)
;; (add-to-list 'hl-todo-keyword-faces `("REVIEW" . ,(alist-get "TODO" hl-todo-keyword-faces nil nil 'equal)))
;; (global-hl-todo-mode)
;; ;; (global-set-key (kbd "M-s M-o") 'hl-todo-occur)
;; (define-key hl-todo-mode-map (kbd "M-s t") 'hl-todo-occur))
;; ;;; Iedit
;; (nconc package-selected-packages '(iedit))
;; (when (require 'iedit nil t)
;; (global-set-key (kbd "C-;") 'iedit-mode))
;; ;;; Image
;; ;;; TODO: Disable white frame.
;; ;;; I think it's the cursor.
;; ;;; Evil-mode reverts cursor changes.
;; ;; (set-face-foreground 'cursor "black")
;; ;;; TODO: Implement other sxiv features:
;; ;;; - Gamma