-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathorg-init.org
16921 lines (13919 loc) · 538 KB
/
org-init.org
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
#+TITLE: Literate Emacs configuration
#+AUTHOR: Timm Lichte
#+FILETAGS: emacs
#+STARTUP: indent
#+STARTUP: hideblocks content
* Table of contents :TOC_2_gh:
- [[#good-examples][Good examples]]
- [[#general-settings][General settings]]
- [[#general-appearence][General appearence]]
- [[#toolbar][Toolbar]]
- [[#start-up][Start-up]]
- [[#signals][Signals]]
- [[#syntax-highlighting][Syntax highlighting]]
- [[#lines][Lines]]
- [[#cursor][Cursor]]
- [[#text-faces][Text faces]]
- [[#mode-line-and-window-labels][Mode line and window labels]]
- [[#distraction-free-mode][Distraction-free mode]]
- [[#overlays][Overlays]]
- [[#icons][Icons]]
- [[#debugging][Debugging]]
- [[#echo-area--messages][Echo area / Messages]]
- [[#minibuffer][Minibuffer]]
- [[#general][General]]
- [[#ido-ivy][ido, ivy]]
- [[#imenu][imenu]]
- [[#helm][helm]]
- [[#keys][Keys]]
- [[#major-modes][Major modes]]
- [[#org-mode][org-mode]]
- [[#accounting][Accounting]]
- [[#calendardiary--address-book][Calendar/Diary & address book]]
- [[#coding--writing][Coding & Writing]]
- [[#file-management][File management]]
- [[#getting-things-done][Getting things done]]
- [[#messaging][Messaging]]
- [[#viewing-and-editing][Viewing (and editing)]]
- [[#minor-modes][Minor modes]]
- [[#pandoc-mode][pandoc-mode]]
- [[#so-long-mode][so-long-mode]]
- [[#buffer][Buffer]]
- [[#general-configuration][General configuration]]
- [[#general-buffer-actions][General buffer actions]]
- [[#switch-between-buffers][Switch between buffers]]
- [[#autocomplete][Autocomplete]]
- [[#syntax-checking][Syntax checking]]
- [[#spell-checking][Spell checking]]
- [[#grammar-checking][Grammar checking]]
- [[#paren-handling][Paren handling]]
- [[#indentation][Indentation]]
- [[#selection][Selection]]
- [[#code-folding][Code folding]]
- [[#context-menu][Context menu]]
- [[#cursor-actions][Cursor actions]]
- [[#keystroke-visualizer][Keystroke visualizer]]
- [[#lorem-ipsum--blindtext][Lorem ipsum / Blindtext]]
- [[#undo--remove][Undo & remove]]
- [[#save-kill--yank][Save, kill & yank]]
- [[#search--replace][Search & replace]]
- [[#narrowing][Narrowing]]
- [[#commenting][Commenting]]
- [[#quoting][Quoting]]
- [[#line-actions][Line actions]]
- [[#capitalization][Capitalization]]
- [[#special-characters][Special characters]]
- [[#speech-to-text][Speech to text]]
- [[#thesauri][Thesauri]]
- [[#translation][Translation]]
- [[#printing][Printing]]
- [[#integers][Integers]]
- [[#numbered-examples][Numbered examples]]
- [[#zooming][Zooming]]
- [[#files][Files]]
- [[#org-agenda-files][org-agenda files]]
- [[#search--find][Search & find]]
- [[#backup][Backup]]
- [[#autosave][Autosave]]
- [[#locking-files][Locking files]]
- [[#line-encodings][Line encodings]]
- [[#project-management][Project management]]
- [[#projectile][projectile]]
- [[#windows-and-frames][Windows and frames]]
- [[#general-key-bindings][General key bindings]]
- [[#navigation][Navigation]]
- [[#transpose-frame][transpose-frame]]
- [[#dimmer][dimmer]]
- [[#burly][Burly]]
- [[#emacs-everywhere][emacs-everywhere]]
- [[#bookmarks][Bookmarks]]
- [[#general-settings][General settings]]
- [[#burly][[[Burly]]]]
- [[#git][Git]]
- [[#magit][magit]]
- [[#forge][Forge]]
- [[#git-gutter][git-gutter]]
- [[#git-link][git-link]]
- [[#kill-ring][Kill ring]]
- [[#shells][Shells]]
- [[#better-shell][better-shell]]
- [[#eshell][eshell]]
- [[#external-terminal][External terminal]]
- [[#vterm][vterm]]
- [[#data-security][Data security]]
- [[#gnupg--easypg][GnuPG / EasyPG]]
- [[#authinfo][authinfo]]
- [[#system-management][System management]]
- [[#proced][proced]]
- [[#helm-system-packages][helm-system-packages]]
- [[#guix][Guix]]
- [[#tags][Tags]]
- [[#etags][etags]]
- [[#web-browsing][Web browsing]]
- [[#atomic-chrome][atomic-chrome]]
- [[#xah-lookup][xah-lookup]]
- [[#remote-connections][Remote connections]]
- [[#tramp][tramp]]
- [[#emacs-ssh-deploy][emacs-ssh-deploy]]
- [[#help][Help]]
- [[#helpful][helpful]]
- [[#discover][discover]]
- [[#hydras][Hydras]]
- [[#hydra-begin][hydra: begin]]
- [[#hydras-for-function-keys][Hydras for function keys]]
- [[#hydra-artist][hydra-artist]]
- [[#hydra-bibtex][hydra-bibtex]]
- [[#hydra-bookmarks][hydra-bookmarks]]
- [[#hydra-cm-mode][hydra-cm-mode]]
- [[#hydra-dired][hydra-dired]]
- [[#hydra-elisp][hydra-elisp]]
- [[#hydra-org][hydra-org]]
- [[#hydra-deft][hydra-deft]]
- [[#hydra-git-gutter][hydra-git-gutter]]
- [[#hydra-helm][hydra-helm]]
- [[#hydra-ibuffer][hydra-ibuffer]]
- [[#hydra-image][hydra-image]]
- [[#hydra-insert-date][hydra-insert-date]]
- [[#hydra-insert-file-name][hydra-insert-file-name]]
- [[#hydra-jump][hydra-jump]]
- [[#hydra-khardel][hydra-khardel]]
- [[#hydra-latex][hydra-latex]]
- [[#hydra-macro][hydra-macro]]
- [[#hydra-markdown][hydra-markdown]]
- [[#hydra-mu4e][hydra-mu4e]]
- [[#hydra-flycheck][hydra-flycheck]]
- [[#hydra-flyspell][hydra-flyspell]]
- [[#hydra-compilation-error][hydra-compilation-error]]
- [[#hydra-multiple-cursors][hydra-multiple-cursors]]
- [[#hydra-highlight-changes][hydra-highlight-changes]]
- [[#hydra-highlight-symbol][hydra-highlight-symbol]]
- [[#hydra-pdftools][hydra-pdftools]]
- [[#hydra-pomidor][hydra-pomidor]]
- [[#hydra-position-register][hydra-position-register]]
- [[#hydra-load-theme][hydra-load-theme]]
- [[#hydra-search][hydra-search]]
- [[#hydra-smerge][hydra-smerge]]
- [[#hydra-tags][hydra-tags]]
- [[#hydra-transpose][hydra-transpose]]
- [[#hydra-drag-stuff][hydra-drag-stuff]]
- [[#hydra-end][hydra: end]]
- [[#key-bindings][Key bindings]]
- [[#tlkeys-mode][tlkeys-mode]]
- [[#underi-mode][underi-mode]]
- [[#winkeys-mode][winkeys-mode]]
- [[#winkeys-starter-mode][winkeys-starter-mode]]
- [[#debugging][Debugging]]
- [[#private-settings][Private settings]]
* Good examples
- http://ivanmalison.github.io/dotfiles/
- https://github.com/novoid/dot-emacs/blob/master/config.org
- http://www.coli.uni-saarland.de/~slemaguer/emacs/main.html
- https://github.com/progfolio/.emacs.d
* General settings
General settings concerning startup, special variables, package management etc. are stored in an extra file. [[file:init.el]]
* General appearence
** Toolbar
Don't show the toolbar:
#+BEGIN_SRC emacs-lisp
(tool-bar-mode 0)
#+END_SRC
** Start-up
*** dashboard
https://github.com/emacs-dashboard/emacs-dashboard
An extensible Emacs startup screen.
#+BEGIN_SRC emacs-lisp
(use-package dashboard
:ensure t
:diminish dashboard-mode
:config
(setq
dashboard-banner-logo-title (emacs-version)
dashboard-startup-banner 'logo
dashboard-items '((recents . 10)
(bookmarks . 10)
(projects . 5)
)
)
(add-to-list 'dashboard-item-generators '(custom-settings . dashboard-insert-custom-settings))
(add-to-list 'dashboard-items '(custom-settings) t)
(define-key dashboard-mode-map (kbd "<up>") (lambda () (interactive)(widget-forward -1)))
(define-key dashboard-mode-map (kbd "<down>") (lambda () (interactive)(widget-forward 1)))
;; (setq dashboard-set-navigator t)
;; (setq dashboard-navigator-buttons
;; `(;; line1
;; ((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0)
;; "Homepage"
;; "Browse homepage"
;; (lambda (&rest _) (browse-url "homepage")))
;; ("★" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning)
;; ("?" "" "?/h" #'show-help nil "<" ">"))
;; ;; line 2
;; ((,(all-the-icons-faicon "linkedin" :height 1.1 :v-adjust 0.0)
;; "Linkedin"
;; ""
;; (lambda (&rest _) (browse-url "homepage")))
;; ("⚑" nil "Show flags" (lambda (&rest _) (message "flag")) error))))
(dashboard-setup-startup-hook)
)
#+END_SRC
Custom settings (https://www.gnu.org/software/emacs/manual/html_mono/widget.html):
#+BEGIN_SRC emacs-lisp
(defun dashboard-insert-custom-settings (&rest ignore)
(interactive)
(widget-insert "Custom settings:\n\t\t")
(widget-create
'checkbox
:notify (lambda (&rest ignore)
(if (bound-and-true-p cua-mode)
(progn (cua-mode nil)
(customize-save-variable 'cua-mode nil))
(cua-mode t)
(customize-save-variable 'cua-mode t)
))
(bound-and-true-p cua-mode))
(widget-insert " Use CUA-mode?"))
#+END_SRC
Show dashboard when also starting a client:
#+BEGIN_SRC emacs-lisp
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
#+END_SRC
** Signals
No beeping:
#+BEGIN_SRC emacs-lisp
(setq visible-bell nil)
#+END_SRC
** Syntax highlighting
Show matching brackets:
#+BEGIN_SRC emacs-lisp
(show-paren-mode 1)
(setq show-paren-delay 0)
#+END_SRC
Apply syntax highlighting to all buffers:
#+BEGIN_SRC emacs-lisp
(global-font-lock-mode t)
#+END_SRC
*** highlight-symbol
https://github.com/nschum/highlight-symbol.el
Quickly highlight a symbol – most likely the word under point – throughout the buffer and cycle through its locations.
There is a hydra attached to it: [[hydra-highlight-symbol]]
#+BEGIN_SRC emacs-lisp
(use-package highlight-symbol
:ensure t
:config
(setq highlight-symbol-idle-delay 0.2)
(add-hook 'highlight-symbol-mode-hook
(function
(lambda () (highlight-symbol-nav-mode +1)))))
#+END_SRC
** Lines
Highlight line of cursor:
#+BEGIN_SRC emacs-lisp
(global-hl-line-mode t)
#+END_SRC
Soft-wrap lines:
#+BEGIN_SRC emacs-lisp
(global-visual-line-mode t)
#+END_SRC
Display line numbers in the modeline:
#+BEGIN_SRC emacs-lisp
(line-number-mode t)
#+END_SRC
*** Line numbers in the margin
Before Emacs v26, the (sometimes slow) linum package was used for displaying the line numbers in the margin of the window:
#+BEGIN_SRC emacs-lisp
;; ;; before Emacs 26
;; (global-linum-mode t)
;; (setq linum-format " %3d ")
#+END_SRC
With Emcas v26, the display of line numbers is built-in and much faster:
#+BEGIN_SRC emacs-lisp
;; ;; with Emacs 26
;; (global-display-line-numbers-mode)
#+END_SRC
Line numbering can be turned on/off with =M-x display-line-numbers-mode.=
Relative line numbers will be displayed after setting =display-line-numbers= as follows:
#+BEGIN_SRC emacs-lisp :tangle no
(setq display-line-numbers 'relative)
#+END_SRC
**** COMMENT linum-relative (DEPRECATED)
https://github.com/coldnew/linum-relative
Display relative line numbers.
Note that this package uses the deprecated linum package.
#+BEGIN_SRC emacs-lisp
(use-package linum-relative
:ensure t)
#+END_SRC
** Cursor
Let the cursor blink forever:
#+BEGIN_SRC emacs-lisp
(blink-cursor-mode 1) ; blink
(setq blink-cursor-blinks 0) ; blink forever
#+END_SRC
Stretch cursor:
#+BEGIN_SRC emacs-lisp
(setq x-stretch-cursor t)
#+END_SRC
** Text faces
A face is a collection of graphical attributes for displaying text: font, foreground color, background color, optional underlining, etc.
https://www.gnu.org/software/emacs/manual/html_node/emacs/Faces.html
*** Themes
A theme is a specified collection of faces, so that different types of text is displayed in a different way.
Add local themes directory to search space (just in case):
#+BEGIN_SRC emacs-lisp
(setq themes-dir
(expand-file-name "themes" user-emacs-directory))
(add-to-list 'custom-theme-load-path themes-dir)
#+END_SRC
**** monokai-theme
https://github.com/oneKelvinSmith/monokai-emacs
The monokai theme is one of my favourites.
#+BEGIN_SRC emacs-lisp
(use-package monokai-theme
:ensure t
:config
(load-theme 'monokai t)
;; font size of org-mode headers
(setq monokai-height-minus-1 1.0
monokai-height-plus-1 1.0
monokai-height-plus-2 1.1
monokai-height-plus-3 1.25
monokai-height-plus-4 1.5)
)
#+END_SRC
Yet I don't like how regions are highlighted:
#+BEGIN_SRC emacs-lisp
(custom-theme-set-faces
'monokai
`(region ((t (:inherit highlight :background "#FFB269" :foreground ,monokai-background))))
)
(enable-theme 'monokai) ; needed since v27
#+END_SRC
*** Switch between font styles
Toggle proportional mode when appropriate.
Inspired by https://ogbe.net/blog/toggle-serif.html
#+BEGIN_SRC emacs-lisp
(defvar font-preserve-default-list nil
"A list holding the faces that preserve the default family and
height when TOGGLE-SERIF is used.")
(setq font-preserve-default-list
'(;; LaTeX markup
font-latex-math-face
font-latex-sedate-face
font-latex-warning-face
;; org markup
org-latex-and-related
org-meta-line
org-verbatim
org-block-begin-line
;; syntax highlighting using font-lock
font-lock-builtin-face
font-lock-comment-delimiter-face
font-lock-comment-face
font-lock-constant-face
font-lock-doc-face
font-lock-function-name-face
font-lock-keyword-face
font-lock-negation-char-face
font-lock-preprocessor-face
font-lock-regexp-grouping-backslash
font-lock-regexp-grouping-construct
font-lock-string-face
font-lock-type-face
font-lock-variable-name-face
font-lock-warning-face))
(defun toggle-proportional ()
"Change the default face of the current buffer to use a proportional family."
(interactive)
(when (display-graphic-p) ;; this is only for graphical emacs
;; the serif font familiy and height, save the default attributes
(let ((proportional-fam "Segoe UI")
(proportional-height 125)
(default-fam (face-attribute 'default :family))
(default-height (face-attribute 'default :height)))
(if (not (bound-and-true-p default-cookie))
(progn (make-local-variable 'default-cookie)
(make-local-variable 'preserve-default-cookies-list)
(setq preserve-default-cookies-list nil)
;; remap default face to serif
(setq default-cookie
(face-remap-add-relative
'default :family proportional-fam :height proportional-height))
;; keep previously defined monospace fonts the same
(dolist (face font-preserve-default-list)
(add-to-list 'preserve-default-cookies-list
(face-remap-add-relative
face :family default-fam :height default-height)))
(message "Turned on proportional font."))
;; undo changes
(progn (face-remap-remove-relative default-cookie)
(dolist (cookie preserve-default-cookies-list)
(face-remap-remove-relative cookie))
(setq default-cookie nil)
(setq preserve-default-cookies-list nil)
(message "Restored default fonts."))))))
#+END_SRC
*** UTF8 support
Replace LaTeX commands by UTF8 symbols:
#+BEGIN_SRC emacs-lisp
;; (use-package latex-pretty-symbols
;; :ensure t)
#+END_SRC
*** Emojis
As of Emacs v29, displaying and selecting emojis is now built-in via [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Input-Methods.html][input methods]].
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "C-c i e") 'emoji-search)
#+END_SRC
**** COMMENT emacs-emojify
https://github.com/iqbalansari/emacs-emojify
Display and insert emojis in Emacs. Superseded by the built-in support of emojis in Emacs v29.
Tutorial: https://ianyepan.github.io/posts/emacs-emojis/
#+BEGIN_SRC emacs-lisp
(use-package emojify
:pin MELPA
:ensure t
;; :hook (after-init . global-emojify-mode)
:config
(setq emojify-display-style 'unicode
emojify-emoji-styles '(unicode)
emojify-company-tooltips-p t)
(global-set-key (kbd "C-c i e") 'emojify-insert-emoji)
)
#+END_SRC
** Mode line and window labels
Show file path in window title:
#+BEGIN_SRC emacs-lisp
(setq frame-title-format
'(buffer-file-name "%b - %f" ; File buffer
(dired-directory dired-directory ; Dired buffer
(revert-buffer-function "%b" ; Buffer Menu
("%b - Dir: " default-directory))))) ; Plain buffer
#+END_SRC
Show date and time:
#+BEGIN_SRC emacs-lisp
(setq display-time-24hr-format t)
(display-time-mode +1)
#+END_SRC
Fringe style:
#+BEGIN_SRC emacs-lisp
;; (set-face-attribute 'fringe nil :background "#3F3F3F" :foreground "#3F3F3F")
#+END_SRC
*** smart-mode-line
https://github.com/Malabarba/smart-mode-line/
Make the mode line nicer and better readable.
#+BEGIN_SRC emacs-lisp
(use-package smart-mode-line
:ensure t
:init
;; (setq sml/theme 'dark)
(setq sml/no-confirm-load-theme t)
:config
(sml/setup))
#+END_SRC
** Distraction-free mode
*** writeroom-mode
https://github.com/joostkremers/writeroom-mode
A minor mode for Emacs that implements a distraction-free writing mode similar to the famous Writeroom editor for OS X.
#+BEGIN_SRC emacs-lisp
(use-package writeroom-mode
:ensure t
:bind
(:map writeroom-mode-map
("C-M-<" . writeroom-decrease-width)
("C-M->" . writeroom-increase-width)
("C-M-=" . writeroom-adjust-width)
("C-<f10>" . writeroom-toggle-mode-line)
)
)
(global-set-key (kbd "<f10>") 'writeroom-mode)
#+END_SRC
** Overlays
*** ov
https://github.com/emacsorphanage/ov
Package for manipulating overlays. However, it does not affect font-lock or text-properties.
#+BEGIN_SRC emacs-lisp
(use-package ov
:ensure t)
#+END_SRC
** Icons
*** all-the-icons
https://github.com/domtronn/all-the-icons.el
=all-the-icons= makes popular icons available in Emacs.
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons
:ensure t
:if (display-graphic-p))
#+END_SRC
Missing fonts can be installed with =M-x all-the-icons-install-fonts=.
** Debugging
*** font-lock-studio
https://github.com/Lindydancer/font-lock-studio
Interactive debugger for font-lock keywords.
#+BEGIN_SRC emacs-lisp
(use-package font-lock-studio
:ensure t)
#+END_SRC
** Echo area / Messages
https://www.gnu.org/software/emacs/manual/html_node/elisp/The-Echo-Area.html
The *echo area* is used for displaying error messages, messages created with the =message= function, and for echoing keystrokes. It is not to be confused with the [[minibuffer]], although it is shown in the same place of an Emacs window,
Messages from the echo area are also recorded in the =*Messages*= buffer.
*** Format of =*Messages*= buffer
The following code adds timestamps to messages in the =*Messages*= buffer. It is a modified version of https://emacs.stackexchange.com/a/64551/12336.
#+BEGIN_SRC emacs-lisp
(defvar last-message-with-timestamp nil
"Last message with timestamp appended to it.")
(defun add-timestamp-to-message (format-string &rest args)
"Prepend timestamp to each message in message buffer.
FORMAT-STRING and ARGS are used by `message' to print a formatted string.
Enable with (advice-add 'message :before 'add-timestamp-to-message)"
(when (and message-log-max
(not (string-equal format-string "%s%s")))
(let ((formatted-message-string (if args
(apply 'format `(,format-string ,@args))
format-string)))
(unless (string= formatted-message-string last-message-with-timestamp)
(setq last-message-with-timestamp formatted-message-string)
(let ((deactivate-mark nil)
(inhibit-read-only t))
(with-current-buffer "*Messages*"
(goto-char (point-max))
(when (not (bolp))
(newline))
(insert (format-time-string "[%F %T] "))))))))
(advice-add 'message :before 'add-timestamp-to-message)
#+END_SRC
* Minibuffer
** General
Shorten yes/no answers to y/n:
#+BEGIN_SRC emacs-lisp
(fset 'yes-or-no-p 'y-or-n-p)
#+END_SRC
** ido, ivy
Currently, I'm using neither of the two.
*** COMMENT ido
#+BEGIN_SRC emacs-lisp
;; ;; ido improves buffer switching experience
;; (ido-mode 1)
;; (ido-everywhere 1)
;; ;; add vertical mode to ido
;; (use-package ido-vertical-mode
;; :ensure t
;; :config (ido-vertical-mode 1) )
;; ;; add grid mode
;; (use-package ido-grid-mode
;; :ensure t
;; :config (ido-grid-mode 1))
;; ;; add flx to ido
;; (use-package flx-ido
;; :ensure t
;; :config
;; (flx-ido-mode 1)
;; ;; disable ido faces to see flx highlights.
;; (setq ido-enable-flex-matching t)
;; (setq ido-use-faces nil))
#+END_SRC
*** COMMENT Recent files
#+BEGIN_SRC emacs-lisp
;; recent files
(require 'recentf)
(recentf-mode 1)
; 50 files ought to be enough.
(global-set-key (kbd "C-x C-r") 'ido-recentf-open)
(setq recentf-max-saved-items 50)
(defun ido-recentf-open ()
"Use `ido-completing-read' to `find-file' a recent file"
(interactive)
(if (find-file (ido-completing-read "Find recent file: " recentf-list))
(message "Opening file...")
(message "Aborting")))
#+END_SRC
*** COMMENT ivy, counsel
#+BEGIN_SRC emacs-lisp
;; counsel adds fuzzy search to command completion
(use-package counsel
:ensure t
:config
(setq ivy-display-style 'fancy)
(setq ivy-re-builders-alist ; use flx
'((t . ivy--regex-fuzzy)))
(setq ivy-initial-inputs-alist nil) ; omit ^
(setq ivy-wrap t) ;; cycle through results
:bind
("M-x" . counsel-M-x)
("C-ß" . ivy-imenu-anywhere) ; ivy + imenu
)
#+END_SRC
*** COMMENT swiper
#+BEGIN_SRC emacs-lisp
(use-package swiper
:ensure t
:config
(setq ivy-wrap t)
:bind
(("C-s" . swiper)
:map swiper-map
("M-n" . ivy-next-history-element)
("M-p" . ivy-previous-history-element))
)
#+END_SRC
*** COMMENT smex
Smex helps to remember often used commands; used by ido and counsel
#+BEGIN_SRC emacs-lisp
(use-package smex
:ensure t)
#+END_SRC
** imenu
https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html
Imenu is built into Emacs and helps to navigate between "definitions", e.g. defun statements in lisp code, within a buffer.
*** imenu-anywhere
https://github.com/vspinu/imenu-anywhere
Imenu navigation across buffers of the same type (major mode, project).
#+BEGIN_SRC emacs-lisp
(use-package imenu-anywhere
:ensure t)
#+END_SRC
*** COMMENT imenu-list
https://github.com/bmag/imenu-list
Creates an buffer called *Ilist* that is populated with the current buffer's imenu entries.
#+BEGIN_SRC emacs-lisp
(use-package imenu-list
:ensure t
:bind
("C-?" . imenu-list)
:init
(setq imenu-list-focus-after-activation t)
(setq imenu-list-after-jump-hook t)
;; (setq imenu-list-auto-resize t)
(setq imenu-list-position (quote left))
(setq imenu-list-size 30)
:config
(add-hook 'text-mode-hook 'imenu-list-minor-mode)
(add-hook 'prog-mode-hook 'imenu-list-minor-mode)
)
(add-hook 'imenu-list-minor-mode-hook (lambda () (toggle-truncate-lines))) ; FIXME
(setq org-imenu-depth 4)
#+END_SRC
** helm
https://github.com/emacs-helm/helm
https://tuhdo.github.io/helm-intro.html
Emacs framework for incremental completions and narrowing selections.
#+BEGIN_SRC emacs-lisp
(use-package helm
:diminish helm-mode
:init
(progn
;; (require 'helm-config) ; Obsolete since v3.9.1: https://github.com/emacs-helm/helm/commit/e81fbbc687705595ab65ae5cd3bdf93c17a90743
(setq helm-candidate-number-limit 100)
(setq helm-idle-delay 0.0 ; update sources immediately
helm-input-idle-delay 0.01 ; update input quickly
helm-yas-display-key-on-candidate t
helm-M-x-requires-pattern nil
helm-ff-skip-boring-files t
helm-mode-fuzzy-match t ; global fuzzy match
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-M-x-fuzzy-match t
helm-follow-mode-persistent t ; follow candidate in buffer (with C-up/C-down)
helm-imenu-fuzzy-match t
helm-completion-in-region-fuzzy-match t
helm-apropos-fuzzy-match t
helm-autoresize-mode 1 ; re-size the completion window based on number of candidates
helm-adaptive-mode t ; show commonly used commands first
helm-move-to-line-cycle-in-source nil ; if non-nil, cycle only within a source
)
(setq bibtex-completion-bibliography user-bibliography-file
bibtex-completion-library-path user-bibliography-pdf-dir ; directory of PDFs
bibtex-completion-notes-path user-bibliography-notes-dir ; directory of notes
)
;; helm-mini
(setq helm-mini-default-sources
'(helm-source-buffers-list
helm-source-bookmarks
helm-source-recentf
helm-source-buffer-not-found))
(helm-mode)
;; ;; http://emacs.stackexchange.com/a/7896/12336
;; ;; <return> opens directory in helm-find-files, not dired
;; (defun fu/helm-find-files-navigate-forward (orig-fun &rest args)
;; (if (file-directory-p (helm-get-selection))
;; (apply orig-fun args)
;; (helm-maybe-exit-minibuffer)))
;; (advice-add 'helm-execute-persistent-action :around #'fu/helm-find-files-navigate-forward)
;; (define-key helm-find-files-map (kbd "<return>") 'helm-execute-persistent-action)
;; http://emacs.stackexchange.com/a/7896/12336
;; <backspace> before backslash lets helm-find-files move one directory up
(defun fu/helm-find-files-navigate-back (orig-fun &rest args)
(if (= (length helm-pattern) (length (helm-find-files-initial-input)))
(helm-find-files-up-one-level 1)
(apply orig-fun args)))
(advice-add 'helm-ff-delete-char-backward :around #'fu/helm-find-files-navigate-back)
;; ;; https://redd.it/3f55nm
;; ;; Remove . and .. from helm-find-files
;; (advice-add 'helm-ff-filter-candidate-one-by-one
;; :around (lambda (fcn file)
;; (unless (string-match "\\(?:/\\|\\`\\)\\.\\{1,2\\}\\'" file)
;; (funcall fcn file))))
)
:bind (("M-y" . helm-mini)
("C-x C-r" . helm-recentf)
("C-h a" . helm-apropos)
("C-x C-b" . helm-buffers-list)
("C-x b" . helm-buffers-list)
("C-x C-f" . helm-find-files)
("C-x C-y" . helm-show-kill-ring)
("C-x y" . helm-show-kill-ring)
("C-x t" . helm-etags-select)
("C-x C-t" . helm-etags-select)
("C-x SPC" . helm-all-mark-rings)
("C-x C-SPC" . helm-all-mark-rings)
("M-x" . helm-M-x)
("C-s" . helm-occur)
;; ("C-x c s" . helm-swoop)
("C-x c y" . helm-yas-complete)
("C-x c Y" . helm-yas-create-snippet-on-region)
("C-x c SPC" . helm-all-mark-rings)
("C-ß" . helm-imenu)
("C-S-?" . helm-imenu-anywhere)
)
)
(ido-mode -1) ; turn off ido mode, just in case
#+END_SRC
*** COMMENT helm-fuzzier
https://github.com/EphramPerdition/helm-fuzzier
Improves fuzzy matching even more by taking more candidates into account.
Issues:
- [ ] With helm v3.6.4, =helm-fuzzier= breaks the display of candidates in =helm-find-files=.
#+BEGIN_SRC emacs-lisp
(use-package helm-fuzzier
:ensure t
:after helm
:config
(helm-fuzzier-mode +1))
#+END_SRC
*** helm-descbinds
https://github.com/emacs-helm/helm-descbinds
List active key bindings.
#+BEGIN_SRC emacs-lisp
(use-package helm-descbinds
:ensure t
:bind ("C-h b" . helm-descbinds))
#+end_src
*** org-mode
https://github.com/emacs-helm/helm-org
Complete tags with =helm= when using =org-set-tags=:
#+BEGIN_SRC emacs-lisp
(use-package helm-org
:ensure t
:pin MELPA
:config
(add-to-list 'helm-completing-read-handlers-alist '(org-capture . helm-org-completing-read-tags))
(add-to-list 'helm-completing-read-handlers-alist '(org-set-tags . helm-org-completing-read-tags))
)
#+END_SRC
*** helm-swoop
https://github.com/emacsorphanage/helm-swoop
Search buffer while showing matches in a separate buffer.
#+begin_src emacs-lisp
(use-package helm-swoop
:ensure t
:pin MELPA
:config
;; Move up and down like isearch
(define-key helm-swoop-map (kbd "C-r") 'helm-previous-line)
(define-key helm-swoop-map (kbd "C-s") 'helm-next-line)
(define-key helm-multi-swoop-map (kbd "C-r") 'helm-previous-line)
(define-key helm-multi-swoop-map (kbd "C-s") 'helm-next-line)
;; From helm-swoop to helm-multi-swoop-all
(define-key helm-swoop-map (kbd "M-i") 'helm-multi-swoop-all-from-helm-swoop)
;; Instead of helm-multi-swoop-all, you can also use helm-multi-swoop-current-mode
(define-key helm-swoop-map (kbd "M-m") 'helm-multi-swoop-current-mode-from-helm-swoop)
;; If nil, you can slightly boost invoke speed in exchange for text color
(setq helm-swoop-speed-or-color t)
;; Optional face for line numbers
;; Face name is `helm-swoop-line-number-face`
(setq helm-swoop-use-line-number-face t)
;; If you prefer fuzzy matching (seems to be already activated)
;; (setq helm-swoop-use-fuzzy-match t)
;; Do not call helm-swoop with symbol or word at point
(setq helm-swoop-pre-input-function
(lambda () nil))
:bind ("C-c /" . helm-swoop))
#+END_SRC
*** swiper-helm
https://github.com/abo-abo/swiper-helm
Swiper with Helm backend.
Issues:
- [ ] Error: "swiper-helm: Cannot open load file: No such file or directory, helm-match-plugin"
#+BEGIN_SRC emacs-lisp
(use-package swiper-helm
:ensure t
:bind ("C-s" . swiper-helm))
#+END_SRC
*** helm-dash
https://github.com/dash-docs-el/helm-dash
Browse [[https://www.kapeli.com/dash][Dash]] docsets with helm.
=helm-dash= depends on =sqlite3= which you probably have to install manually:
http://sqlite.org/download.html
#+BEGIN_SRC emacs-lisp