-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpel--keys-macros.el
1673 lines (1541 loc) · 77.9 KB
/
pel--keys-macros.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
;;; pel--keys-macros.el --- Key binding macros. -*- lexical-binding: t; -*-
;; Created : Tuesday, September 1 2020.
;; Author : Pierre Rouleau <[email protected]>
;; Time-stamp: <2025-01-10 10:50:47 EST, updated by Pierre Rouleau>
;; This file is part of the PEL package.
;; This file is not part of GNU Emacs.
;; Copyright (C) 2020, 2021, 2022, 2023, 2024, 2025 Pierre Rouleau
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; --------------------------------------------------------------------------
;;; Commentary:
;;
;; The functions and macros defined in this file are used by pel_keys.el to
;; create specialized key bindings and to manipulate customization groups.
;; To have a name show up in which-key 'menu', a named function is required,
;; otherwise all we see is 'prefix' which is not meaningful.
;; The macros in this file help simplify/reduce the lines of code used to
;; create the key bindings for functions that open the customization groups
;; PEL configuration and for Emacs groups.
;;
;; The following lists the functions ('-'), and macros ('@') provided
;; and their calling hierarchy:
;;
;; @ `pel--cfg-emacs'
;; @ `pel--cfg-ext-pkg'
;; @ `pel--cfg'
;; - `pel-prefixed'
;; @ `pel--cfg-pkg'
;; - `pel--customize-groups'
;; - `pel--customize-group'
;; - `pel--group-isin-libfile'
;; - `pel--isa-custom-group-p'
;; - `pel--multi-file-customization-p'
;; - `pel--load-all-libs-for'
;; - `pel--load-all-in'
;;; --------------------------------------------------------------------------
;;; Dependencies:
;;
;;
(require 'pel--base) ; use: macroexp-file-name
(require 'pel--options)
(require 'seq) ; use: seq-concatenate, seq-drop, seq-subseq
(eval-when-compile
(require 'cl-lib)) ; use: cl-dolist and cl-return
;;; --------------------------------------------------------------------------
;;; Code:
;;
;; ---------------------------------------------------------------------------
;; PEL Key Sequences Prefix and their F1, F2 and F3 topics
;; -------------------------------------------------------
;;
;; Some packages have a large set of package dependencies with customize
;; groups. For those define their list first and inject them inside the
;; `pel--prefix-to-topic-alist' below. Specially those that have duplicated
;; entries.
(defconst pel--c-groups (let ((items '(c
c-macro
bison-mode
electricity)))
(when pel-use-call-graph
(append items '(call-graph)))))
(defconst pel--c++-groups (let ((items '(cpp
c-macro
electricity)))
(when pel-use-call-graph
(append items '(call-graph)))))
(defconst pel--awk-groups '(c
electricity))
(defconst pel--dired-groups '(dired
dired-git-info
dired-hide-dotfiles
dired-narrow
dired-sidebar
dired-x
files
ls-lisp
wdired)
"List of groups used related to dired.")
(defconst pel--highligh-groups (let ((items '(auto-highlight-symbol
electricity
iedit
highlight-indentation
hl-line
paren-showing
rainbow
rainbow-delimiters
smartparens
vline)))
(if (version< emacs-version "27.1")
(append items '(fill-column-indicator))
(append items '(beacon)))))
(defconst pel--markdown-groups '(markdown
grip
impatient-showdown
markdown-preview
markdown-toc
vmd
edit-indirect
htmlize
simple-httpd)
"List of groups for packages used by markdown.")
(defconst pel--yaml-groups '(yaml
flycheck
indent-tools
smartparens)
"List of groups for YAML and CWL.")
(defconst pel--lsp-groups '(lsp-mode
lsp-ui
helm-lsp
lsp-ivy
lsp-origami
lsp-treemacs))
(defconst pel--scheme-groups '(scheme
geiser
macrostep-geiser
quack
lispy))
(defconst pel--spell-groups (if (version< emacs-version "27.1")
'(ispell
flyspell)
'(ispell
flyspell
go-translate)))
;; Shells
(defconst pel--shell-launch-groups '(shell
term
terminals
vterm))
(defconst pel--sh-scripting-groups '(sh
sh-script
sh-indentation
electricity))
(defconst pel--undo-groups (let ((items '(undo
undo-propose
undo-tree)))
(if pel-emacs-28-or-later-p
(append items '(vundo)))))
;; TODO: add logic in the processing of that table to allow the first element
;; of a row to be a list of key sequences.
;; This will help reduce duplication when several key sequences lead
;; to the same data.
(defconst pel--prefix-to-topic-alist
;; key sequence F1: Help PDF fname F2: PEL custom group F3: lib custom
;; group
;; ------------ ------------------ -------------------- -----------------
`(
(,(kbd "M-g <f4>") nil pel-pkg-for-completion (imenu
flimenu
popup-imenu
popup-switcher))
([27 103 f4] nil pel-pkg-for-completion (imenu
flimenu
popup-imenu
popup-switcher))
([f6] "inserting-text" pel-pkg-generic-code-style)
([f7 f8] "pl-applescript" pel-pkg-for-applescript)
([f8] "projectile" pel-pkg-for-project-mng (projectile
projectile-speedbar))
([f11] "-index" nil)
([f11 f10] "menus" pel-pkg-for-imenu (menu
imenu
Imenu-Plus
flimenu
popup-imenu
popup-switcher))
([f11 f2] "customize" nil customize)
([f11 f2 ?S] "fast-startup")
([f11 f8] "projectile" pel-pkg-for-project-mng (projectile
projectile-speedbar))
([f11 f5 ?k] "key-chords" pel-pkg-for-key-chord key-chord)
([f11 ?$] "spell-checking" pel-pkg-for-spelling ,pel--spell-groups)
([f11 ?'] "bookmarks" pel-pkg-for-bookmark (bookmark
bm))
([f11 ?,] "auto-completion" pel-pkg-for-expand (auto-complete
company
hippie-expand))
([f11 ?-] "cut-paste" pel-pkg-for-cut-and-paste (browse-kill-ring
cua-mode
killing
popup-kill-ring))
([f11 ?.] "marking" pel-pkg-for-marking expand-region)
([f11 ?=] "cut-paste" pel-pkg-for-cut-and-paste)
([f11 ?\;] "comments" pel-pkg-for-programming comment)
([f11 ??] "help" (pel-pkg-for-help
pel-syntax-tools)
(apropos
command-log
debbugs
help
helpful
hydra
keycast
info
interaction-log
man
minibuffer
which-func
which-key))
([f11 ?? ?k] "help" pel-pkg-for-keys (command-log
interaction-log
hydra
keycast
which-func
which-key))
([f11 9] "indentation" pel-pkg-for-indentation (indent
indent-tools
smart-shift))
;; 2 different possible key sequences for speedbar,
;; because M-s can also be typed ``Esc s``
(,(kbd "<f11> M-s") "speedbar" pel-pkg-for-speedbar (speedbar
sr-speedbar
projectile-speedbar))
([f11 27 ?s] "speedbar" pel-pkg-for-speedbar (speedbar
sr-speedbar
projectile-speedbar))
([f11 32 ?W] "pl-awk" pel-pkg-for-awk ,pel--awk-groups)
([f11 32 ?C] "pl-c++" pel-pkg-for-c++ ,pel--c++-groups)
([f11 32 ?C f12] "pl-c++" pel-c++-skeleton-control)
([f11 32 ?C ?#] "pl-c++" pel-pkg-for-c++ hide-ifdef)
([f11 32 ?D] "pl-d" pel-pkg-for-d (d-mode
electricity))
([f11 32 ?L] "pl-common-lisp" pel-pkg-for-clisp (lisp
lispy
slime
sly))
([f11 32 ?L f12] "pl-common-lisp" pel-clisp-code-style)
([f11 32 ?M] "pl-make" pel-pkg-for-make makefile)
([f11 32 ?R] "pl-rexx" pel-pkg-for-rexx rexx-mode)
([f11 32 ?N] "pl-rexx" pel-pkg-for-rexx netrexx)
([f11 32 ?a] "pl-applescript" pel-pkg-for-applescript apples)
([f11 32 ?c] "pl-c" pel-pkg-for-c ,pel--c-groups)
([f11 32 ?c f12] "pl-c" pel-c-skeleton-control)
([f11 32 ?c ?#] "pl-c" pel-pkg-for-c hide-ifdef)
([f11 32 ?e] "pl-erlang" pel-pkg-for-erlang (erlang
erldoc
erlstack
edts
ivy-erlang-complete
lsp-erlang
lsp-mode
lsp-treemacs
auto-highlight-symbol
electricity
smart-dash
smartparens
treemacs))
([f11 32 ?e f12] "pl-erlang" pel-erlang-code-style)
([f11 32 ?e ?L] "pl-erlang" pel-pkg-for-lsp-mode ,(cons 'lsp-erlang pel--lsp-groups))
([f11 32 ?e ?w] "pl-erlang" pel-pkg-for-lsp-mode (treemacs
lsp-treemacs))
(,(kbd "<f11> SPC M-f") "pl-factor" pel-pkg-for-factor factor)
([f11 32 27 ?f] "pl-factor" pel-pkg-for-factor factor)
([f11 32 ?f] "pl-forth" pel-pkg-for-forth)
([f11 32 ?g] "pl-go" pel-pkg-for-go (go
go-cover
godoc
go-dot-mod
electricity))
([f11 32 ?h] "pl-haskell" pel-pkg-for-haskell haskell)
([f11 32 ?T] "pl-janet" pel-pkg-for-janet (janet
ijanet
inf-janet))
([f11 32 ?j] "pl-julia" pel-pkg-for-julia (julia
julia-mode
julia-snail
electricity))
([f11 32 ?l] "pl-emacs-lisp" pel-pkg-for-elisp (checkdoc
editing-basics
elint
eros
lisp
lispy
suggest))
([f11 32 ?l f12] "pl-emacs-lisp" pel-elisp-code-style)
([f11 32 ?l ??] "pl-emacs-lisp" pel-pkg-for-all-languages (eldoc
eldoc-box))
([f11 32 ?4] "pl-m4" pel-pkg-for-m4 m4)
([f11 32 ?n] "pl-nim" pel-pkg-for-nim (nim
electricity))
([f11 32 ?o] "pl-ocaml" pel-pkg-for-ocaml (merlin
tuareg
tuareg-opam))
([f11 32 ?p] "pl-python" pel-pkg-for-python (python
python-flymake
electricity))
([f11 32 ?r] "pl-rust" pel-pkg-for-rust (rust-mode
rustic
racer
cargo
electricity))
([f11 32 ?P] "pl-perl" pel-pkg-for-perl (perl
cperl
electricity
perl-repl))
([f11 32 ?U] "pl-ruby" pel-pkg-for-ruby (ruby
electricity))
([f11 32 ?t] "pl-tcl" pel-pkg-for-tcl tcl)
([f11 32 ?v] "pl-v" pel-pkg-for-v (v-mode
electricity))
([f11 32 ?x] "pl-elixir" pel-pkg-for-elixir (elixir
electricity))
([f11 32 ?Z] "pl-sh" pel-pkg-for-sh-scripting ,pel--sh-scripting-groups)
(,(kbd "<f11> SPC C-a") nil pel-pkg-for-arc (arc
lispy))
(,(kbd "<f11> SPC C-h") "pl-hy" pel-pkg-for-hy)
(,(kbd "<f11> SPC C-j") "pl-clojure" pel-pkg-for-clojure (clojure
cider
cljr
lispy))
(,(kbd "<f11> SPC C-l") "pl-lfe" pel-pkg-for-lfe (lfe
lispy))
(,(kbd "<f11> SPC SPC C-l") "pl-lfe" pel-pkg-for-lfe (lfe
lispy))
;; Scheme Dialect Languages
(,(kbd "<f11> SPC C-s C-s") "pl-scheme" pel-pkg-for-scheme ,pel--scheme-groups)
(,(kbd "<f11> SPC C-s C-z") "pl-chez-scheme" pel-pkg-for-chez ,pel--scheme-groups)
(,(kbd "<f11> SPC C-s C-i") "pl-chibi-scheme" pel-pkg-for-chibi ,pel--scheme-groups)
(,(kbd "<f11> SPC C-s C-k") "pl-chicken-scheme" pel-pkg-for-chicken ,pel--scheme-groups)
(,(kbd "<f11> SPC C-s C-b") "pl-gambit-scheme" pel-pkg-for-gambit ,(cons 'gambit
pel--scheme-groups))
(,(kbd "<f11> SPC C-s C-e") "pl-gerbil-scheme" pel-pkg-for-gerbil ,(cons 'gerbil-mode
pel--scheme-groups))
(,(kbd "<f11> SPC C-s C-g") "pl-guile-scheme" pel-pkg-for-guile ,pel--scheme-groups)
(,(kbd "<f11> SPC C-s C-m") "pl-mit-scheme-scheme" pel-pkg-for-mit-scheme ,pel--scheme-groups)
(,(kbd "<f11> SPC C-s C-r") "pl-racket" pel-pkg-for-racket ,(cons 'racket
pel--scheme-groups) )
(,(kbd "<f11> SPC C-s C-h") "pl-scsh-scheme" pel-pkg-for-scsh ,pel--scheme-groups)
;;
;; ([f11 ?C]
([f11 ?D] "drawing" pel-pkg-for-drawing-markup)
([f11 ?D ?u] "plantuml" pel-pkg-for-plantuml plantuml-mode)
([f11 ?F] "frames" pel-pkg-for-frame frames)
([f11 ?T] "time-tracking" pel-pkg-for-time-tracking (display-time
timeclock
timelog))
([f11 ?S] "sessions" pel-pkg-for-sessions desktop)
;; ([f11 ?S ?R]
([f11 ?X] "xref" pel-pkg-for-xref (cscope
dumb-jump
eopengrok
etags
ggtags
gxref
helm
helm-cscope
helm-xref
ivy
ivy-xref
projectile
speedbar
xref))
([f11 ?_] "inserting-text")
([f11 ?a] "abbreviations" pel-pkg-for-expand abbrev)
(,(kbd "<f11> SPC SPC b") "ibuffer-mode" pel-pkg-for-ibuffer (ibuffer ibuffer-vc))
([f11 ?b] "buffers" pel-pkg-for-buffer (Buffer-menu
bs
ibuffer
iflipb
minibuffer
hexl
nhexl
popup-switcher))
;; ([f11 ?b ?I]
([f11 ?h] "highlight" (pel-pkg-for-highlight
pel-pkg-for-modeline
pel-pkg-for-parens)
,pel--highligh-groups)
([f11 ?c] "counting" nil)
(,(kbd "<f11> SPC SPC d d") "diff-merge" pel-pkg-for-diff-merge diff)
([f11 ?d] "diff-merge" pel-pkg-for-diff-merge (diff
ediff
emerge
smerge
ztree))
([f11 ?d ?e] "diff-merge" pel-pkg-for-diff-merge ediff)
(,(kbd "<f11> SPC SPC d e") "diff-smerge" pel-pkg-for-diff-merge ediff)
([f11 ?d ?s] "diff-merge" pel-pkg-for-diff-merge smerge)
(,(kbd "<f11> SPC SPC d s") "diff-smerge" pel-pkg-for-diff-merge smerge)
([f11 ?f ?v] "file-variables" nil)
(,(kbd "<f11> SPC M-D") "mode-dired" pel-pkg-for-dired ,pel--dired-groups)
([f11 32 27 ?D] "mode-dired" pel-pkg-for-dired ,pel--dired-groups)
([dired] "mode-dired" pel-pkg-for-dired ,pel--dired-groups)
([f11 ?f]
("file-mngt"
"web")
pel-pkg-for-filemng (files
fzf
recentf
popup-switcher
x509))
;; no PDF for browse yet, the info is in file-mngt.
([f11 ?B] "file-mngt" (pel-pkg-for-file-browse
pel-pkg-for-web-browse
pel-pkg-for-ztree)
(dir-treeview
rfc-mode-group
treemacs
lsp-treemacs
ztree
))
([f11 ?B ?N] "file-mngt" pel-pkg-for-neotree neotree)
([f11 ?f ?a] "file-mngt" nil ffap)
([f11 ?f ?p] "file-mngt" pel-pkg-for-project-mng ffip)
([f11 ?f ?r] "file-mngt" nil auto-revert)
([f11 ?f ?v] "file-variables")
([f11 ?f ?v ?D] "file-variables")
([f11 ?g] "grep" pel-pkg-for-grep (grep
ag
deadgrep
fzf
rg
ripgrep
wgrep))
([f11 ?\(] "smartparens" pel-pkg-for-parens (electricity
rainbow-delimiters
smartparens))
([f11 ?i] "inserting-text" pel-pkg-for-insertions (electricity
lice
smart-dash
smartparens
tempo
time-stamp
yanippet))
([f11 ?k] "keyboard-macros" pel-pkg-for-kbmacro (kmacro
centimacro))
([f11 ?k ?e] "keyboard-macros" pel-pkg-for-kbmacro emacros)
([f11 ?k ?l] "keyboard-macros" pel-pkg-for-kbmacro elmacro)
([f11 ?l] "display-lines" nil (display-line-numbers
visual-line))
([f11 ?m] "cursor" pel-pkg-for-cursor (cursor
display
multiple-cursors))
([f11 ?o] "sorting" nil)
([f11 ?r] "registers" nil)
([f11 ?s] "search-replace" pel-pkg-for-search (isearch
anzu
iedit
easy-escape
fzf
swiper))
([f11 ?s ?m] "search-replace" nil)
([f11 ?s ?w] "search-replace" nil)
([f11 ?s ?x] "search-replace" pel-pkg-for-regexp (rxt ; for pcre
re-builder
visual-regexp))
([f11 ?!] "syntax-checking" pel-pkg-for-syntax-check (flymake
flycheck))
([f11 ?t] ("case-conversion"
"input-method"
"text-modes") pel-pkg-for-text-mode (editing-basics
glasses
whitespace))
([f11 ?t ?a] "align" pel-pkg-for-align align)
([f11 ?t ?e] "enriched-text" nil enriched)
([f11 ?t ?f] "filling-justification" nil fill)
([f11 ?t ?j] "filling-justification" nil fill)
([f11 ?t ?m] "text-modes" pel-pkg-for-text-mode (editing-basics
glasses
whitespace))
([f11 ?t ?t] "transpose" nil)
([f11 ?t ?w] "whitespaces" nil whitespace)
([f11 ?u] "undo-redo-repeat" pel-pkg-for-undo ,pel--undo-groups)
([f11 ?v] "vcs-mercurial" pel-pkg-for-vcs (vc
vc-hg
vc-git
magit
monky))
(,(kbd "<f11> SPC SPC v") "vcs-mercurial" pel-pkg-for-vcs (vc
vc-hg
vc-git))
([f11 ?w] "windows" pel-pkg-for-window (windows
ace-window
ace-window-display
golden-ratio
winner
windmove
windresize
winum))
(,(kbd "<M-f11> M-=") "tab-bar" nil tab-bar)
([M-f11 27 61] "tab-bar" nil tab-bar)
([f11 ?w ?P] "windows" pel-pkg-for-windows purpose)
([f11 ?y] "inserting-text" pel-pkg-for-insertions (yasnippet
yasnippet-snippets
yas-minor))
([f11 ?z] "shells" pel-pkg-for-shells ,pel--shell-launch-groups)
([f11 32 ?z ?s] "shell-mode" pel-pkg-for-shells (shell comint))
([f11 32 ?z ?t] "term-mode" pel-pkg-for-term-mode term)
([f11 32 ?z ?f] "eat-mode" pel-pkg-for-eat-mode eat)
([f11 32 ?z ?v] "vterm-mode" pel-pkg-for-vterm-mode vterm)
([f11 ?|] "scrolling" pel-pkg-for-scrolling (frame
follow
smooth-scrolling))
;; For keys with Meta, make sure the Esc equivalent is also entered
;; to allow the F1, F2, F3 entries to be accessible via the Esc key.
;; Because: in Emacs ``M-a`` can also be typed ``Esc a``
(,(kbd "<f11> M-S") "fast-startup" pel-fast-startup)
([f11 27 ?S] "fast-startup" pel-fast-startup)
(,(kbd "<f11> M-/") "hide-show-code" pel-pkg-for-hide-show (hideshow
hide-lines
origami))
([f11 27 ?/] "hide-show-code" pel-pkg-for-hide-show (hideshow
hide-lines
origami))
(,(kbd "<f11> M-c") "completion-input" pel-pkg-for-completion (helm
ido
ido-completing-read-plus
ido-grid
ido-grid-mode
ivy
counsel
minibuffer
smex))
([f11 27 99] "completion-input" pel-pkg-for-completion (helm
ido
ido-completing-read-plus
ido-grid
ido-grid-mode
ivy
counsel
minibuffer
smex))
([f11 27 ?d] "mode-line" pel-pkg-for-modeline (display-time
mode-line))
(,(kbd "<f11> M-d") "mode-line" pel-pkg-for-modeline (display-time
mode-line))
(,(kbd "<f11> SPC M-g") "graphviz-dot" pel-pkg-for-graphviz-dot graphviz)
([f11 32 27 ?g] "graphviz-dot" pel-pkg-for-graphviz-dot graphviz)
(,(kbd "<f11> SPC M-a") "asciidoc" pel-pkg-for-asciidoc adoc)
([f11 32 27 ?a] "asciidoc" pel-pkg-for-asciidoc adoc)
(,(kbd "<f11> SPC M-r") "mode-rst" pel-pkg-for-reST rst)
([f11 32 27 ?r] "mode-rst" pel-pkg-for-reST rst)
(,(kbd "<f11> SPC M-m") "mode-markdown" pel-pkg-for-markdown ,pel--markdown-groups)
([f11 32 27 ?m] "mode-markdown" pel-pkg-for-markdown ,pel--markdown-groups)
(,(kbd "<f11> SPC M-l") "outline" pel-pkg-for-outline outlines)
([f11 32 27 ?l] "outline" pel-pkg-for-outline outlines)
(,(kbd "<f11> SPC M-o") "mode-org-mode" pel-pkg-for-org-mode org)
([f11 32 27 ?o] "mode-org-mode" pel-pkg-for-org-mode org)
(,(kbd "<f11> SPC M-u") "plantuml" pel-pkg-for-plantuml plantuml-mode)
([f11 32 27 ?u] "plantuml" pel-pkg-for-plantuml plantuml-mode)
(,(kbd "<f11> SPC M-M") "mscgen" pel-pkg-for-mscgen mscgen)
([f11 32 27 ?M] "mscgen" pel-pkg-for-mscgen mscgen)
(,(kbd "<f11> SPC M-R") "rpm" pel-pkg-for-rpm rpm-spec)
([f11 32 27 ?R] "rpm" pel-pkg-for-rpm rpm-spec)
;; (,(kbd "<f11> SPC M-S") "rpm" pel-pkg-for-rpm rpm-spec)
;; ([f11 32 27 ?S] "rpm" pel-pkg-for-rpm rpm-spec)
(,(kbd "<f11> SPC M-c") "cwl" pel-pkg-for-cwl ,pel--yaml-groups)
([f11 32 27 ?c] "cwl" pel-pkg-for-cwl ,pel--yaml-groups)
(,(kbd "<f11> SPC M-y") "yaml" pel-pkg-for-yaml ,pel--yaml-groups)
([f11 32 27 ?y] "yaml" pel-pkg-for-yaml ,pel--yaml-groups)
(,(kbd "<f11> SPC M-Y") "yang" pel-pkg-for-spec-definition)
([f11 32 27 ?Y] "yang" pel-pkg-for-spec-definition))
"Map from key prefix array to topic string.
The topic string correspond to the base name of the PDF file
stored inside the doc/pdf directory.")
;; PDF files not identified by the key sequences above
;; "autosave-backup"
;; "closing-suspending"
;; "cua"
;; "ert"
;; "faces-fonts"
;; "hooks"
;; "keys-f11"
;; "keys-fn"
;; "macOS-terminal-settings"
;; "modifier-keys"
;; "mouse"
;; "narrowing"
;; "navigation"
;; "numkeypad"
;; "packages"
;; "rectangles"
;; --
(defconst pel--mode-letter-alist
'(("Custom" [f11 f2])
("dired" [dired])
("dired-sidebar" [dired])
("apples" [f11 32 ?a])
("awk" [f11 32 ?W])
("c++" [f11 32 ?C])
("c++-ts" [f11 32 ?C])
("c" [f11 32 ?c])
("c-ts" [f11 32 ?c])
("lisp" [f11 32 ?L])
("common-lisp" [f11 32 ?L]) ; an alias for lisp.
("clojure" [f11 32 10])
("d" [f11 32 ?D])
("elixir" [f11 32 ?x])
("lisp-interaction" [f11 32 ?l]) ; for scratch buffer
("suggest" [f11 32 ?l]) ; suggest -> emacs-lisp help
("emacs-lisp" [f11 32 ?l])
("erlang" [f11 32 ?e])
("factor" [f11 32 27 ?f])
("forth" [f11 32 ?f])
("go" [f11 32 ?g])
("janet" [f11 32 ?T])
("julia" [f11 32 ?j])
("m4" [f11 32 ?4])
("makefile" [f11 32 ?M])
("makefile-bsdmake" [f11 32 ?M])
("makefile-gmake" [f11 32 ?M])
("makefile-makepp" [f11 32 ?M])
("makefile-automake" [f11 32 ?M])
("makefile-imake" [f11 32 ?M])
("makefile-nmake" [f11 32 ?M])
("python" [f11 32 ?p])
("python-ts" [f11 32 ?p])
("arc" [f11 32 1])
("haskell" [f11 32 ?h])
("hy" [f11 32 8])
("lfe" [f11 32 12])
("inferior-lfe" [f11 32 32 12])
("ibuffer" [f11 32 32 ?b])
("vc-dir" [f11 32 32 ?v])
("nim" [f11 32 ?n])
("ocaml" [f11 32 ?o])
("tuareg" [f11 32 ?o])
("perl" [f11 32 ?P])
("cperl" [f11 32 ?P])
("rexx" [f11 32 ?R])
("rpm" [f11 32 27 ?R])
;; ("rpmspec" [f11 32 27 ?S])
("ruby" [f11 32 ?U])
("rust" [f11 32 ?r])
;;
("scheme" [f11 32 19 19])
("chez" [f11 32 19 26])
("chibi" [f11 32 19 9])
("chicken" [f11 32 19 11])
("gambit" [f11 32 19 2])
("gerbil" [f11 32 19 5])
("guile" [f11 32 19 7])
("mit-scheme" [f11 32 19 13])
("racket" [f11 32 19 18])
("scsh" [f11 32 19 8])
;;
("sh" [f11 32 ?Z])
("tcl" [f11 32 ?t])
("v" [f11 32 ?v])
("adoc" [f11 32 27 ?a])
("markdown" [f11 32 27 ?m])
("netrexx" [f11 32 ?N])
("rst" [f11 32 27 ?r])
("cwl" [f11 32 27 ?c])
("outline" [f11 32 27 ?l])
("org" [f11 32 27 ?o])
("graphviz-dot" [f11 32 27 ?g])
("mscgen" [f11 32 27 ?M])
("plantuml" [f11 32 27 ?u])
("yaml" [f11 32 27 ?y])
("yang" [f11 32 27 ?Y])
;; shells and terminals
("shell" [f11 32 ?z ?s])
("term" [f11 32 ?z ?t])
("vterm" [f11 32 ?z ?v])
("eat" [f11 32 ?z ?f])
;; diff modes
("diff" [f11 32 32 ?d ?d])
("ediff" [f11 32 32 ?d ?e])
("smerge" [f11 32 32 ?d ?s])
)
"Maps the name of a major mode (without the -mode suffix)
to a symbol or key sequence array to use as map key inside
`pel--prefix-to-topic-alist' table.")
(defun pel--major-mode-keyseq (keyseq)
"Return global mode index for major mode KEYSEQ.
The KEYSEQ is a sequence prefix that starts with f12, used as a
short cut in a major mode. It may have only one or several keys.
Its meaning depend on the currently active major mode. Return
the corresponding global key sequence that means the same thing
so it can be used as an index inside variable
`pel--prefix-to-topic-alist'."
(unless (eq (elt keyseq 0) 'f12)
(error "Logic error!! keyseq should start with f12. It is %s" keyseq))
;; (message "pel--major-mode-keyseq keyseq=%s" keyseq)
(let* ((mode-str (substring (symbol-name major-mode) 0 -5))
(keyidx (cadr (assoc mode-str pel--mode-letter-alist))))
;; (message "pel--major-mode-keyseq --> mode-str = %s" mode-str)
;; (message "pel--major-mode-keyseq --> keyidx = %s" keyidx)
(if keyidx
(seq-concatenate 'vector keyidx (seq-drop keyseq 1))
(error "Missing entry for %s in pel--mode-letter-alist" mode-str))))
(defun pel--kte-for (keyseq)
"Return the table entry for the specified KEYSEQ.
The KEYSEQ should start with either f11 or f12, but also other prefix keys
such as f6, f7, f8 and some key sequences.
The f11 is a full key sequence.
The f12 key sequence is a mode-specific key sequence,
where f12 abbreviates the full f11 key sequence for the
current major mode.
Check the key sequences. Expand the f12 key sequence into
the full f11 key sequence. Report invalid key sequence."
(let ((prefix-key (elt keyseq 0)))
;; (message "pel--kte-for: prefix-key : %s" prefix-key)
(unless (or (memq prefix-key '(f6 f7 f8 f11 f12 M-f11 M-f12))
;; special case command (for now)
(equal keyseq [27 103 f4])
(equal keyseq (kbd "M-g <f4>")))
(user-error "This command can only be invoked via \
F6, F7, F8, F11, F12 or M-F12 prefix.\n\
Not %s in %s" prefix-key keyseq))
;; Replace M-f12 by f12:
;; all other logic has no knowledge of M-f12 bindings.
(when (eq prefix-key 'M-f12)
(setq prefix-key 'f12)
(aset keyseq 0 'f12))
(assoc (if (eq prefix-key 'f12)
(pel--major-mode-keyseq keyseq)
keyseq)
pel--prefix-to-topic-alist)))
(defun pel--kte-pdfs (table-entry)
"Return a list of partial names of PDF files in TABLE-ENTRY.
Return strings: the partial names of PDF files for the TABLE-ENTRY.
Return nil if there are none."
(let ((elem (nth 1 table-entry)))
(if (stringp elem)
(list elem)
elem)))
(defun pel--kte-pel-groups (table-entry)
"Return a list of symbols of PEL group for the TABLE-ENTRY, or nil if none."
(let ((elem (nth 2 table-entry)))
(if (and (symbolp elem) elem)
(list elem)
elem)))
(defun pel--kte-lib-groups (table-entry)
"Return the library customization group for the TABLE-ENTRY.
Return a list of groups if there are several.
Return nil if there are none."
(nth 3 table-entry))
(defun pel--keyseq ()
"Return the key sequence that invoked the command.
Drop the last key: it's either f1, f2 or f3, because a binding
allowed the command to be invoked."
(seq-subseq (this-command-keys) 0 -1))
(defun pel--kte-select-topic (prompt strings)
"PROMPT the user for one of the STRINGS and return the selected one."
(if (< (length strings) 2)
(car strings)
(require 'pel-prompt nil :noerror)
(if (fboundp 'pel-select-string-from)
(pel-select-string-from prompt strings)
(error "Cannot load pel-prompt!"))))
(defun pel-shell-scripting-language ()
"Return string identifying the shell scripting language for current buffer.
Something like \"sh\", \"bash\", or \"zsh\".
If the current buffer "
(unless (fboundp 'sh-shell)
(require 'sh-script))
(defvar sh-shell)
(symbol-name sh-shell))
(defun pel-lang-pdf ()
"Return list of language specific PDF file for current buffer.
Each entry of the list is file base name without file extension."
(let ((major-mode-str (symbol-name major-mode)))
(cond
((eq major-mode 'sh-mode)
;; return "sh", "bash", zsh", based on shell scripting language used.
(list (pel-shell-scripting-language)))
((memq major-mode '(emacs-lisp-mode lisp-interaction-mode))
;; Special case: these old files are located in the doc/pdf directory.
;; Because the files are located right in the doc/pdf and not inside the
;; doc/pdf/lang directory, and because the files returned by this
;; function are supposed to be in the lang subdir, return a file name
;; that force looking into the above dir.
(list "../plm-lispy" "../emacs-lisp-types"))
((pel-string-starts-with-p major-mode-str "makefile-")
;; Return MMMM for the makefile-MMMM-mode modes.
;; Example: for makefile-gmake-mode: return "gmake".
(list (substring major-mode-str 9 -5)))
(t (user-error "No language specific for this major mode.")))))
;;-pel-autoload
(defun pel-help-pdf (&optional n)
"Open the PEL PDF file(s) for the current context.
The argument N controls the selection of the PDF file and way it is opened.
======= ======================== ============================================
N value Content Method
======= ======================== ============================================
none Mode-specific PDF Open local PDF
1 Mode-specific PDF Open local PDF with PDF reader
-1 Mode-specific PDF Open GitHub raw PDF with default web browser
>= 2 Language/Syntax/Ref PDF Open local PDF
<= -2 Language/Syntax/Ref PDF Open GitHub raw PDF with default web browser
======= ======================== ============================================
The local PDF is opened according to the value selected by the
`pel-open-pdf-method' user-option; which defaults to the local
PDF viewer.
The sign of the numeric value identifies whether the local PDF
file or the corresponding GitHub hosted raw PDF file is opened.
However, if the user-option variable `pel-flip-help-pdf-arg' is
set, it's the other way around: the GitHub remote file is opened
by default.
To open the web file, the function uses Emacs default browse
mechanism specified by the user-option variable
`browse-url-browser-function' unless the user-option variable
`pel-browser-used' forces the use of a specific browser.
If your system default browser can not render PDF files directly
and downloads them, then you can force the use of the Firefox
browser (which renders PDF) by setting `pel-browser-used' to
`firefox'.
Using a browser that is capable of direct rendering of PDF
produces a much better user experience: you will be able to
quickly navigate through PEL documentation inside the browser.
The `pel-help-pdf' function determines the requested PDF topic by the key
sequence that led to the execution of the command. These key sequences
normally end with the F1 key."
(interactive "p")
;; (message "N is %s" n)
(let* ((open-github-page-p (< n 0))
(category (when (>= (abs n) 2) "lang"))
(keyseq (pel--keyseq)) ; identify the first key(s)
(kte (pel--kte-for keyseq)) ; pel--prefix-to-topic-alist entry
(pdfs (if category
(pel-lang-pdf)
(pel--kte-pdfs kte))))
;; (message "pel--keyseq :--> %s" keyseq)
;; (message "pel--kte-for :--> %s" kte)
;; (message "pel--kte-pdfs :--> %s" pdfs)
(unless pdfs
(error "No PDF entry in pel--prefix-to-topic-alist for %s.\n\
There should be no key binding!" keyseq))
(let* ((open-github-file-p (if pel-flip-help-pdf-arg
(not open-github-page-p)
open-github-page-p))
(url (pel-pdf-file-url
(pel--kte-select-topic "Open the PDF file: " pdfs)
open-github-file-p
category)))
;; (message "url: %s" url)
(pel--help-browse url))))
(defconst pel--topic-alias
'(
;; programming languages alias: all of their PDF files start with 'pl-'
("applescript" . "pl-applescript")
("arc" . "pl-arc")
("awk" . "pl-awk")
("c++" . "pl-c++")
("c" . "pl-c")
("common-lisp" . "pl-common-lisp")
("clojure" . "pl-clojure")
("d" . "pl-d")
("elixir" . "pl-elixir")
("emacs-lisp" . "pl-emacs-lisp")
("erlang" . "pl-erlang")
("factor" . "pl-factor")
("forth" . "pl-forth")
("go" . "pl-go")
("haskell" . "pl-haskell")
("hy" . "pl-hy")
("janet" . "pl-janet")
("julia" . "pl-julia")
("lfe" . "pl-lfe")
("m4" . "pl-m4")
("make" . "pl-make")
("nim" . "pl-nim")
("ocaml" . "pl-ocaml")
("perl" . "pl-perl")
("cperl" . "pl-perl")
("python" . "pl-python")
("rexx" . "pl-rexx")
("ruby" . "pl-ruby")
("rust" . "pl-rust")
("netrexx" . "pl-rexx")
;; Scheme dialects
("scheme" . "pl-scheme")
("chez" . "pl-chez-scheme")
("chibi" . "pl-chibi-scheme")
("chicken" . "pl-chicken-scheme")
("gambit" . "pl-gambit-scheme")
("gerbil" . "pl-gerbil-scheme")
("guile" . "pl-guile-scheme")
("mit-scheme" . "pl-mit-scheme-scheme")
("racket" . "pl-racket")
("scsh" . "pl-scsh-scheme")
;;
("sh" . "pl-sh")
("tcl" . "pl-tcl")
("v" . "pl-v")
;; repl
;; ("sly" . "repl-cl-sly")
;; ("slime" . "repl-cl-slime")
;; mode names aliases
("git" . "vcs-git")
("mercurial" . "vcs-mercurial")
("subversion" . "vcs-subversion")
("lispy" . "plm-lispy")
("dired" . "mode-dired")
("org-mode" . "mode-org-mode")
("adoc" . "asciidoc")
("markdown" . "mode-markdown")
("rst" . "mode-rst")
;; topic related aliases, ordered by file names
("repeat" . "undo-redo-repeat")
("redo" . "undo-redo-repeat")
("hippie-expand" . "abbreviations")
("dabbrev-expand" . "abbreviations")
("text-align" . "align")
("completion" . "auto-completion")
("auto-complete" . "auto-completion")
("company-mode" . "auto-completion")
("binary" . "buffers")
("hexadecimal" . "buffers")
("input-completion-availability" . "completion-input-availability")
("input-completion" . "completion-input")
("copy" . "cut-paste")
("delete" . "cut-paste")
("kill" . "cut-paste")
("yank" . "cut-paste")
("lines" . "display-lines")
("artist-mode" . "drawing")
("picture-mode" . "drawing")
("fonts" . "faces-fonts")
("ascii-table" . "help")
("prefix-keys" . "help")
("keycast" . "help")