-
Notifications
You must be signed in to change notification settings - Fork 0
/
pel--options.el
11702 lines (9996 loc) · 438 KB
/
pel--options.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--options.el --- PEL Customization Options -*-lexical-binding: t-*-
;; Copyright (C) 2020, 2021, 2022, 2023, 2024 Pierre Rouleau
;; Author: Pierre Rouleau <prouleau001@gmail.com>
;; This file is part of the PEL package
;; This file is not part of GNU Emacs.
;; 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:
;;
;; Defines the PEL options. All the options using the 'pel-use-' prefix
;; identify functionality (and potentially also a Emacs Lisp library) that can
;; be used by PEL. It is used when the option is set to `t' and not used when
;; set to `nil'. This way, the user can choose what is provided by PEL simply
;; by customizing PEL.
;;
;; The pel group customization tree, inside emacs/convenience, contains the
;; following group hierarchy:
;;
;; - pel
;; - pel-base-emacs
;; - pel-syntax-tools
;; - pel-fast-startup
;; - pel-package-use
;; - pel-pkg-for-align
;; - pel-pkg-for-bookmark
;; - pel-pkg-for-buffer
;; - pel-pkg-for-ibuffer
;; - pel-pkg-for-completion
;; - pel-pkg-for-cursor
;; - pel-pkg-for-iedit
;; - pel-pkg-for-cut-and-paste
;; - pel-pkg-for-data-files
;; - pel-pkg-for-diff-merge
;; - pel-pkg-for-dired
;; - pel-pkg-for-expand
;; - pel-pkg-for-conf-file
;; - pel-pkg-for-filemng
;; - pel-pkg-for-browse
;; - pel-pkg-for-file-browse
;; - pel-pkg-for-neotree
;; - pel-pkg-for-ztree
;; - pel-pkg-for-web-browse
;; - pel-pkg-for-frame
;; - pel-pkg-for-graphics-emacs
;; - pel-pkg-for-graphics-cursor
;; - pel-pkg-for-grep
;; - pel-pkg-for-help
;; - pel-pkg-for-hide-show
;; - pel-pkg-for-highlight
;; - pel-pkg-for-iedit
;; - pel-pkg-for-modeline
;; - pel-pkg-for-imenu
;; - pel-pkg-for-indentation
;; - pel-pkg-for-insertions
;; - pel-text-insertions
;; - pel-date-time-insertion
;; - pel-pkg-for-parens
;; - pel-pkg-for-kbmacro
;; - pel-pkg-for-key-chord
;; - pel-pkg-for-keys
;; - pel-keypad-keys
;; - pel-pkg-for-log-file
;; - pel-pkg-for-object-file
;; - pel-pkg-for-x509-file
;; - pel-pkg-for-marking
;; - pel-pkg-for-markup
;; - pel-pkg-for-asciidoc
;; - pel-pkg-for-drawing-markup
;; - pel-pkg-for-graphviz-dot
;; - pel-pkg-for-mscgen
;; - pel-pkg-for-plantuml
;; - pel-pkg-for-markdown
;; - pel-pkg-for-outline
;; - pel-pkg-for-org-mode
;; - pel-pkg-for-reST
;; - pel-reST-style
;; - pel-pkg-for-xml
;; - pel-pkg-for-yaml
;; - pel-pkg-for-cwl
;; - pel-pkg-for-modeline
;; - pel-pkg-for-navigation
;; - pel-pkg-for-xref
;; - pel-pkg-for-parser
;; - pel-pkg-for-programming
;; - pel-pkg-for-all-languages
;; - pel-pkg-for-parens
;; - pel-pkg-for-syntax-check
;; - pel-pkg-for-language-server
;; - pel-pkg-generic-code-style
;; - pel-sh-script-skeleton-control
;; - pel-pkg-for-applescript
;; - pel-pkg-for-cc
;; - pel-pkg-for-awk
;; - pel-pkg-for-c
;; - pel-c-code-style
;; - pel-c-skeleton-control
;; - pel-c-module-header-skeleton-control
;; - pel-c-function-header-skeleton-control
;; - pel-pkg-for-bison
;; - pel-pkg-for-c++
;; - pel-c++-code-style
;; - pel-c++-skeleton-control
;; - pel-c++-module-header-skeleton-control
;; - pel-c++-function-header-skeleton-control
;; - pel-pkg-for-d
;; - pel-d-code-style
;; - pel-pkg-for-javascript
;; - pel-pkg-for-go
;; - pel-pkg-for-haskell
;; - pel-pkg-for-lisp
;; - pel-pkg-for-clisp
;; - pel-clisp-code-style
;; - pel-sexp-form-navigation
;; - pel-pkg-for-elisp
;; - pel-elisp-code-style
;; - pel-sexp-form-navigation
;; - pel-pkg-for-arc
;; - pel-pkg-for-clojure
;; - pel-pkg-for-janet
;; - pel-pkg-for-hy
;; - pel-pkg-for-scheme
;; - pel-pkg-for-racket
;; - pel-pkg-for-gambit
;; - pel-pkg-for-gerbil
;; - pel-pkg-for-beam-vm
;; - pel-pkg-for-elixir
;; - pel-pkg-for-erlang
;; - pel-erlang-environment
;; - pel-erlang-ide
;; - pel-erlang-code-style
;; - pel-erlang-skeleton-control
;; - pel-pkg-for-lfe
;; - pel-pkg-for-gleam
;; - pel-pkg-for-forth
;; - pel-pkg-for-julia
;; - pel-pkg-for-m4
;; - pel-pkg-for-nim
;; - pel-pkg-for-ocaml
;; - pel-pkg-for-perl
;; - pel-pkg-for-python
;; - pel-pkg-for-rexx
;; - pel-pkg-for-ruby
;; - pel-pkg-for-rust
;; - pel-pkg-for-sh-scripting
;; - pel-sh-script-skeleton-control
;; - pel-pkg-for-tcl
;; - pel-pkg-for-v
;; - pel-pkg-for-project-mng
;; - pel-pkg-for-regexp
;; - pel-pkg-for-scrolling
;; - pel-pkg-for-search
;; - pel-pkg-for-session
;; - pel-pkg-for-shells
;; - pel-pkg-for-vterm-mode
;; - pel-pkg-for-eat-mode
;; - pel-pkg-for-skeletons
;; - pel-pkg-generic-code-style
;; - pel-sh-script-skeleton-control
;; - pel-c-module-header-skeleton-control
;; - pel-c-module-header-skeleton-control
;; - pel-c-function-header-skeleton-control
;; - pel-erlang-skeleton-control
;; - pel-pkg-for-spec-definition
;; - pel-pkg-for-speedbar
;; - pel-pkg-for-spelling
;; - pel-pkg-for-sw-build
;; - pel-pkg-for-cmake
;; - pel-pkg-for-make
;; - pel-pkg-for-text-mode
;; - pel-pkg-for-time-tracking
;; - pel-pkg-for-text-translation
;; - pel-pkg-for-tree-sitter
;; - pel-pkg-for-undo
;; - pel-pkg-for-vcs
;; - pel-pkg-for-git
;; - pel-pkg-for-mercurial
;; - pel-pkg-for-perforce
;; - pel-pkg-for-subversion
;; - pel-pkg-for-window
;; - pel-pkg-for-scrolling
;; - pel-pkg-for-session
;; - pel-pkg-for-speedbar
;;
;; Naming conventions:
;;
;; For the following, replace <mode> by the name of the major mode.
;; for example, for python-mode, replace <mode> by python.
;;
;; - pel-pkg-for-<package-name or topic>
;; - pel-use-<package name>
;; - pel-startup-<thing to activate at startup>
;; - pel-modes-activating-<package name>
;; - pel-<mode>-activates-minor-modes
;; - pel-<mode>-use-tabs
;; - pel-<mode>-tab-width
;;
;; The `pel-use-' user-options are either t/nil boolean types or tri-state
;; types that can be set to nil, t or 'use-from-start. When set to t, they
;; are only activated once a PEL command for that effect is executed by the
;; user.
;; Properties applied to defcustom variables
;; -----------------------------------------
;;
;; Extra information is stored inside attributes of the `pel-use-' defcustom
;; user-option variables. This information is used in the logic PEL uses to
;; disable/remove packages when a `pel-use-' user option is turned off and the
;; function `pel-cleanup' is executed.
;;
;; The following properties are applied to the `pel-use-' user-option
;; variables only:
;;
;; - `:also-required-when'
;; - `:requires'
;; - `:package-is'
;; - `:restricted-to'
;;
;; They are described below.
;; `:also-required-when'
;; --------------------
;;
;; The `:also-required-when' property indicates that the package controlled
;; by the `pel-use-' user-option is also activated by something else. The
;; condition that also activates it is identified by the quoted form that is
;; used as the value for this property. Any valid form can be used.
;; As an example, look at the `pel-use-lice' user-option: the lice package is
;; installed when `pel-use-lice' is non-nil but also when one of the
;; programming language skels requires the use of code license.
;;
;; `:requires'
;; ----------
;;
;; The `:requires' property indicates package dependencies. The attribute
;; value might be:
;;
;; - A single `pel-use-' symbol: stating that this parent must also be
;; activated for the package to be installed. The parent may be a 'gate'
;; package (a `pel-use-' symbol that has the :package-is :a-gate property),
;; or a `pel-use-' symbol for a normal package.
;;
;; - A list of several `pel-use-' symbols, stating that any of the specified
;; parent must be installed for this package to be installed.
;;
;; - A list of several `pel-use-' symbols with `:all' in the first element,
;; stating that *all* parent packages must be activated for this package to
;; be installed.
;;
;; `:requires-package'
;; ------------------
;;
;; If a package is taken from an Elpa-compliant repo it is packaged and it
;; already identifies its dependencies. The `pel-cleanup' function reads the
;; package dependencies and takes them into account.
;;
;; However, there are cases where the dependencies are not fully identified.
;;
;; - Case 1: the pel-init call in pel_keys.el sometimes installs and activates
;; several packages for a single `pel-use-' variable. These other packages
;; must be identified.
;;
;; - Case 2: the package dependency of some packages do not identify *all* of
;; their dependencies. In some case they do that because the package
;; activates extra functionality only when the extra dependency is present.
;;
;; In both cases, when these extra packages are present you want to keep them
;; during a `pel-cleanup' operation. To identify those extra dependencies use
;; the `:requires-package' property and identify the required package. The
;; semantics is the same as for the `:requires' property above except for the
;; fact that if it is not present nothing is inferred.
;;
;; *Development Tip*:
;; When writing support for a new package that is coming from and
;; Elpa-compliant repo:
;; - write the specification code here and the code calling
;; the `pel-ensure-package' inside pel_keys.el,
;; - turn the option on and execute `pel-init' to get PEL to install the new
;; package.
;; - Inspect the source file(s) of the newly install package to identify its
;; dependencies.
;; - Execute the function `pel-elpa-pkg-dependencies' on the package and see
;; if it identifies all its dependencies.
;; - If that's not the case, then add a `:requires-package' property to the
;; package `pel-use-' user-option that identifies the unspecified
;; dependencies.
;; - Activate the package `pel-use-' variable and run `pel-init' to ensure
;; that all required packages are installed.
;; - With the variable still active, run a dry-run `pel-cleanup' to check that
;; nothing it requires would be un-installed.
;; - Deactivate the variable and run a dry-run `pel-cleanup' to verify that it
;; removes only what should be removed.
;; `:package-is'
;; ------------
;;
;; In most case the name of the package that is controlled by the `pel-use-'
;; variables is the string that follows the "pel-use-" prefix in the symbol
;; name. But this is not always the case. There are the other possibilities
;; that are identified by the `:package-is' property:
;;
;; - the `:a-gate' property value means that this user-option acts as a
;; gate and does not install anything. Other user-options use it as a
;; parent to gate their installation. This property is often used for
;; programming languages.
;; - the `:builtin-emacs' property value indicates that the package is
;; distributed with Emacs and cannot be de-installed,
;; - the `:in-utils' property value indicates that the package is installed
;; by PEL into the ~/.emacs.d/utils directory and not managed by the Emacs
;; `package' library. The package name is identified by the suffix of the
;; pel-use- symbol.
;; - A symbol which is the real name of a package that is downloaded
;; from an Elpa-compliant package management site and managed trough Emacs
;; `package' library.
;; - a consp form that must be evaluated dynamically to compute the symbol or
;; list of symbols representing the Elpa packages that are used. The result
;; must be a cons cell or a list of cons cell where the car is a symbol that
;; identifies the packaging mechanism and the cdr is the package name
;; symbol. The package mechanisms supported are 'elpa and 'utils. The
;; 'elpa symbol identifies a package that is downloaded and managed by the
;; Emacs package library and comes from an Elpa-compliant repository. The
;; 'utils symbol identifies a file that is downloaded from a web-site and
;; stored into PEL's utils directory. See `pel-use-ripgrep' for an example.
;; - In the absence of the `:package-is' property, the name of the package is
;; extracted from the name of the `pel-use-' symbol.
;; `:restricted-to'
;; ----------------
;;
;; Some packages are restricted to a specific mode of Emacs operation. The
;; value of this property is a variable symbol that identifies when this
;; package is used.
;;
;; Currently, this property is only used to identify whether a package is
;; restricted to Emacs running in graphics or TTY mode. It is possible to use
;; PEL with multiple customization files. There could be one for Emacs
;; running in graphics mode and another for Emacs running in TTY mode. The
;; selection must be done in your init file before pel-init is ever called.
;; We use this property to prevent `pel-cleanup' from removing a
;; graphics-mode-only package when `pel-cleanup' is invoked from Emacs running
;; in TTY mode. The `pel-cleanup' disables packages only when the value for
;; this attribute evaluates to non-nil. In other words, `pel-cleanup' will
;; only remove a package associated to a user-option that has a
;; `:restricted-to' property set to `pel-emacs-is-graphic-p' when Emacs is
;; running in graphics mode.
;; `:choices'
;; ----------
;;
;; This property is currently used only for the code template user-options to
;; identify a sample of valid choices for the user-option. These are used in
;; the test code that generate the file sample examples stored inside the
;; example/templates directory. These files provide samples of what is
;; possible to generate with the PEL code generation.
;;; --------------------------------------------------------------------------
;;; Dependency
(require 'pel--base) ; use: `pel-expression-p'
;; ; `pel-user-option-p'
(eval-when-compile
(require 'cl-macs)) ; use: `cl-case'.
;;; --------------------------------------------------------------------------
;;; Code:
;; Validation Utilities
;; --------------------
(defun pel-indent-valid-p (n)
"Return t if N is a valid indentation integer in 2-8 range, nil otherwise."
(and (integerp n) (< n 9) (> n 1)))
(defun pel-c-style-valid-p (style)
"Return non-nil if STYLE is one of the valid CC Mode styles, nil otherwise."
(require 'cc-vars nil :noerror)
(if (boundp 'c-style-alist)
(member style (mapcar 'car c-style-alist))
(error "Failed loading cc-vars!")))
;; Property setter with validation
;; -------------------------------
;; In the code below, use the `pel-put' macro instead of the `put' function.
;; The `pel-put' macro validates the arguments and generates code only when
;; the arguments are correct. This provides compilation time code checking
;; with no impact to load and run time.
(defmacro pel-put (symbol propname value)
"Store SYMBOL's PROPNAME property with value VALUE.
Validate at `byte-compile' time."
(if (cond
((eq propname :also-required-when)
(and (consp value)
(eq (car value) 'quote)
(pel-expression-p value)))
((memq propname '(:requires :requires-package))
(and (consp value)
(eq (car value) 'quote)))
((eq propname :package-is)
(or (memq value '(:a-gate :builtin-emacs :in-utils))
(and (consp value)
(eq (car value) 'quote)
(or (eq (length (cdr value)) 1)
(and (consp (cdr value))
(pel-expression-p value))))))
((eq propname :restricted-to)
(and (consp value)
(eq (car value) 'quote)
(pel-expression-p value)))
;; choices is to help testing - accept them
((eq propname :choices)
t)
(t nil))
`(put ,symbol ,propname ,value)
`(error "Invalid %s property value %S for symbol %s"
,propname ,value ,symbol)))
;; ---------------------------------------------------------------------------
;; File Path build utility
;; -----------------------
(defun pel-pdf-directory ()
"Return the full path of the directory where PDF files are stored.
Last character is a forward slash."
(expand-file-name
(format "%s/doc/pdf/"
(file-name-directory (locate-library "pel")))))
(defun pel-pdf-file-url (topic &optional on-web category)
"Return the full path of a PEL pdf table for TOPIC in CATEGORY.
TOPIC is the file name body (no path, no extension).
CATEGORY identifies the PDF category directory name:
- if nil (the default), return main PEL mode PDF file name.
- otherwise, the CATEGORY identifies the name of a sub-directory
where other PDF files are stored and the function returns the
name of that file. This allows managing a set of PDF files for
a given topic. For instance, CATEGORY set to \"lang\",
identifies PDF files that contain programming language specific
syntax and reference information.
By default return the local file url.
If ON-WEB is non-nil return the web URL for the file hosted in GitHub."
(let ((subdir (if category
(format "%s/" category)
"")))
(if on-web
;; Return GitHub directory location.
(format "https://raw.githubusercontent.com/pierre-rouleau/pel/\
master/doc/pdf/%s%s.pdf" subdir topic)
;; Return URL for local PDF file
(format "file:%s"
(expand-file-name
(format "%s%s.pdf" subdir topic)
(pel-pdf-directory))))))
;; ---------------------------------------------------------------------------
;; User Option Data Definition
;; ---------------------------
(defgroup pel nil
"Pragmatic Emacs Library.
A collection of facilities designed to integrate and complement a large
set of Emacs libraries while providing key bindings that mainly use function
keys as key prefixes, leaving the standard Emacs keys untouched.
PEL comes with a manual and a large set of PDF files, each documenting the
commands and key bindings of a specific aspect of Emacs. The PDF files document
the standard Emacs key bindings as well as PEL's specific key bindings."
:group 'convenience
:link `(file-link :tag "Directory of PDF table files" ,(pel-pdf-directory))
:link `(url-link :tag "PEL key maps PDF" ,(pel-pdf-file-url "-pel-key-maps"))
:link `(file-link :tag "PEL @ GitHub" "https://github.com/pierre-rouleau/pel")
:package-version '(pel . "0.4.1"))
;; ---------------------------------------------------------------------------
(defgroup pel-base-emacs nil
"PEL Emacs basic configuration."
:group 'pel)
(defcustom pel-future-proof nil
"Activate future-proofing package download when set to t.
This activates the automatic download and installation of packages that
protect your Emacs installation against time changes to Emacs and to its
ecosystem. See the logic inside pel_keys.el "
:group 'pel-base-emacs
:type 'boolean
:safe #'booleanp)
(defcustom pel-emacs-source-directory nil
"Absolute path of Emacs repository root directory.
- Identify the Emacs repo root directory.
That should hold a src sub-directory.
- The name can start with \"~\".
PEL sets the `source-directory' variable to the value of
`pel-emacs-source-directory' when it starts, allowing Emacs help
to open Emacs C source code files."
:group 'pel-base-emacs
:group 'pel-pkg-for-help
:type 'directory)
(defcustom pel-auto-mode-alist nil
"Alist of filename patterns vs corresponding major mode functions to set.
These associations are added to Emacs variable `auto-mode-alist' at
initialization time.
See `auto-mode-alist' for more information.
Use the INS and DEL buttons to add associations:
- the first element is a string regxp pattern identifying the
file name to identify (which may only be matching it by its extension),
- the second is a major mode symbol."
:group 'pel-base-emacs
:type
'(repeat
(list
(string :tag "file pattern regex")
(symbol :tag "major mode "))))
(defcustom pel-prompt-accept-y-n nil
"Accept \"y\" or \"n\" instead of \"yes\" or \"no\" as answers to prompts."
:group 'pel-base-emacs
:type 'boolean
:safe #'booleanp)
(defcustom pel-modes-activating-syntax-check nil
"List of major modes that automatically activate their syntax checker.
PEL controls what syntax checker is used for each major mode.
This includes flymake and flycheck and if others exist they will
also be added to the support. A user may want to use flymake with
one language and flycheck with another. PEL supports that. By
default PEL does not activate a syntax checker when the file is
opened, allowing Emacs to run a little faster. PEL provides a
command (bound to the ``<f12> !`` key of that mode) for each
supported major mode to toggle the syntax checker on or off.
If you prefer to activate a syntax checker for a specific major
mode right when the file is opened, add the name of the major
mode to this list. PEL will then activate the syntax checker
right when the file is opened. Each entry must be the symbol
name of a major mode.
For example, to activate it in Erlang, add a line with
`erlang-mode' without the quotes."
:group 'pel-base-emacs
:type '(repeat symbol))
(defcustom pel-activates-global-minor-modes nil
"List of *global* minor-modes automatically activated for all buffers.
Enter *global* minor-mode activating function symbols.
Do not enter lambda expressions."
:group 'pel-base-emacs
:type '(repeat function))
;; ---------------------------------------------------------------------------
(defgroup pel-syntax-tools nil
"PEL syntax investigation tools."
:group 'pel)
(defcustom pel-syntax-text-properties '(category ; used by erlang.el
syntax-table)
"List of text properties used for syntax definitions.
The text properties listed here are included in the message displayed by the
`pel-syntax-at-point' command.
Use this is a tool to help debug syntax processing of major modes."
:group 'pel-syntax-tools
:type '(repeat symbol))
;; ---------------------------------------------------------------------------
(defgroup pel-fast-startup nil
"PEL fast startup options."
:link `(url-link :tag "Fast Startup PDF" ,(pel-pdf-file-url "fast-startup"))
:group 'pel)
(defcustom pel-shell-detection-envvar "_"
"Name of envvar used to detect that Emacs was launched by a shell.
The default is \"_\", the environment variable that Bash uses to
identify the name of the executable that launched it. This
environment variable is not part of the process environment when
Emacs is launched from a GUI program such as macOS Finder.
Change this value when using another shell or when running on
other operating system such as Windows. If you cannot find a
suitable environment variable that is defined when Emacs is
launched, then define an environment variable that will be
present in all instances of your shell but not inside the OS
process environment. For instance you could use the environment
name \"PEL_SHELL\"."
:group 'pel-fast-startup
:type 'string)
(defcustom pel-gui-process-environment nil
"Environment variables to set when for Emacs launched from GUI program.
When Emacs is launched from a shell it inherit the environment
variables from that shell parent process. It is then possible to
create several specialized shells and set environment variables
in the shell initialization script that will be used by Emacs.
However you can also launch Emacs from a GUI program such as
Window Explorer or macOS Finder. These use a minimal environment
set for the OS. In many way that will not be sufficient for that
Emacs process as you may want to add more directories to its PATH
and define various environment variables.
PEL provides the `pel-gui-process-environment' user-option to
specify a set of environment variables that the GUI Emacs will
then be able to use.
That may not be as flexible as using multiple specialized shells
but it will provide what is needed for the GUI Emacs. For more
flexibility use a shell launched Emacs as both terminal and
graphics modes can be launched by shell scripts.
For each variable you can use to use the variable as specified,
which is always done when the variable does not exists. But for
some variables like PATH, MANPATH, LIBPATH and others you may
want to replace, append or prepend the value to any existing
value. In that case, change the action specified for the
variable.
***************
IMPORTANT NOTES
***************
These environment variables are only used for a GUI-launched
Emacs session; an Emacs session that has not been launched by a
shell. PEL detects this type of Emacs session when it detects
that the environment variable identified by
`pel-shell-detection-envvar' is not present inside the process
environment.
PEL sets Emacs environment variable process **once** per process
execution session, during the **first** call of function
`pel-init'. Therefore if you change this you **must** restart
Emacs for the new values to take effect.
The PATH environment variable is treated specially: setting,
appending, prepending to it also sets the value of the variable
`exec-path' and variable `eshell-path-env'."
:group 'pel-fast-startup
:type '(repeat
(list :tag "Environment variable"
(string :tag "name ")
(string :tag "value")
(choice :tag "use"
(const :tag "as is, replacing exiting value if any." use-as-is)
(const :tag "append to existing value if any." append)
(const :tag "prepend to existing value if any." prepend)))))
(defcustom pel-compile-pel-bundle-autoload nil
"Whether `pel-setup-fast' byte compiles pel-bundle autoloads.el file.
Set this to t to instruct `pel-setup-fast' to force the byte-compilation of the
pel-bundle-autoloads.el file even though the autoloads.el files of Elpa
packages are not byte compiled. Byte compilation of that file may generate
byte compiler warnings but that will also speed the Emacs startup a little."
:group 'pel-fast-startup
:type 'boolean
:safe #'booleanp)
(defcustom pel-support-dual-environment nil
"Whether independent environment for terminal/TTY and graphics is enabled.
Turn it on if you want Emacs in terminal/TTY mode and Emacs in
graphics mode to use independent sets of customization and
packages. By default this feature is turned off.
It is best to turn it on by executing the function
`pel-setup-dual-environment' because that will create all
necessary files and will update the user-option in both
customization files."
:group 'pel-fast-startup
:type 'boolean
:safe #'booleanp)
;; ----
(defcustom pel-compile-emacs-init nil
"Whether PEL setup commands that update init.el also `byte-compile' it.
Note that this assumes that your init.el file does not prevent byte
compilation. If your file defines the `no-byte-compile' variable, remove that
or force it nil if you want PEL to `byte-compile' it.
Unlike the pel-bundle and package-quickstart files, PEL will not change the
value of `no-byte-compile' file variable in your init.el file."
:group 'pel-fast-startup
:type 'boolean
:safe #'booleanp)
(defcustom pel-compile-emacs-early-init nil
"Whether PEL setup commands that update early-init.el also `byte-compile' it.
Note that this assumes that your early-init.el file does not prevent byte
compilation. If your file defines the `no-byte-compile' variable, remove that
or force it nil if you want PEL to `byte-compile' it.
Unlike the pel-bundle and package-quickstart files, PEL will not change the
value of `no-byte-compile' file variable in your early-init.el file."
:group 'pel-fast-startup
:type 'boolean
:safe #'booleanp)
;; ----
(defcustom pel-support-package-quickstart nil
"When non-nil: activate package-quickstart, otherwise don't activate it.
This is only used in Emacs 27 and later."
:group 'pel-fast-startup
:type 'boolean
:safe #'booleanp)
(defcustom pel-compile-package-quickstart nil
"Whether PEL byte-compiles package-quickstart file.
Set this to t to instruct PEL to force the byte-compilation of
the package-quickstart.el file even though these files are
normally not byte compiled. Byte compilation of that file may
generate byte compiler warnings but that will also speed the
Emacs startup a little.
This is only used for Emacs 27 and later."
:group 'pel-fast-startup
:type 'boolean
:safe #'booleanp)
(defcustom pel-early-init-template
(expand-file-name "example/init/early-init.el"
(file-name-directory load-file-name))
"Path name of PEL-compatible early-init.el file template.
To be compatible with PEL your early-init.el file MUST contain
the code located in that file. You may use another file which
adds extra code for your own needs but you must include the code
located in that file template. If you do not need any extra
logic, leave the default and use the template file unmodified.
This is only used in Emacs 27 and later."
:group 'pel-fast-startup
:type '(file :must-match t))
;; ---------------------------------------------------------------------------
(defgroup pel-package-use nil
"List of external packages that can be used by PEL."
:group 'pel)
(defconst pel-elpa-obsolete-packages '(parinfer)
"Lists the PEL supported ELPA packages that are no longer available.")
(defcustom pel-elpa-packages-to-keep '(benchmark-init
elisp-lint package-lint dash)
"List of Elpa package names that should not be removed by `pel-cleanup'.
Put the names of the packages you install manually in this list.
PEL will not remove them when it performs a cleanup.
By default, PEL identifies the following packages:
- benchmark-init: use this to measure your initialization time.
- elisp-lint: check your Emacs Lisp code. PEL's ``make lint`` uses it.
elisp-lint requires package-lint and dash, which are also
in the default list."
:group 'pel-package-use
:type '(repeat symbol))
(defcustom pel-utils-packages-to-keep nil
"List of utils file names that should not be removed by `pel-cleanup'.
If you manually install Emacs Lisp files in your utils directory, you should
put their names in this list to prevent their removal by `pel-cleanup'."
:group 'pel-package-use
:type '(repeat string))
(defcustom pel-utils-dirname "utils"
"Name of the PEL utils directory, where non-Elpa Emacs files are stored.
The directory is always located in the directory identified by the Emacs
variable `user-emacs-directory'.
PEL uses \"utils\" by default but you may want to specify another
directory for whatever reason."
:group 'pel-package-use
:type 'string)
(defcustom pel-use-editor-config nil
"Control whether PEL activates EditorConfig plugin for Emacs."
:link '(url-link :tag "EditorConfig home page"
"https://editorconfig.org")
:link '(url-link :tag "editorconfig-emacs @ GitHub"
"https://github.com/editorconfig/editorconfig-emacs")
:group 'pel-base-emacs
:group 'pel-package-use
:type 'boolean
:safe #'booleanp)
(pel-put 'pel-use-editor-config :package-is 'editorconfig)
;; TODO: pel-cleanup currently does not remove the following lines from the
;; `custom-set-variable' form:
;; - '(editorconfig-mode t)
;; - '(editorconfig-mode-lighter " 🎛 ")
;; I probably need to add another property-driven concept in pel-cleanup
;; support to get it to identify forms that must be removed. Perhaps the
;; lighter config could stay, but setting the mode to true should be
;; removed. Note however, that these will not activate the mode once
;; the current cleanup has been done, they will just be left in the
;; `custom-set-variable' which has no impact once `pel-cleanup' ran and
;; uninstalled editorconfig.
;; ---------------------------------------------------------------------------
;; Alignment Support
;; -----------------
(defgroup pel-pkg-for-align nil
"Customization of PEL alignment support."
:group 'pel-package-use
:link `(url-link :tag "Align PDF" ,(pel-pdf-file-url "align")))
(defcustom pel-modes-activating-align-on-return nil
"List of major modes that automatically activate alignment on M-RET.
For these modes the buffer local variable `pel-newline-does-align' is
automatically set to t. This activates the automatic alignment of contiguous
lines when the function `pel-newline-and-indent-below' executes.
The alignment is controlled by a set of regular-expression based rules
stored in the variable `align-rules-list'.
These rules support the alignment of C and Python assignment
statements, where the alignment is done on the equal sign
character. Also for C++ \"//\" style comments.
See `align-rules-list'.
By default PEL does not activate it on any mode. To activate a mode,
add the mode name in the list.
For example, to activate it for C, add the c-mode symbol to the list."
:group 'pel-pkg-for-align
:type '(repeat symbol)
:link '(emacs-commentary-link :tag "commentary" "align.el")
:link `(url-link :tag "Align PDF" ,(pel-pdf-file-url "align")))
;; ---------------------------------------------------------------------------
;; Bookmark Support
;; ----------------
(defgroup pel-pkg-for-bookmark nil
"List of external packages that PEL can use to manage bookmarks."
:group 'pel-package-use
:link `(url-link :tag "Bookmarks PDF" ,(pel-pdf-file-url "bookmarks"))
:link '(custom-manual "(emacs)Bookmarks"))
(defcustom pel-use-bm nil
"Control whether PEL uses the bm (Visible Bookmarks) package.
With this activated PEL binds the following keys:
- <f2> : `bm-next'
- <f11> ' : `bm-toggle'
- <f11> n : `bm-next'
- <f11> p : `bm-previous'"
:group 'pel-pkg-for-bookmark
:type 'boolean
:safe #'booleanp
:link '(url-link :tag "bm @ GitHub" "https://github.com/joodland/bm"))
;; ---------------------------------------------------------------------------
;; Buffer Management
;; -----------------
(defgroup pel-pkg-for-buffer nil
"List of external packages that PEL can use to manage buffers."
:group 'pel-package-use
:link `(url-link :tag "Buffers PDF" ,(pel-pdf-file-url "buffers"))
:link '(custom-manual "(emacs)Buffers"))
(defcustom pel-use-uniquify nil
"Control whether PEL uses the uniquify package.
With this activated PEL changes the way Emacs displays the names
of the buffers that visit identically-named files.
It sets up the post-forward method for the buffers except the
special buffers (which have their own disambiguation method) and
forces rationalization of the names when buffers are killed.
With the post-forward method, if you have 3 files opened, like:
- ~/projects/p1/hello.c
- ~/projects/p2/hello.c
- ~/some/other/place/somedir/hello.c
The buffers will respectively be named:
- hello.c|p1
- hello.c|p2
- hello.c|somedir
If you kill 2 of these buffers, the remaining buffer will be named
hello.c"
:group 'pel-pkg-for-buffer
:type 'boolean
:safe #'booleanp
:link '(custom-manual "(emacs)Uniquify"))
(pel-put 'pel-use-uniquify :package-is :builtin-emacs)
(defcustom pel-use-ascii-table nil
"Control whether the `ascii-table' package is available.
When set PEL activates the ``<f11> ? A`` key sequence to
open the ASCII table in the current buffer."
:group 'pel-pkg-for-buffer
:type 'boolean
:safe #'booleanp
:link '(url-link :tag "ascii-table @ MELPA"
"https://melpa.org/#/ascii-table"))
(defcustom pel-use-nhexl-mode nil
"Control whether PEL uses the package and function `nhexl-mode'.
This mode supports editing a file in hexadecimal dump mode.
When set, PEL activates the following key sequences:
- <f11> t O : `nhexl-overwrite-only-mode'
- <f11> b x : `nhexl-mode'
- <f11> b X : `nhexl-nibble-edit-mode'"
:group 'pel-pkg-for-buffer
:type 'boolean
:safe #'booleanp
:link '(url-link :tag "nhexl @ Elpa"
"https://elpa.gnu.org/packages/nhexl-mode.html"))
(defcustom pel-use-iflipb nil
"Control whether PEL provides access to the iflipb package."
:link '(url-link :tag "iflipb @GitHub"
"https://github.com/jrosdahl/iflipb")
:group 'pel-pkg-for-buffer
:type 'boolean
:safe #'booleanp)
;; ---------------------------------------------------------------------------
(defgroup pel-pkg-for-ibuffer nil
"List of external packages that PEL can use to extend ibuffer-mode."
:group 'pel-pkg-for-buffer
:link `(url-link :tag "ibuffer-mode PDF" ,(pel-pdf-file-url
"ibuffer-mode")))
(defcustom pel-use-ibuffer-vc nil
"Control whether PEL uses & activates the ibuffer-vc package."
:group 'pel-pkg-for-ibuffer
:link '(url-link :tag "ibuffer-vc @ Github"
"https://github.com/purcell/ibuffer-vc")
:type 'boolean
:safe #'booleanp)
(defcustom pel-use-ibuffer-tramp nil
"Control whether PEL uses & activates the ibuffer-tramp package."
:group 'pel-pkg-for-ibuffer
:link '(url-link :tag "ibuffer-tramp @ GitHub"
"https://github.com/pierre-rouleau/ibuffer-tramp")
:type 'boolean
:safe #'booleanp)
(pel-put 'pel-use-ibuffer-tramp :package-is :in-utils)
;; ---------------------------------------------------------------------------
;; Completion Support
;; ------------------
(defgroup pel-pkg-for-completion nil
"List of external packages that PEL can use to manage completion.
PEL allows selecting input completion mechanism dynamically.
Aside from Emacs tab-based completion default, you can also use
Ido, Ivy, or Helm.
Ido is very flexible and powerful. It is built-in Emacs but can
be extended with several external packages which can select
various input geometries, activate 'flx' fuzzy matching, etc...
If you prefer using a simpler drop-down menu with search
capabilities built-in you may prefer Ivy.
And if you want a input completion mechanism that has tons of
functionality and are willing to learn its power, you can use
Helm.
Note that with PEL you can select the input completion used by
default and change it dynamically during an editing session, as
long as it is activated by its user-option.
- Activate Ido with : `pel-use-ido'.
- Activate ivy with : `pel-use-ivy'.
- Activate Helm with: `pel-use-helm'.
To provide smart input completion of commands related to current
major mode, use Smex and activate it with `pel-use-smex'.