-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.el
1099 lines (886 loc) · 36.4 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; lexical-binding: t -*-
;;; Figuring out which system we're in.
;;; We might be running on MacOSX but using X11.
(defvar darwin-p (string-match "darwin" (symbol-name system-type)))
(defvar x11-p (eq window-system 'x))
(defvar mac-p (or (eq window-system 'ns) (eq window-system 'mac)))
(defvar olpc-p (string-match "olpc" (user-login-name)))
(defvar siscog-p (string-match "luismbo" (user-login-name)))
(defvar win-p (eq window-system 'w32))
(setq user-mail-address (rot13 "ybyvirven@pbzzba-yvfc.arg"))
;; (defun lbo:imenu-elisp-sections ()
;; (setq imenu-prev-index-position-function nil)
;; (add-to-list 'imenu-generic-expression '("Sections" "^;;;; \\(.+\\)$" 1) t))
;; (add-hook 'emacs-lisp-mode-hook 'lbo:imenu-elisp-sections)
;;; emacs ... -T ORG
(defvar org-only-mode-p
(string= "ORG" (frame-parameter (selected-frame) 'title)))
;;; emacs ... -T JABBER
(defvar roster-only-mode-p
(string= "JABBER" (frame-parameter (selected-frame) 'title)))
(defvar gnus-only-mode-p
(string= "GNUS" (frame-parameter (selected-frame) 'title)))
;;;; Exec Path
(when mac-p
(add-to-list 'exec-path "/usr/local/bin"))
;;;; Load Path
(add-to-list 'load-path "~/.emacs.d/lib")
;;;; package.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(defvar lbo:*auto-refreshed-packages* nil
"True if `lbo:ensure-package' has already refreshed the package
list in the current session")
(defun lbo:ensure-package (name)
(unless (package-installed-p name)
(unless lbo:*auto-refreshed-packages*
(package-refresh-contents)
(setq lbo:*auto-refreshed-packages* t))
(package-install name)))
;;;; use-package
(lbo:ensure-package 'use-package)
(lbo:ensure-package 'diminish)
(eval-when-compile
(require 'use-package)
(setq use-package-always-ensure t))
;;;; SISCOG
(when siscog-p
(load "~/.emacs.d/siscog/site.el")
(unless (or roster-only-mode-p org-only-mode-p gnus-only-mode-p)
(load "~/.emacs.d/my-siscog-config.el"))
(unless (or gnus-only-mode-p roster-only-mode-p)
(load "~/.emacs.d/my-siscog-org-config.el")
(setq display-time-format "-%H:%M-")
;; (display-time)
))
;;;; Editing Stuff
(setq-default indent-tabs-mode (and siscog-p t))
(set-language-environment "UTF-8")
(global-font-lock-mode t)
(show-paren-mode t)
(transient-mark-mode t)
(when mac-p
(setq browse-url-browser-function
(lambda (url &optional new-window)
(message url)
(do-applescript (concat "open location \"" url "\"")))))
(use-package crux
:bind (("C-a" . crux-move-beginning-of-line)))
;;;; Highlight FIXMEs et cetera
(add-hook 'prog-mode-hook
(lambda ()
(font-lock-add-keywords nil '(("\\<\\(FIXME\\|TODO\\|CAUTION\\|XXX\\)"
1 font-lock-warning-face prepend)))))
;;; ethan-wspace
(use-package ethan-wspace
:config
(setq mode-require-final-newline nil)
(add-hook 'ethan-wspace-mode-hook
(lambda ()
(when indent-tabs-mode
(setq ethan-wspace-errors (remove 'tabs ethan-wspace-errors)))))
(add-hook 'prog-mode-hook 'ethan-wspace-mode))
(defun lbo:scrub-whitespace ()
(interactive)
(untabify (point-min) (point-max))
(delete-trailing-whitespace))
;;;; Goto Last Change
(use-package goto-last-change
:bind (("C-c \\" . goto-last-change)))
;;;; Non-marking M-> and M-<
(defun lbo:end-of-buffer-nomark () (interactive) (goto-char (point-max)))
(defun lbo:beginning-of-buffer-nomark () (interactive) (goto-char (point-min)))
(global-set-key (kbd "M-<") 'lbo:beginning-of-buffer-nomark)
(global-set-key (kbd "M->") 'lbo:end-of-buffer-nomark)
;;;; Fonts
(when mac-p
;(setq mac-allow-anti-aliasing nil)
(setq mac-option-key-is-meta nil)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil))
(setq *default-font*
(cond
(mac-p "Menlo-11")
(olpc-p "Monospace-7")
;; (win-p "Consolas-10")
(win-p "Cascadia Code PL-10")
((> emacs-major-version 22) "Ubuntu Mono 12")
(t "-*-*-*-*-*-*-13-*-*-*-*-*-*-*")))
(set-frame-font *default-font* t t)
(global-set-key [C-M-wheel-up] 'text-scale-increase)
(global-set-key [C-M-wheel-down] 'text-scale-decrease)
;;;; C
(defun my-c-mode ()
(c-set-style "K&R")
(setq c-basic-offset 4
indent-tabs-mode nil)
(helm-gtags-mode))
(add-hook 'c-mode-hook 'my-c-mode)
(add-hook 'c++-mode-hook 'my-c-mode)
(add-hook 'c-mode-common-hook
(lambda ()
(define-key c-mode-base-map (kbd "C-c C-c") 'compile)))
(when siscog-p
(defun lbo:inject-mingw64-path (wrapped-function &rest args)
(let ((exec-path (cl-list* "d:/msys64/mingw64/bin/"
"d:/msys64/usr/bin/"
exec-path))
(restore (getenv "PATH")))
(unwind-protect
(progn
(setenv "PATH" (mapconcat #'identity exec-path ";"))
(apply wrapped-function args))
(setenv "PATH" restore))))
(advice-add 'gdb :around 'lbo:inject-mingw64-path)
(advice-add 'compile :around 'lbo:inject-mingw64-path)
(advice-add 'recompile :around 'lbo:inject-mingw64-path)
(advice-add 'compile :around
(lambda (wrapped &rest args)
"Use a sane value for `default-directory'."
(let* ((default-directory (locate-dominating-file default-directory ".git")))
(apply wrapped args)))
'((name . lbo:default-directory-from-first-dot-git)
(depth . 0)))
(defun lbo:dont-ask-about-saving-outside-project-dir (wrapped &rest args)
"Use a sane value for `default-directory'."
(let* ((my-default-directory default-directory)
(compilation-save-buffers-predicate
(lambda () (string-prefix-p
my-default-directory
(file-truename (buffer-file-name))))))
(apply wrapped args)))
(advice-add 'compile :around
'lbo:dont-ask-about-saving-outside-project-dir
'((depth . 50)))
(advice-add 'recompile :around 'lbo:dont-ask-about-saving-outside-project-dir))
(defun lbo:remove-all-advice (symbol)
(advice-mapc (lambda (ad props)
(advice-remove symbol ad))
symbol))
;;;; Java
(add-hook 'java-mode-hook (lambda () (setq c-basic-offset 2)))
;;;; Python
;(add-to-list 'load-path "~/.emacs.d/python-mode/")
;(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
;(setq interpreter-mode-alist (cons '("python" . python-mode)
; interpreter-mode-alist))
;(autoload 'python-mode "python-mode" "Python editing mode." t)
;;;; Factor
(when mac-p
(load-file "~/Software/factor/misc/fuel/fu.el"))
;;;; Common Lisp
(load "~/.emacs.d/my-slime-config.el")
(put 'package 'safe-local-variable 'symbolp)
(put 'Package 'safe-local-variable 'symbolp)
(put 'syntax 'safe-local-variable 'symbolp)
(put 'Syntax 'safe-local-variable 'symbolp)
(put 'Base 'safe-local-variable 'integerp)
(put 'base 'safe-local-variable 'integerp)
;;;; Paredit
(lbo:ensure-package 'paredit)
(add-hook 'lisp-mode-hook (lambda () (paredit-mode 1)))
(add-hook 'emacs-lisp-mode-hook (lambda () (paredit-mode 1)))
;; have RET automatically do indentation
(eval-after-load 'paredit
'(progn
(define-key paredit-mode-map (kbd "RET") nil)
(define-key lisp-mode-shared-map (kbd "RET") 'paredit-newline)
(diminish 'paredit-mode)))
;;; Elisp
(add-hook 'emacs-lisp-mode-hook (lambda () (eldoc-mode 1)))
(diminish 'eldoc-mode)
(use-package find-func
:ensure nil
:bind (:map emacs-lisp-mode-map ("M-." . find-function-at-point)))
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(local-set-key (kbd "C-c C-c") 'compile-defun)))
;;;; Light-grey Parentheses
(use-package paren-face
:if window-system
:config (global-paren-face-mode))
;;;; Pretty Greek Alphabet
(defun pretty-greek ()
(let ((greek '("alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta"
"theta" "iota" "kappa" "lambda" "mu" "nu" "xi" "omicron"
"pi" "rho" "sigma_final" "sigma" "tau" "upsilon" "phi"
"chi" "psi" "omega")))
(loop for word in greek
for code = 97 then (+ 1 code)
do (let ((greek-char (make-char 'greek-iso8859-7 code)))
(font-lock-add-keywords
nil
`((,(concat "\\(^\\|[^a-zA-Z0-9]\\)\\(" word "\\)[a-zA-Z]")
(0 (progn
(decompose-region (match-beginning 2) (match-end 2))
nil)))))
(font-lock-add-keywords
nil
`((,(concat "\\(^\\|[^a-zA-Z0-9]\\)\\(" word "\\)[^a-zA-Z]")
(0 (progn
(compose-region (match-beginning 2) (match-end 2)
,greek-char)
nil)))))))))
;; (add-hook 'lisp-mode-hook 'pretty-greek)
;;;; Window number mode
(use-package wn-mode
:diminish wn-mode
:config (wn-mode))
;;;; Utilities
(defun max-frame ()
(interactive)
(set-frame-position (selected-frame) 0 0)
(cond (mac-p (set-frame-size (selected-frame) 210 58))
((and darwin-p x11-p) (set-frame-size (selected-frame) 199 69))))
;; (global-set-key (kbd "C-c m") 'max-frame)
(defun split-frame-in-3 ()
(interactive)
(split-window-horizontally)
(wn-select-nth 1)
(split-window-vertically)
(enlarge-window 15)
(wn-select-nth 2))
(global-set-key (kbd "C-c f") 'split-frame-in-3)
(defun eshell/clear ()
"Clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
;;; http://www.emacswiki.org/emacs/RevertBuffer#toc3
(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files"
(interactive)
(let* ((list (buffer-list))
(buffer (car list)))
(while buffer
(when (buffer-file-name buffer)
(progn
(set-buffer buffer)
(revert-buffer t t t)))
(setq list (cdr list))
(setq buffer (car list))))
(message "Refreshing open files"))
;;;; Look and Feel
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)
(column-number-mode 1)
(when window-system
(scroll-bar-mode -1))
(tool-bar-mode -1)
(unless window-system
(xterm-mouse-mode))
(unless mac-p
(menu-bar-mode 0))
(setq default-indicate-empty-lines t)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally)
;(invert-face 'default)
(setq ring-bell-function 'ignore)
(use-package doom-themes
:config
;; (load-theme 'doom-dark+ t)
(load-theme 'doom-gruvbox t))
;; (use-package zenburn-theme
;; :config (load-theme 'zenburn t))
;;;; Enable disabled functions
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
;;;; Editing Keybindings
(global-set-key (kbd "C-c l") 'goto-line)
(global-set-key (kbd "C-DEL") 'join-line)
(global-set-key (kbd "C-<backspace>") 'join-line)
(global-set-key "\M-`" 'other-frame)
(global-unset-key (kbd "C-z"))
;;;; Haskell
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(setq haskell-program-name "/usr/local/bin/ghci -fobject-code")
;;;; Org Mode
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(lbo:ensure-package 'org)
(require 'org-install)
(setq org-hide-leading-stars t)
(setq org-odd-levels-only t)
;(setq org-startup-indented t) ; interesting alternative
(setq org-src-fontify-natively t)
(when siscog-p
(setq org-agenda-start-with-log-mode nil)
(setq org-agenda-start-with-clockreport-mode t))
(setq org-agenda-custom-commands
'(("n" "Agenda and NEXT tasks"
((tags-todo "next")
(agenda "")))))
;(add-hook 'org-agenda-mode-hook (lambda () (org-agenda-day-view)))
(setq org-directory
(if siscog-p
"z:/org"
"~/Dropbox/Documents/org"))
(setq org-agenda-files (list org-directory))
(setq org-default-notes-file (concat org-directory "/WORK.org"))
(define-key global-map (kbd "C-c o c") 'org-capture)
(setq org-capture-templates
`(("t" "Todo" entry (file+olp ,(concat org-directory "/WORK.org") "CAPTURE")
"* MAYBE %?\n %i\n %a")))
;; Add new TODO states
;;
;; C-c C-t followed by the key in parenthesis picks the respective
;; state. S-<Right> and S-<Left> cycle through all of these states.
(setq org-todo-keywords
'(;(sequence "TODO(t)" "|" "DONE(d)")
(sequence "TODO(t)" "MAYBE(m)" "WAITING(w)" "|" "DONE(d)")
(sequence "|" "CANCELLED(c)")
(sequence "OPEN(o)" "STARTED(s)" "VERIFICATION(v)" "|" "DELEGATED(l)" "RESOLVED(r)")
(sequence "REVIEW(R)" "|" "REVIEWED(D)")))
(setq org-todo-keyword-faces
'(("CANCELLED" . shadow)
("WAITING" . (:foreground "orange"))
("MAYBE" . (:foreground "orange"))
("WIP" . (:foreground "orange"))
("STARTED" . (:foreground "orange"))
("SEP" . (:foreground "orange"))))
;; The default was '(closed clock), show state changes as well.
(setq org-agenda-log-mode-items '(closed clock state))
(global-set-key (kbd "C-c o a")
(lambda () (interactive) (org-agenda nil "n")))
(global-set-key (kbd "C-c o t") 'org-todo-list)
(defun my-open-main-org-file ()
(interactive)
(find-file (concat org-directory (if siscog-p "/WORK.org" "/LIFE.org")))
(set-face-foreground 'org-hide (face-background 'default)))
(global-set-key (kbd "C-c o o") 'my-open-main-org-file)
(when siscog-p
(global-set-key (kbd "C-c o e")
'(lambda () (interactive) (find-file (concat org-directory "/EFFORT.org")))))
(setq org-agenda-span 'day)
;;;; ELPA FTW
;; (lbo:package-require 'scala-mode2)
;; (let ((ensime-dir "~/src/scala/ensime/src/main/elisp"))
;; (when (file-exists-p ensime-dir)
;; (add-to-list 'load-path ensime-dir)
;; (require 'ensime)
;; (add-hook 'scala-mode-hook 'ensime-scala-mode-hook)))
;;;; Magit
(use-package magit
:bind (("C-x g" . magit-status)
("C-x M-g" . magit-file-dispatch)
("C-c d" . magit-dispatch))
:diminish auto-revert-mode
:init (require 'vc-git)) ; for magit-grep
(add-to-list 'load-path "~/src/multi-magit")
(use-package multi-magit
:bind ("C-x G" . multi-magit-status)
:ensure nil
:config (progn
(unless magit-repository-directories
(setq magit-repository-directories '(("~/src/" . 2))))
(magit-add-section-hook 'magit-status-sections-hook
'multi-magit-insert-repos-overview
nil t)))
;; git >= 2.25 follows network/subst mapped drives which is annoying.
;; Thankfully `magit-toplevel' mostly handles this when
;; `find-file-visit-truename' is false.
(setq find-file-visit-truename nil)
;;;; Git grep
;; from https://gist.github.com/scottjacobsen/4693356
(defun lbo:git-root ()
"Return GIT_ROOT if this file is a part of a git repo,
else return nil."
(let ((curdir default-directory)
(max 10)
(found nil))
(while (and (not found) (> max 0))
(if (file-exists-p (concat curdir ".git"))
(setq found t)
(setq curdir (concat curdir "../"))
(setq max (- max 1))))
(if found (expand-file-name curdir))))
;; like vc-git-grep but case insensitive
(defun lbo:vc-git-grep (regexp &optional files dir)
"Run git grep, searching for REGEXP in FILES in directory DIR.
The search is limited to file names matching shell pattern FILES.
FILES may use abbreviations defined in `grep-files-aliases', e.g.
entering `ch' is equivalent to `*.[ch]'.
With \\[universal-argument] prefix, you can edit the constructed shell command line
before it is executed.
With two \\[universal-argument] prefixes, directly edit and run `grep-command'.
Collect output in a buffer. While git grep runs asynchronously, you
can use \\[next-error] (M-x next-error), or \\<grep-mode-map>\\[compile-goto-error] \
in the grep output buffer,
to go to the lines where grep found matches.
This command shares argument histories with \\[rgrep] and \\[grep]."
(interactive
(progn
(grep-compute-defaults)
(cond
((equal current-prefix-arg '(16))
(list (read-from-minibuffer "Run: " "git grep"
nil nil 'grep-history)
nil
default-directory))
(t (let* ((regexp (grep-read-regexp))
(files (grep-read-files regexp))
(dir (read-directory-name "In directory: "
nil default-directory t)))
(list regexp files dir))))))
(require 'grep)
(when (and (stringp regexp) (> (length regexp) 0))
(let ((command regexp))
(if (null files)
(if (string= command "git grep")
(setq command nil))
(setq dir (file-name-as-directory (expand-file-name dir)))
(setq command
;; -I means "ignore binaries"
(grep-expand-template "git --no-pager grep -I --no-color --ignore-case -n -e <R> -- <F>"
regexp files))
(when command
(if (equal current-prefix-arg '(4))
(setq command
(read-from-minibuffer "Confirm: "
command nil nil 'grep-history))
(add-to-history 'grep-history command))))
(when command
(let ((default-directory dir)
(compilation-environment (cons "PAGER=" compilation-environment)))
;; Setting process-setup-function makes exit-message-function work
;; even when async processes aren't supported.
(compilation-start command 'grep-mode))
(if (eq next-error-last-buffer (current-buffer))
(setq default-directory dir))))))
(defun lbo:git-grep (regexp)
(interactive (progn
(grep-compute-defaults)
(list (grep-read-regexp))))
(lbo:vc-git-grep regexp "*" (lbo:git-root)))
(global-set-key (kbd "C-c g") 'lbo:git-grep)
;; C-c i toggle ignore case
;; C-! suspends auto update
;; C-x C-s moves results to a grep-mode buffer
;; (use-package helm-git-grep
;; :bind ("C-c g" . lbo:helm-git-grep-at-point)
;; :config (defun lbo:helm-git-grep-at-point ()
;; (interactive)
;; (helm-git-grep-at-point)))
;;;; Input Methods
;; Default setting for C-\
(setq default-input-method 'portuguese-prefix)
(global-set-key (kbd "C-c k p")
(defun lbo:portuguese-input ()
(interactive)
(set-input-method 'portuguese-prefix)))
(global-set-key (kbd "C-c k e")
(defun lbo:esperanto-input ()
(interactive)
(set-input-method 'esperanto-postfix)))
(global-set-key (kbd "C-c k l")
(defun lbo:tex-input ()
(interactive)
(set-input-method 'TeX)))
;;;; bm
(use-package bm
:bind (("<left-fringe> <wheel-up>" . bm-next-mouse)
("<left-fringe> <wheel-down>" . bm-previous-mouse)
("<left-fringe> <mouse-1>" . bm-toggle-mouse)
("<left-fringe> <mouse-3>" . bm-show-all))
:config (setq bm-cycle-all-buffers t))
;;;; expand-region
(use-package expand-region
:bind ("C-@" . er/expand-region))
;;;; multiple-cursors
(use-package multiple-cursors
:bind (("C-S-c C-S-c" . mc/edit-lines)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C-<" . mc/mark-all-like-this)))
;;;; ace-jump-mode
(use-package avy
:bind ("C-:" . avy-goto-char))
;;;; AMPL
(use-package ampl-mode
:ensure nil
:mode ("\\.mod$" "\\.ampl$"))
;;;; htmlize
(use-package htmlize
:commands (lbo:export-buffer-to-html
lbo:export-region-to-html)
:config
(defmacro lbo:with-disabled-themes (&rest body)
(let ((themes (gensym)))
`(let ((,themes custom-enabled-themes))
(mapc #'disable-theme ,themes)
(unwind-protect (progn ,@body)
(mapc #'enable-theme ,themes)))))
(defun lbo:browse-htmlized-buffer (prefix buffer)
(with-current-buffer buffer
(let ((file (make-temp-file prefix nil ".html")))
(write-file file)
(browse-url (concat "file://" file)))
(kill-buffer)))
(defun lbo:export-buffer-to-html ()
(interactive)
(lbo:with-disabled-themes
(lbo:browse-htmlized-buffer "htmlized-buffer-" (htmlize-buffer))))
(defun lbo:export-region-to-html ()
(interactive)
(let (transient-mark-mode-enabled transient-mark-mode)
(lbo:with-disabled-themes
(transient-mark-mode -1)
(redisplay)
(lbo:browse-htmlized-buffer "htmlized-region-"
(htmlize-region (region-beginning)
(region-end)))
(transient-mark-mode (if transient-mark-mode-enabled 1 -1))))))
;;;; The End
(setq auto-save-list-file-prefix "~/.asl-emacs/saves-")
(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
(setq confirm-kill-emacs 'yes-or-no-p)
(unless org-only-mode-p
(ido-mode)
;; don't search for files outside the current directory in
;; `ido-find-file'.
(setq ido-auto-merge-work-directories-length -1))
;; (autoload 'idomenu "idomenu" nil t)
;; (global-set-key (kbd "M-i") 'idomenu)
(random t)
(when org-only-mode-p
(setq inhibit-startup-message t)
(my-open-first-agenda-file))
;; (load "~/.emacs.d/my-jabber-config.el")
(when siscog-p
(load "~/.emacs.d/siscog/gnus-config.el")
(when gnus-only-mode-p
(setq inhibit-startup-message t)
(gnus)))
(when roster-only-mode-p
(setq inhibit-startup-message t)
(gtalk))
(eval-after-load 'sml-mode
'(setq sml-program-name "/usr/local/Cellar/smlnj/110.75/libexec/bin/sml"))
(lbo:ensure-package 'circe)
(eval-after-load 'circe
'(progn
(circe-set-display-handler "JOIN" (lambda (&rest ignored) nil))
(circe-set-display-handler "PART" (lambda (&rest ignored) nil))
(circe-set-display-handler "QUIT" (lambda (&rest ignored) nil))
;; see <https://github.com/jorgenschaefer/circe/issues/340>
(setq tls-end-of-info
(concat
"\\("
;; `openssl s_client' regexp. See ssl/ssl_txt.c lines 219-220.
;; According to apps/s_client.c line 1515 `---' is always the last
;; line that is printed by s_client before the real data.
"^ Verify return code: .+\n\\(\\|^ Extended master secret: .+\n\\)---\n\\|"
;; `gnutls' regexp. See src/cli.c lines 721-.
"^- Simple Client Mode:\n"
"\\(\n\\|" ; ignore blank lines
;; According to GnuTLS v2.1.5 src/cli.c lines 640-650 and 705-715
;; in `main' the handshake will start after this message. If the
;; handshake fails, the programs will abort.
"^\\*\\*\\* Starting TLS handshake\n\\)*"
"\\)"))
(setq circe-network-options '(("kerno"
:tls t
:nick "luis"
:host "kerno.org"
:port 6697)))))
;; (use-package slack
;; :commands (slack-start)
;; :init
;; (setq slack-buffer-emojify t)
;; (setq slack-prefer-current-team t)
;; :config
;; (slack-register-team
;; :name "siscog"
;; :default t
;; :client-id ""
;; :client-secret ""
;; :token ""
;; :subscribed-channels '()))
(lbo:ensure-package 'helm-gtags)
(eval-after-load 'helm-gtags
'(progn
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
(define-key helm-gtags-mode-map (kbd "M-t") 'helm-gtags-find-tag)
(define-key helm-gtags-mode-map (kbd "M-r") 'helm-gtags-find-rtag)
(define-key helm-gtags-mode-map (kbd "M-s") 'helm-gtags-find-symbol)
(define-key helm-gtags-mode-map (kbd "M-g M-p") 'helm-gtags-parse-file)
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history)
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)))
;;;; Helm
;; (use-package helm-config
;; :ensure helm
;; :demand t
;; :bind (("C-c C-/" . helm-occur)
;; ("C-c i" . helm-imenu)
;; ("C-x f" . helm-multi-files)
;; ("C-c C-f" . helm-find-files)
;; ("M-H" . helm-resume)
;; ("M-x" . helm-M-x))
;; :config
;; (require 'helm-files)
;; (require 'helm-buffers)
;; (use-package helm-mode
;; :ensure nil
;; :diminish helm-mode
;; :init
;; (helm-mode 1))
;; (require 'helm-multi-match)
;; (helm-autoresize-mode 1)
;; (bind-key "<tab>" #'helm-execute-persistent-action helm-map)
;; (bind-key "C-i" #'helm-execute-persistent-action helm-map)
;; (bind-key "C-z" #'helm-select-action helm-map))
;;;; Ivy / Counsel / Swiper
;; (use-package ivy
;; :config (ivy-mode 1))
;; (use-package counsel
;; :config (counsel-mode 1))
;; (use-package swiper
;; :bind ("C-s" . swiper))
;;;; Selectrum
(use-package selectrum
:config (selectrum-mode 1))
(use-package selectrum-prescient
:config (progn
(selectrum-prescient-mode 1)
(prescient-persist-mode 1)))
;;;; Marginalia
(use-package marginalia
:config (progn
(marginalia-mode)
(marginalia-cycle)))
(use-package embark
:bind
("C-S-a" . embark-act)) ; pick some comfortable binding
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
:hook
(embark-collect-mode . embark-consult-preview-minor-mode))
(use-package ctrlf
:config (progn
(setq ctrlf-mode-bindings
'(("C-S-s" . ctrlf-forward-literal)
("C-S-r" . ctrlf-backward-literal)
("C-M-S-s" . ctrlf-forward-regexp)
("C-M-S-r" . ctrlf-backward-regexp)
("C-c ." . ctrlf-forward-symbol-at-point)
("C-c _" . ctrlf-forward-symbol)))
(setq ctrlf-minibuffer-bindings
`(("<down>" . ctrlf-next-match)
("<up>" . ctrlf-previous-match)
("C-w" . next-history-element)
,@ctrlf-minibuffer-bindings))
(ctrlf-mode)))
(define-prefix-command 'lbo:consult-map)
(global-set-key (kbd "M-c") 'lbo:consult-map)
(use-package consult
:bind (;; M-g bindings (goto-map)
("M-g g" . consult-goto-line)
("M-g M-g" . consult-goto-line)
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g e" . consult-error)
;; M-c
("M-c 4 b" . consult-buffer-other-window)
("M-c 5 b" . consult-buffer-other-frame)
("M-c b" . consult-buffer)
("M-c B" . consult-bookmark)
("M-c f" . consult-find)
("M-c h" . consult-history)
("M-c i" . consult-imenu)
("M-c o" . consult-outline)
("M-c p" . consult-project-imenu)
("M-c r" . consult-register)
("M-c s" . consult-line)
("M-c G" . consult-grep)
("M-c g" . consult-git-grep)
("M-c k" . consult-keep-lines)
("M-c l" . consult-line)
("M-c m" . consult-multi-occur)
("M-c u" . consult-focus-lines)
("M-c x" . consult-mode-command)
;; Other bindings
("M-y" . consult-yank-pop)
("<help> a" . consult-apropos))
:config (setq consult-narrow-key "<"))
(use-package which-key
:diminish which-key-mode
:config (which-key-mode))
;;;; smartscan
(use-package smartscan
:bind (("C-c n" . smartscan-symbol-go-forward)
("C-c p" . smartscan-symbol-go-backward)))
;;;; spaceline
;; (use-package spaceline
;; :demand t
;; :init (setq powerline-default-separator 'arrow-fade
;; powerline-height 25)
;; :config
;; (require 'spaceline-config)
;; (spaceline-spacemacs-theme))
(use-package powerline
:demand t
:init (setq powerline-default-separator 'slant
powerline-height 25)
:config
(powerline-default-theme)
(defun lbo:powerline-reset-after (&rest _args)
(powerline-reset))
(advice-add #'enable-theme :after 'lbo:powerline-reset-after)
(advice-add #'disable-theme :after 'lbo:powerline-reset-after)
;; adapted from <https://github.com/domtronn/all-the-icons.el/wiki/Mode-Line>
(when (fboundp 'all-the-icons-octicon)
(defpowerline powerline-vc
(when (and (buffer-file-name (current-buffer)) vc-mode)
(if (string-match "Git[:-]" vc-mode)
(let ((branch (subseq vc-mode (match-end 0))))
(concat
(propertize (format " %s " (all-the-icons-octicon "git-branch"))
'face `(:height 1.3 :family ,(all-the-icons-octicon-family) :inherit ,face)
'display '(raise -0.15))
branch))
(format-mode-line '(vc-mode vc-mode)))))))
;;;; dired
(setq-default dired-listing-switches "-alh")
(put 'dired-find-alternate-file 'disabled nil)
(require 'dired-x)
(setq dired-omit-files "^\\.?#")
(add-hook 'dired-mode-hook
(lambda ()
(dired-omit-mode)
(dired-hide-details-mode)))
;; (setq ls-lisp-use-insert-directory-program t)
;; (setq ls-list-verbosity nil)
;; (defadvice ls-lisp-format (around my-ls-lisp-format
;; (file-name file-attr file-size switches time-index))
;; "Advice definition which removes unnecessary information
;; during file listing in dired. For such purposes
;; `ls-lisp-verbosity' customized variable can be used, but
;; even if it is equal to nil dired will display file
;; permissions field like \"drwxrwxrwx\".\. So here we just
;; get full control to what dired shows and leave only those
;; fields which we need."
;; (progn
;; ad-do-it
;; (setq ad-return-value
;; (concat
;; ;; (substring ad-return-value 0 1)
;; (substring ad-return-value 10))))) ; 13
;; (ad-activate 'ls-lisp-format t)
;; (use-package dired-narrow
;; :bind (:map dired-mode-map ("/" . dired-narrow)))
;; (use-package peep-dired
;; :bind (:map dired-mode-map ("P" . peep-dired)))
;; (setq package-check-signature nil)
;; (use-package dired
;; :hook (dired-mode . dired-hide-details-mode)
;; :ensure nil
;; :config
;; ;; Colourful columns.
;; (use-package diredfl
;; :config
;; (diredfl-global-mode 1)))
;; (use-package dired-git-info
;; :bind (:map dired-mode-map
;; (")" . dired-git-info-mode)))
;;;; hunspell
;; http://sourceforge.net/projects/ezwinports/files/?source=navbar