forked from jkitchin/scimax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scimax-hydra.el
1542 lines (1312 loc) · 50.3 KB
/
scimax-hydra.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
;;; scimax-hydra.el --- Hydras for scimax -*- lexical-binding: t; -*-
;;; Commentary:
;; The goal of this library is to emulate Spacemacs with hydras. You can access
;; a lot of the commands we use a lot with just 2-3 keystrokes. The hydras are
;; saved in a stack as you visit them so you can go to the previous one with ,
;; (comma). You can get to M-x by pressing x in any of these hydras, and / to
;; undo. Not every command will be shorter, e.g. C-a is shorter than f12 n a,
;; but this shows you tips of what you can do, and doesn't require any chording.
;;
;; This should not get in the way of any regular keybindings as you access all
;; of them through a single dispatch key (I use f12, which is remapped onto the
;; capslock key).
;;
;; At the moment this probably requires scimax, and has a number of Mac specific
;; things in it.
;; https://ericjmritz.wordpress.com/2015/10/14/some-personal-hydras-for-gnu-emacs/
(require 'cl)
(defgroup scimax-hydra nil
"Customization for `scimax-hydra'."
:tag "scimax-hydra")
(defcustom scimax-hydra-key "<f12>"
"Key to bind `scimax/body' to."
:type 'string
:group 'scimax-hydra)
(global-set-key (kbd scimax-hydra-key) 'scimax/body)
;;* scimax-hydra utilities
;; Lexical closure to encapsulate the stack variable.
(lexical-let ((scimax-hydra-stack '()))
(defun scimax-hydra-push (expr)
"Push an EXPR onto the stack."
(push expr scimax-hydra-stack))
(defun scimax-hydra-pop ()
"Pop an expression off the stack and call it."
(interactive)
(let ((x (pop scimax-hydra-stack)))
(when x
(call-interactively x))))
(defun scimax-hydra ()
"Show the current stack."
(interactive)
(with-help-window (help-buffer)
(princ "Scimax-hydra-stack\n")
(pp scimax-hydra-stack)))
(defun scimax-hydra-reset ()
"Reset the stack to empty."
(interactive)
(setq scimax-hydra-stack '())))
(defmacro scimax-open-hydra (hydra)
"Push current HYDRA to a stack.
This is a macro so I don't have to quote the hydra name."
`(progn
(scimax-hydra-push hydra-curr-body-fn)
(call-interactively ',hydra)))
(defun scimax-hydra-help ()
"Show help buffer for current hydra."
(interactive)
(with-help-window (help-buffer)
(with-current-buffer (help-buffer)
(unless (featurep 'emacs-keybinding-command-tooltip-mode)
(require 'emacs-keybinding-command-tooltip-mode))
(emacs-keybinding-command-tooltip-mode +1))
(let ((s (format "Help for %s\n" hydra-curr-body-fn)))
(princ s)
(princ (make-string (length s) ?-))
(princ "\n"))
(princ (mapconcat
(lambda (head)
(format "%s%s"
;; key
(s-pad-right 10 " " (car head))
;; command
(let* ((hint (if (stringp (nth 2 head))
(concat " " (nth 2 head))
""))
(cmd (cond
;; quit
((null (nth 1 head))
"")
;; a symbol
((symbolp (nth 1 head))
(format "`%s'" (nth 1 head)))
((and (listp (nth 1 head))
(eq 'scimax-open-hydra (car (nth 1 head))))
(format "`%s'" (nth 1 (nth 1 head))))
((listp (nth 1 head))
(with-temp-buffer
(pp (nth 1 head) (current-buffer))
(let ((fill-prefix (make-string 10 ? )))
(indent-code-rigidly
(save-excursion
(goto-char (point-min))
(forward-line)
(point))
(point-max) 10))
(buffer-string)))
(t
(format "%s" (nth 1 head)))))
(l1 (format "%s%s" (s-pad-right 50 " " (car (split-string cmd "\n"))) hint))
(s (s-join "\n" (append (list l1) (cdr (split-string cmd "\n"))))))
(s-pad-right 50 " " s))))
(symbol-value
(intern
(replace-regexp-in-string
"/body$" "/heads"
(symbol-name hydra-curr-body-fn))))
"\n"))))
(defhydra scimax-base (:color blue)
"base"
("," scimax-hydra-pop "back" :color blue)
("x" counsel-M-x "M-x")
("C-s" save-buffer "Save")
("/" undo-tree-undo "undo" :color red)
("\\" undo-tree-redo "redo" :color red)
("8" (switch-to-buffer "*scratch*") "*scratch*")
("?" scimax-hydra-help "Menu help")
("." scimax-dispatch-mode-hydra "Major mode hydras")
("u" (hydra--universal-argument current-prefix-arg) "C-u" :color red)
("q" nil "quit"))
;;* scimax hydra
(defhydra scimax (:color blue :inherit (scimax-base/heads)
:columns 4 :body-pre (scimax-hydra-reset)
:idle 0.5)
"scimax"
("a" (scimax-open-hydra scimax-applications/body) "Applications")
("b" (scimax-open-hydra scimax-buffers/body) "Buffers")
;; c for user? compile?
;; d ?
("e" (scimax-open-hydra scimax-errors/body) "Edit/Errors")
("f" (scimax-open-hydra scimax-files/body) "Files")
("g" (scimax-open-hydra scimax-google/body) "Google")
("h" (scimax-open-hydra scimax-help/body) "Help")
("i" (scimax-open-hydra scimax-insert/body) "Insert")
("j" (scimax-open-hydra scimax-jump/body) "Jump")
("k" (scimax-open-hydra scimax-bookmarks/body) "Bookmarks")
("l" (scimax-open-hydra scimax-lisp/body) "Lisp")
("m" (scimax-open-hydra scimax-minor-modes/body) "Minor modes/mark")
("M" (scimax-open-hydra scimax-smerge/body) "smerge")
("s-m" scimax-dispatch-mode-hydra "Major mode hydras")
("n" (scimax-open-hydra scimax-navigation/body) "Navigation")
("o" (scimax-open-hydra scimax-org/body) "org")
("p" (scimax-open-hydra hydra-projectile/body) "Project")
;; q is for quit, don't reassign
("r" (scimax-open-hydra scimax-registers/body) "Registers/resume")
("s" (scimax-open-hydra scimax-search/body) "Search")
("t" (scimax-open-hydra scimax-text/body) "Text")
;; u is a prefix arg, do not reassign
("v" (scimax-open-hydra scimax-version-control/body) "Version control")
("w" (scimax-open-hydra scimax-windows/body) "Windows")
;; x is for M-x, don't reassign
("z" (scimax-open-hydra scimax-customize/body) "Customize"))
;;** applications
(defun scimax-app-hints ()
"Calculate some variables for the applications hydra."
(setq elfeed-count
(s-pad-right 12 " "
(if (get-buffer "*elfeed-search*")
(format "RSS(%s)"
(car (s-split "/" (with-current-buffer "*elfeed-search*"
(elfeed-search--count-unread)))))
"RSS(?)"))))
(defhydra scimax-applications (:hint nil
:pre (scimax-app-hints)
:color blue
:inherit (scimax-base/heads))
"applications"
("a" (org-db-agenda "+2d") "agenda" :column "Emacs")
("d" dired "dired" :column "Emacs")
("j" scimax-journal/body "journal" :column "Emacs")
("n" nb-hydra/body "notebook" :column "Emacs")
("r" elfeed "elfeed" :column "Emacs")
("b" bash "bash" :column "OS")
("f" finder "Finder" :column "OS")
("e" eshell "eshell" :column "OS")
("c" google-calendar "Calendar" :column "Web")
("g" google "Google" :column "Web")
("o" (scimax-open-hydra scimax-office/body) "MS Office" :column "Web")
("G" (scimax-open-hydra scimax-gsuite/body) "GSuite" :column "Web")
("s" slack/body "Slack" :column "Web")
("k" package-list-packages "List packages" :column "commands")
("m" compose-mail "Compose mail" :column "commands"))
(defhydra scimax-office (:color blue)
"Office"
("e" excel"Excel")
("p" powerpoint "Powerpoint")
("w" word "Word"))
(defhydra scimax-gsuite (:color blue)
"GSuite"
("v" (browse-url "https://drive.google.com/drive/u/0/my-drive") "GDrive")
("d" (browse-url "https://docs.google.com/document/u/0/" "GDoc"))
("h" (browse-url "https://docs.google.com/spreadsheets/u/0/" "GSheet"))
("s" (browse-url "https://docs.google.com/presentation/u/0/" "GSlides"))
("j" (browse-url "https://jamboard.google.com/" "Jamboard")))
;;** buffers
(defhydra scimax-buffers (:color blue :inherit (scimax-base/heads) :columns 3 :hint nil)
"
buffer
Switch ^Kill Split Misc
------------------------------------------------------------------
_a_: ace-window _k_: kill _2_: below _l_: list (%(length (buffer-list)))
_b_: switch buffer _K_: kill others _3_: right _r_: rename
_o_: other-window _A_: kill all
_O_: switch other win _m_: kill matching
_n_: next buffer _0_: delete win
_p_: prev buffer _1_: delete other
_s_: scratch _4_: kill buf/win
_f_: other frame _6_: kill some
_F_: buf in frame _y_: bury
------------------------------------------------------------------
"
("0" delete-window)
("1" delete-other-windows)
("2" split-window-below)
("3" split-window-right)
("5" make-frame-command)
("4" kill-buffer-and-window)
("6" kill-some-buffers)
("a" ace-window :color red)
("b" switch-to-buffer)
("A" kill-all-buffers)
("f" other-frame :color red)
("F" switch-to-buffer-other-frame)
("k" kill-this-buffer :color red)
("K" kill-other-buffers)
("l" ibuffer)
("m" kill-matching-buffers :color red)
("n" next-buffer :color red)
("o" other-window :color red)
("O" switch-to-buffer-other-window :color red)
("p" previous-buffer :color red)
("s" (switch-to-buffer "*scratch*"))
("r" rename-buffer)
("y" bury-buffer))
;;** drag
(defhydra scimax-drag (:color red :inherit (scimax-base/heads) :hint nil)
("<left>" drag-stuff-left :color red)
("<right>" drag-stuff-right :color red)
("<up>" drag-stuff-up :color red)
("<down>" drag-stuff-down :color red))
;;** edit/errors
(defhydra scimax-errors (:color blue :inherit (scimax-base/heads) :columns 3 :hint nil)
"
edit/errors
Edit Errors
------------------------------------------------------------------
_a_: edit abbrevs _n_: next error
_c_: copy (dwim) _p_: prev error
_k_: kill (dwim)
_v_: paste
_V_: paste ring
------------------------------------------------------------------
"
("a" edit-abbrevs)
("c" scimax-copy-dwim)
("v" yank)
("V" counsel-yank-pop)
("k" scimax-kill-dwim)
("n" next-error :color red)
("p" previous-error :color red))
;;** files
(defhydra scimax-files (:color blue :inherit (scimax-base/heads) :columns 3 :hint nil)
"
files
------------------------------------------------------------------
_f_: find file _R_: rename _r_: recentf
_4_: other window _k_: close _l_: locate
_5_: other frame _d_: dired
_p_: ffap
------------------------------------------------------------------"
("4" find-file-other-window)
("5" find-file-other-frame)
("b" describe-file)
("d" (dired default-directory))
("f" find-file)
("k" kill-this-buffer)
("l" counsel-locate)
("p" ffap)
("r" counsel-recentf)
("R" write-file))
;;** google
(defhydra scimax-google (:color blue :inherit (scimax-base/heads) :columns 3)
"google"
("e" google-this-error "Error")
("f" google-this-forecast "Forecast")
("g" google-this-region "Region")
("k" google-this-lucky-search "Lucky")
("l" google-this-line "Line")
("m" google-maps "Maps")
("r" google-this-ray "Ray")
("s" google-this-search "Search")
("t" google-this "This")
("w" google-this-word "Word")
("y" google-this-symbol "Symbol"))
;;** help
(defhydra scimax-help (:color blue :inherit (scimax-base/heads) :columns 3)
"help"
("a" apropos "Apropos" :column "Code")
("c" describe-command "Command" :column "Code")
("f" describe-function "Function" :column "Code")
("v" describe-variable "Variable" :column "Code")
("g" view-echo-area-messages "Messages" :column "Code")
("o" ore "Org explorer" :column "Point")
("t" describe-text-properties "Text properties" :column "Point")
("s" describe-syntax "Syntax" :column "Point")
("h" describe-theme "Theme" :column "Thing")
("k" describe-key "Key" :column "Thing")
("K" describe-keymap "Keymap" :column "Thing")
("m" describe-mode "Mode" :column "Thing")
("p" describe-package "Package" :column "Thing")
("S" scimax-help "Scimax help" :column "Documentation")
("e" info-emacs-manual "Emacs manual" :column "Documentation")
("T" help-with-tutorial "Emacs tutorial" :column "Documentation")
("i" info "Info" :column "Documentation")
("w" woman "Unix manual pages" :column "Documentation"))
;;** insert
(defhydra scimax-insert (:color blue :inherit (scimax-base/heads) :columns 3)
"insert stuff"
("b" insert-buffer "Buffer")
("c" org-db-contacts "Contact")
("e" ivy-insert-org-entity "Org-entity")
("f" insert-file "File contents")
("k" org-inlinetask-insert-task "org task")
;; ("l" ) a link function...
("L" lorem-ipsum-insert-paragraphs "Lorem ipsum" :color red)
("u" insert-char "Unicode char")
("p" insert-parentheses "Parentheses")
("r" insert-register "Register")
("ss" screenshot "screenshot")
("sp" pngpaste "Paste image")
("st" tesseract "screenshot with OCR")
("t" org-time-stamp-inactive "Inactive [timestamp]")
("T" org-time-stamp "Active <timestamp>")
("y" ivy-yasnippet "yasnippet"))
;;** jump
(defhydra scimax-jump (:color blue :inherit (scimax-base/heads) :columns 3)
"jump"
("<" beginning-of-buffer "Beginning of buffer" :column "line")
(">" end-of-buffer "End of buffer" :column "line")
("a" beginning-of-line "Beginning of line" :column "line")
("e" end-of-line "End of line" :column "line")
("g" goto-line "Goto line" :column "line")
("l" (scimax-open-hydra scimax-jump-line/body) "Line" :column "line")
("c" (scimax-open-hydra scimax-jump-char/body) "Char" :column "text")
("w" (scimax-open-hydra scimax-jump-word/body) "Word" :column "text")
("s" avy-jump-to-sentence "Sentence" :column "text")
("r" avy-jump-to-paragraph "Paragraph" :column "text")
("y" (scimax-open-hydra scimax-jump-symbol/body) "Symbol" :column "text")
("h" org-db-headings "org-db-heading" :column "org")
("d" org-db/body "org-db hydra" :column "org")
("k" ace-link "Link" :column "org")
("o" (scimax-open-hydra scimax-jump-org/body) "Org" :column "org")
("3" scimax-ob-jump-to-src-block "src block" :column "org")
("pp" counsel-projectile-switch-project "project" :column "Project")
("pb" counsel-projectile-switch-to-buffer "buffer" :column "Project")
("pf" projectile-find-file "file" :column "Project")
("ph" ivy-org-jump-to-project-headline "headline" :column "Project")
("b" counsel-ibuffer "Buffer" :column "misc")
("n" ace-window "Ace window" :column "misc")
("f" counsel-recentf "Recent file" :column "misc")
("j" avy-goto-char-timer "avy timer" :column "misc")
)
(defhydra scimax-jump-char (:color blue :inherit (scimax-base/heads) :columns 3)
"char"
("c" avy-goto-char "Char")
("l" avy-goto-char-in-line "In line")
("t" avy-goto-char-timer "Timer")
("2" avy-goto-char-2 "Char2")
("a" avy-goto-char-2-above "Above")
("b" avy-goto-char-2-below "Below"))
(defhydra scimax-jump-line (:color blue :inherit (scimax-base/heads) :columns 3)
"line"
("l" avy-goto-line "Line")
("a" avy-goto-line-above "Above")
("b" avy-goto-line-below "Below"))
(defhydra scimax-jump-org (:color blue :inherit (scimax-base/heads) :columns 3)
"org"
("v" ivy-org-jump-to-visible-headline "Visible heading" :column "heading")
("h" ivy-org-jump-to-heading "Heading" :column "heading")
("o" ivy-org-jump-to-open-headline "Open heading" :column "heading")
("d" ivy-org-jump-to-heading-in-directory "Directory heading" :column "heading")
("p" ivy-org-jump-to-project-headline "Project heading" :column "heading")
("a" ivy-org-jump-to-agenda-heading "Agenda heading" :column "heading")
("bb" scimax-ob-jump-to-src-block "Jump to src-block" :column "block")
("bv" scimax-ob-jump-to-visible-src-block "Jump to visible src-block" :column "block")
("bi" scimax-ob-jump-to-inline-src "Jump to inline src" :column "block")
("k" ace-link "link" :column "misc"))
(defhydra scimax-jump-word (:color blue :inherit (scimax-base/heads) :columns 3)
"word"
("w" avy-goto-word-1 "word1")
("l" avy-jump-to-word-in-line "in line")
("0" avy-goto-word-0 "word0")
("a" avy-goto-word-0-above "above-0")
("A" avy-goto-word-1-above "above-1")
("b" avy-goto-word-0-below "below0")
("B" avy-goto-word-1-below "below1")
("o" avy-goto-word-or-subword-1 "word or subword")
("s" avy-goto-subword-0 "subword-0")
("S" avy-goto-subword-1 "subword-1"))
(defhydra scimax-jump-symbol (:color blue :inherit (scimax-base/heads) :columns 3)
"symbol"
("y" avy-goto-symbol-1 "symbol")
("a" avy-goto-symbol-1-above "Above")
("b" avy-goto-symbol-1-below "below"))
;;** bookmarks
(when (eq 'darwin system-type)
;; this is in org-contrib, but I actually keep a copy of my own. It is not
;; part of scimax though.
(require 'org-mac-link))
(defun scimax-bookmark-chrome (nickname)
"Save the url currently open as a bookmark."
(interactive (list (bmkp-completing-read-lax "Nickname: ")))
(bmkp-url-target-set (car (split-string (org-as-mac-chrome-get-frontmost-url) "::"))
nil nickname))
(defhydra scimax-bookmarks (:color blue :inherit (scimax-base/heads) :columns 3)
"bookmarks"
("k" bookmark-jump "jump")
("l" bookmark-bmenu-list "list")
("sc" scimax-bookmark-chrome "save chrome url")
("su" bmkp-url-target-set "save url")
("n" bookmark-set "new"))
;;** lisp
(defhydra scimax-lisp (:color blue :inherit (scimax-base/heads) :columns 3 :hint nil)
"lisp"
("a" eval-buffer "eval buffer")
("c" byte-recompile-file "byte-compile file")
("d" (eval-defun t) "debug defun")
("z" (eval-defun nil) "stop edebug")
("e" eval-defun "eval defun")
("v" eval-last-sexp "eval last sexp")
("g" (eval-region (point-min) (point)) "eval region")
("h" (describe-function 'lispy-mode) "lispy help")
("i" ielm "ielm")
("l" load-file "load file")
("L" counsel-load-library "load library")
("f" counsel-find-library "find library")
("r" eval-region "region")
("t" toggle-debug-on-error "toggle debug")
("y" edebug-on-entry "debug on entry"))
;;** mark/minor modes
(defhydra scimax-minor-modes (:color blue :inherit (scimax-base/heads) :columns 3 :hint nil)
"
minor modes and marks
Marks minor-modes
------------------------------------------------------------------
_w_: mark word _i_: aggressive indent
_n_: mark sentence _b_: org-bullets
_p_: mark paragraph _k_: emacs-keybindings
_g_: mark page _l_: nlinum
_s_: mark sexp _r_: rainbow
_d_: mark defun _on_: org-numbered-headings
_a_: mark buffer
_e_: mark org-element
_m_: set mark
_j_: jump to mark
------------------------------------------------------------------
"
("i" aggressive-indent-mode)
("b" org-bullets-mode)
("k" emacs-keybinding-command-tooltip-mode)
("l" nlinum-mode)
("r" rainbow-mode)
("a" mark-whole-buffer)
("d" mark-defun)
("e" org-mark-element)
("g" mark-page)
("j" pop-to-mark-command)
("m" set-mark-command)
("n" mark-end-of-sentence)
("on" scimax-numbered-org-mode)
("p" mark-paragraph)
("s" mark-sexp)
("w" mark-word))
;;** navigation
(defvar scimax-hydra-modes (make-ring 4)
"Holds list of navigation modes.")
(ring-insert scimax-hydra-modes 'scimax-nav-paragraph/body)
(ring-insert scimax-hydra-modes 'scimax-nav-sentence/body)
(ring-insert scimax-hydra-modes 'scimax-nav-word/body)
(ring-insert scimax-hydra-modes 'scimax-navigation/body)
(defvar scimax-hydra-mode-counter 0
"Integer counter for current mode.")
(defun scimax-hydra-cycle-navigation-mode (&optional arg)
(interactive "P")
(if arg
(cl-decf scimax-hydra-mode-counter)
(cl-incf scimax-hydra-mode-counter))
(eval `(scimax-open-hydra ,(ring-ref scimax-hydra-modes scimax-hydra-mode-counter))))
(defhydra scimax-navigation (:color red :inherit (scimax-base/heads)
:columns 4 :hint nil
:pre (setq scimax-hydra-mode-counter 0))
"
navigation
-----------------------------------------------------------------------------------
_j_: ← _k_: ↑ _l_: ↓ _;_: → _i_: imenu
_a_: beginning of line _e_: end of line _<_: beginning of buffer _>_: end of buffer
_H-w_: beginning of word _H-s_: beginning of sentence _H-p_: beginning of paragraph
_s-w_: end of word _s-s_: end of sentence _s-p_: end of paragraph
_z_: jump
_f_: delete forward _d_: delete backward
_t_: transpose chars
_<tab>_: %(ring-ref scimax-hydra-modes (+ 1 scimax-hydra-mode-counter)) _S-<tab>_: %(ring-ref scimax-hydra-modes (- scimax-hydra-mode-counter 1))
-----------------------------------------------------------------------------------
"
("j" backward-char)
(";" forward-char)
("k" previous-line)
("l" next-line)
("i" counsel-imenu)
("a" beginning-of-line)
("e" end-of-line)
("f" delete-char :color red)
("d" backward-delete-char :color red)
("<" beginning-of-buffer)
(">" end-of-buffer)
("t" transpose-chars)
("z" (scimax-open-hydra scimax-jump/body) :color blue)
("H-w" backward-word)
("H-s" backward-sentence)
("H-p" backaward-paragraph)
("s-p" forward-paragraph)
("s-w" forward-word)
("s-s" forward-sentence)
("<tab>" scimax-hydra-cycle-navigation-mode :color blue)
("S-<tab>" (scimax-hydra-cycle-navigation-mode t) :color blue))
(defhydra scimax-nav-word (:color red :inherit (scimax-base/heads)
:columns 4 :hint nil
:pre (setq scimax-hydra-mode-counter 1))
"
word navigation
----------------------------
_j_: ← _k_: ↑ _l_: ↓ _;_: →
_a_: beginning of line _e_: end of line _i_: imenu
_f_: kill forward _d_: kill backward _m_: Mark word
_t_: transpose words
_z_: jump
_<tab>_: %(ring-ref scimax-hydra-modes (+ 1 scimax-hydra-mode-counter)) _S-<tab>_: %(ring-ref scimax-hydra-modes (- scimax-hydra-mode-counter 1))
------------------------------------------------------------------"
("j" backward-word)
(";" forward-word)
("k" previous-line)
("l" next-line)
("<" beginning-of-buffer)
(">" end-of-buffer)
("i" counsel-imenu)
("a" beginning-of-line)
("e" end-of-line)
("f" (kill-word 1))
("d" backward-kill-word)
("t" transpose-words)
("z" (scimax-open-hydra scimax-jump/body) :color blue)
("m" mark-word)
("<tab>" (scimax-hydra-cycle-navigation-mode) :color blue)
("S-<tab>" (scimax-hydra-cycle-navigation-mode t) :color blue))
(defhydra scimax-nav-sentence (:color red :inherit (scimax-base/heads) :columns 4 :hint nil
:pre (setq scimax-hydra-mode-counter 2))
"
sentence
_j_: ← _k_: ↑ _l_: ↓ _;_: →
_f_: kill forward _d_: kill backward
_t_: transpose sentences
_z_: jump
_<tab>_: %(ring-ref scimax-hydra-modes (+ 1 scimax-hydra-mode-counter)) _S-<tab>_: %(ring-ref scimax-hydra-modes (- scimax-hydra-mode-counter 1))
------------------------------------------------------------------"
("j" backward-sentence)
(";" forward-sentence)
("k" previous-line)
("l" next-line)
("d" (kill-sentence -1))
("f" kill-sentence)
("t" transpose-sentences)
("m" (unless (sentence-beginning-p)
(backward-sentence)
(set-mark (point))
(forward-sentence)))
("z" (scimax-open-hydra scimax-jump/body) :color blue)
("<tab>" scimax-hydra-cycle-navigation-mode :color blue)
("S-<tab>" (scimax-hydra-cycle-navigation-mode t) :color blue))
(defhydra scimax-nav-paragraph (:color red :inherit (scimax-base/heads) :columns 4 :hint nil
:pre (setq scimax-hydra-mode-counter 3))
"
paragraph
_j_: ← _k_: ↑ _l_: ↓ _;_: →
_f_: kill forward _d_: kill backward
_t_: transpose paragraphs _m_: mark paragraph
_z_: jump
_<tab>_: %(ring-ref scimax-hydra-modes (+ 1 scimax-hydra-mode-counter)) _S-<tab>_: %(ring-ref scimax-hydra-modes (- scimax-hydra-mode-counter 1))
------------------------------------------------------------------"
("j" backward-paragraph)
(";" forward-paragraph)
("k" previous-line)
("l" next-line)
("d" (kill-paragraph -1))
("f" (kill-paragraph nil))
("t" transpose-paragraphs)
("m" mark-paragraph)
("z" (scimax-open-hydra scimax-jump/body) :color blue)
("<tab>" scimax-hydra-cycle-navigation-mode :color blue)
("S-<tab>" (scimax-hydra-cycle-navigation-mode t) :color blue))
;;** org
(defhydra scimax-org (:color blue :inherit (scimax-base/heads) :columns 3)
"org-mode"
("'" org-edit-special "edit")
("a" org-agenda "agenda")
("b" (scimax-open-hydra scimax-org-block/body) "block hydra")
("cc" org-ctrl-c-ctrl-c "C-c C-c")
("sl" scimax-store-link "store link")
("il" org-insert-link "insert link")
("d" (scimax-open-hydra scimax-org-db/body) "org-db hydra")
("e" org-export-dispatch "Export")
("E" (scimax-open-hydra hydra-ox/body) "export hydra")
("g" org-babel-tangle "tangle")
("h" ivy-org-jump-to-heading "jump to heading")
("I" org-clock-in "clock in")
("O" org-clock-out "clock out")
("n" outline-next-heading "next heading" :color red)
("p" outline-previous-heading "previous heading" :color red)
("<tab>" org-cycle "cycle" :color red)
("r" (scimax-open-hydra scimax-org-ref/body) "org-ref")
("t" (scimax-open-hydra scimax-org-toggle/body) "toggle"))
(defhydra scimax-org-block (:color red :inherit (scimax-base/heads) :columns 3)
"org blocks"
("r" org-babel-remove-result "clear result")
("<return>" org-babel-execute-src-block "execute")
("S-<return>" scimax-ob-execute-and-next-block "execute and next")
("M-<return>" (scimax-ob-execute-and-next-block t) "execute and new")
("n" org-next-block "next block")
("p" org-previous-block "previous block")
("-" scimax-ob-split-src-block "split block")
("k" scimax-ob-kill-block-and-results "kill")
("w" scimax-ob-copy-block-and-results "copy")
("y" yank "paste")
("c" scimax-ob-clone-block "clone")
("h" scimax-ob-edit-header "edit header")
("v" scimax-jump-to-visible-block "jump to visible")
("j" scimax-jump-to-block "jump to block")
("S-<up>" scimax-ob-move-src-block-up "move up")
("S-<down>" scimax-ob-move-src-block-down "move down"))
(defun scimax-installed-latex-packages ()
(if (get 'scimax-installed-latex-packages 'packages)
(get 'scimax-installed-latex-packages 'packages)
(when
(executable-find "tlmgr")
(require 'async)
(async-start
`(lambda ()
(require 'cl-lib)
(mapcar
(lambda (s)
(second (split-string (first (split-string s ":")) " ")))
(cl-loop for line in (process-lines ,(executable-find "tlmgr")
"info" "--only-installed")
if (and (stringp line) (string= "i" (substring line 0 1)))
collect line)))
(lambda (result)
(put 'scimax-installed-latex-packages 'packages result))))
'("Getting packages. Try later")))
(defun scimax-insert-latex-package ()
(interactive)
(insert (format "#+latex_header: \\usepackage{%s}"
(completing-read "Package: " (scimax-installed-latex-packages)))))
(defhydra scimax-org-ref (:color blue :inherit (scimax-base/heads) :columns 3)
"org-ref"
("b" org-ref-insert-bibliography-link "bibliography")
("s" org-ref-insert-bibliographystyle-link "bibliographystyle")
("p" scimax-insert-latex-package "package")
("c" org-ref-insert-link "cite")
("l" (org-ref-insert-link '(16)) "label")
("r" (org-ref-insert-link '(4)) "ref")
("o" org-ref "org-ref"))
(defhydra scimax-org-db (:color blue :inherit (scimax-base/heads) :columns 3)
"org-db"
("c" org-db-contacts "contact")
("h" org-db-headings "heading")
("f" org-db-files "file")
("l" org-db-locations "location")
("k" org-db-links "link")
("r" org-db-recent-files "recent file")
("t" org-db-hashtags "hashtag")
("2" org-db-@ "@-link"))
(defhydra scimax-org-toggle (:color blue :inherit (scimax-base/heads) :columns 3)
"toggle"
("e" org-toggle-pretty-entities "pretty entities")
("i" org-toggle-inline-images "images")
("l" org-latex-preview "latex"))
;; *** export
;; adapted from https://github.com/abo-abo/hydra/blob/master/hydra-ox.el
(defhydradio hydra-ox ()
(body-only "Export only the body.")
(export-scope "Export scope." [buffer subtree])
(async-export "When non-nil, export async.")
(visible-only "When non-nil, export visible only")
(force-publishing "Toggle force publishing"))
(defhydra hydra-ox-html (:color blue)
"ox-html"
("H" (org-html-export-as-html
hydra-ox/async-export
(eq hydra-ox/export-scope 'subtree)
hydra-ox/visible-only
hydra-ox/body-only)
"As HTML buffer")
("h" (org-html-export-to-html
hydra-ox/async-export
(eq hydra-ox/export-scope 'subtree)
hydra-ox/visible-only
hydra-ox/body-only) "As HTML file")
("o" (org-open-file
(org-html-export-to-html
hydra-ox/async-export
(eq hydra-ox/export-scope 'subtree)
hydra-ox/visible-only
hydra-ox/body-only)) "As HTML file and open")
("q" nil "quit"))
(defhydra hydra-ox-latex (:color blue)
"ox-latex"
("L" org-latex-export-as-latex "As LaTeX buffer")
("l" org-latex-export-to-latex "As LaTeX file")
("p" org-latex-export-to-pdf "As PDF file")
("o" (org-open-file (org-latex-export-to-pdf)) "As PDF file and open")
("b" hydra-ox/body "back")
("q" nil "quit"))
(defhydra hydra-ox ()
"
_C-b_ Body only: % -15`hydra-ox/body-only^^^ _C-v_ Visible only: %`hydra-ox/visible-only
_C-s_ Export scope: % -15`hydra-ox/export-scope _C-f_ Force publishing: %`hydra-ox/force-publishing
_C-a_ Async export: %`hydra-ox/async-export
"
("C-b" (hydra-ox/body-only) nil)
("C-v" (hydra-ox/visible-only) nil)
("C-s" (hydra-ox/export-scope) nil)
("C-f" (hydra-ox/force-publishing) nil)
("C-a" (hydra-ox/async-export) nil)
("h" hydra-ox-html/body "Export to HTML" :exit t)
("l" hydra-ox-latex/body "Export to LaTeX" :exit t)
("n" ox-ipynb-export-to-ipynb-file-and-open "Jupyter" :exit t)
("q" nil "quit"))
;;** project
;; See also https://github.com/abo-abo/hydra/wiki/Projectile
(defhydra hydra-projectile (:color teal :hint nil)
"
PROJECTILE: %(projectile-project-root)
"
("A" projectile-add-known-project "Add project" :column "projects")
("C" projectile-configure-project "Configure" :column "build")
("D" projectile-dired "Dired" :column "Files")
("E" projectile-edit-dir-locals "dir-locals.el" :column "projects")
("F" projectile-find-file-in-known-projects "Find in projects" :column "Files")
("I" projectile-ibuffer "ibuffer" :column "buffers")
("P" projectile-test-project "Run tests" :column "build")
("R" projectile-regenerate-tags "Rebuild tags" :column "search")
("S" projectile-save-project-buffers "Save buffers" :column "buffers")
("T" projectile-find-test-file)
("V" projectile-browse-dirty-projects "Dirty projects" :column "projects")
("X" projectile-remove-known-project "Remove project" :column "projects")
("a" projectile-find-other-file "Find other file" :column "Files")
("b" projectile-switch-to-buffer "Switch buffer" :column "buffers")
("c" projectile-compile-project "Compile" :column "build")
("d" projectile-find-dir "Find dir" :column "Files")
("e" projectile-recentf "Recentf" :column "Files")
("f" projectile-find-file "Find file" :column "Files")
("g" projectile-find-file-dwim "Find dwim" :column "Files")
("i" projectile-invalidate-cache "invalidate cache" :column "projects")
("j" projectile-find-tag "find tag" :column "search")
("k" projectile-kill-buffers "Kill buffers" :column "buffers")
("l" projectile-find-file-in-directory "Find in dir" :column "Files")
("m" projectile-multi-occur "moccur" :column "search")
("p" projectile-switch-project "Switch" :column "projects")
;; ("q" projectile-switch-open-project "Switch to open" :column "projects")
("q" nil "quit")
("r" projectile-replace "Replace" :column "search")
("t" projectile-toggle-between-implementation-and-test)
("u" projectile-run-project "Run" :column "build")
("v" projectile-vc "vc" :column "build")
("z" projectile-cache-current-file "Cache file" :column "projects")
("<return>" (cl-loop for readme in '("readme.org"
"README.org")
when (file-exists-p readme)
do
(find-file readme)
(cl-return)) "Open readme?")
("x1" projectile-run-shell-command-in-root "Run cmd" :column "cmd")
("x7" projectile-run-async-shell-command-in-root "Run async cmd" :column "cmd")
("xe" projectile-run-eshell "eshell" :column "cmd")
("xi" projectile-run-ielm "ielm" :column "cmd")
("xs" projectile-run-shell "shell" :column "cmd")
("xt" projectile-run-term "term" :column "cmd")
("sg" projectile-grep "Grep" :column "search")
("sr" projectile-ripgrep "Ripgrep" :column "search")
("ss" projectile-ag "ag" :column "search")
("so" ivy-org-jump-to-project-headline "org heading" :column "search")
("M-." xref-find-definitions "xref find" :column "search")
("M-," xref-pop-marker-stack "xref pop" :column "search")
("M-/" xref-find-apropos "xref apropos" :column "search"))
;;** registers/resume/replace
(defhydra scimax-registers (:color blue :inherit (scimax-base/heads) :columns 3)
"
register/resume/replace
Register Resume Replace
------------------------------------------------------------------
_j_: jump to register _v_: ivy resume _q_: query replace
_i_: insert register ^ ^ _x_: regexp replace
_c_: copy to register
_a_: append to register
_n_: number to register
_p_: point to register
_w_: window conf to register
_f_: frameset to register
_l_: list registers
------------------------------------------------------------------"
("a" append-to-register)
("c" copy-to-register)
("f" frameset-to-register)
("i" insert-register)
("j" jump-to-register)
("l" list-registers)
("n" number-to-register)
("p" point-to-register)
("q" query-replace)
("v" ivy-resume)
("w" window-configuration-to-register)
("x" query-replace-regexp))
;;** search
(defhydra scimax-search (:color blue :inherit (scimax-base/heads) :columns 3)
"search"
("a" swiper-all "swiper-all")
("cg" counsel-ag "counsel ag")
("g" counsel-git-grep "grep")
("m" multi-moccur "moccur")
("o" occur "occur")
("pa" projectile-ag "project ag")
("pg" projectile-grep "project grep")
("pr" projectile-ripgrep "project-ripgrep")
("po" projectile-multi-occur "project multi-occur")
("r" isearch-backward "search back")
("s" counsel-grep-or-swiper "grep-or-swiper")
("t" counsel-pt "pt"))
;;** text
(defhydra scimax-text (:color blue :inherit (scimax-base/heads) :columns 3)
"text"
("A" (mark-whole-buffer) "Select all")
("c" kill-ring-save "Copy")
("C" capitalize-dwim "Capitalize" :color red)
("d" downcase-dwim "Downcase" :color red)
("k" kill-region "Cut")
("l" kill-whole-line "Kill line" :color red)
("m" set-mark-command "Set mark" :color red)
("n" (scimax-open-hydra scimax-narrow/body) "narrow")
("s" (scimax-open-hydra scimax-spellcheck/body) "spell-check")
("S" sentence-case-region "Sentence case" :color red)
("t" (scimax-open-hydra scimax-transpose/body) "transpose")
("u" upcase-dwim "Upcase" :color red)
("v" yank "paste")
("w" count-words "count words")
("y" counsel-yank-pop "yank ring")
(";" comment-dwim "comment")
(":" uncomment-region "uncomment")