-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathREADME.org
More file actions
2753 lines (2371 loc) · 97.8 KB
/
Copy pathREADME.org
File metadata and controls
2753 lines (2371 loc) · 97.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#+title: leaf.el
#+author: Naoya Yamashita
#+date: <2018-10-25 Thu>
#+exclude_tags: noexport
* Badges :noexport:
[[https://github.com/conao3/leaf.el][https://raw.githubusercontent.com/conao3/files/master/blob/headers/png/leaf.el.png]]
[[https://github.com/conao3/leaf.el/blob/master/LICENSE][https://img.shields.io/github/license/conao3/leaf.el.svg?style=flat-square]]
[[https://github.com/conao3/leaf.el/releases][https://img.shields.io/github/tag/conao3/leaf.el.svg?style=flat-square]]
[[https://travis-ci.org/conao3/leaf.el][https://img.shields.io/travis/conao3/leaf.el/master.svg?style=flat-square]]
[[https://app.codacy.com/project/conao3/leaf.el/dashboard][https://img.shields.io/codacy/grade/3ad51a9fc08e48f98b6eb75f8571f0b0.svg?logo=codacy&style=flat-square]]
[[https://www.patreon.com/conao3][https://img.shields.io/badge/patreon-become%20a%20patron-orange.svg?logo=patreon&style=flat-square]]
[[https://twitter.com/conao_3][https://img.shields.io/badge/twitter-@conao__3-blue.svg?logo=twitter&style=flat-square]]
[[https://join.slack.com/t/conao3-support/shared_invite/enQtNjUzMDMxODcyMjE1LTA4ZGRmOWYwZWE3NmE5NTkyZjk3M2JhYzU2ZmRkMzdiMDdlYTQ0ODMyM2ExOGY0OTkzMzZiMTNmZjJjY2I5NTM][https://img.shields.io/badge/chat-on_slack-blue.svg?logo=slack&style=flat-square]]
[[https://melpa.org/#/leaf][https://melpa.org/packages/leaf-badge.svg]]
[[https://stable.melpa.org/#/leaf][https://stable.melpa.org/packages/leaf-badge.svg]]
* Table of Contents :noexport:
- [[Description]]
- [[Install]]
- [[Usage]]
- [[Customize]]
- [[Syntax]]
- [[Basic keywords]]
- [[none (keyword)]]
- [[:require keyword]]
- [[#ensure][:ensure, :package keywords]]
- [[:vc keyword]]
- [[:preface, :init, :config keywords]]
- [[:defer-config keyword]]
- [[:commands keyword]]
- [[:after keyword]]
- [[:bind, :bind* keywords]]
- [[:bind-keymap, :bind-keymap* keywords]]
- [[Configure variables keywords]]
- [[:custom, :custom*, :custom-face keywords]]
- [[:pre-setq, :setq, :setq-default keywords]]
- [[:setf, :push, :pre-setf, :pre-push keywords]]
- [[Configure list keywords]]
- [[:mode, :interpreter keywords]]
- [[:magic, :magic-fallback keywords]]
- [[:hook keyword]]
- [[:load-path, :load-path* keywords]]
- [[Condition keywords]]
- [[:disabled keyword]]
- [[:if, :when, :unless keywords]]
- [[:emacs<, :emacs<=, :emacs=, :emacs>, :emacs>= keywords]]
- [[Byte compile keywords]]
- [[:defun, :defvar keywords]]
- [[Documentation keywords]]
- [[:doc, :req, :tag, :file, :url keywords]]
- [[Misc keywords]]
- [[:global-minor-mode keyword]]
- [[:advice, :advice-remove keywords]]
- [[:pl-pre-setq, :pl-setq, :pl-setq-default, :pl-custom keywords]]
- [[System keywords]]
- [[:leaf-protect keyword]]
- [[:leaf-defer keyword]]
- [[:leaf-autoload keyword]]
- [[Tips]]
- [[leaf-find feature]]
- [[Information]]
- [[Donation]]
- [[Community]]
- [[Contribution]]
- [[leaf.el mechanism]]
- [[Adding new keywords]]
- [[Migration]]
- [[leaf v3.0 to v4.0]]
- [[leaf v2.0 to v3.0]]
- [[leaf v1.0 to v2.0]]
- [[License]]
- [[Author]]
- [[Contributors]]
- [[Special Thanks]]
* Description
~leaf.el~ is yet another [[https://github.com/jwiegley/use-package][use-package]].
~leaf~ solves the stress that I feel while using the ~use-package~ for
2.5 years. By developing from scratch, we have a cleaner and more
predictable implementation than ~use-package~.
This makes it easy to maintain and add new keywords. (see [[https://github.com/conao3/leaf-keywords.el][leaf-keywords.el]])
~leaf~ has keywords almost identical to ~use-package~, but some of
usage of the keywords is different.
The quickest way to solve problem is using ~macroexpand-1~ to see the
unfolded result if it is not what you intended. And also there are
also a number of samples in this README and more in the [[https://github.com/conao3/leaf.el/blob/master/leaf-tests.el][test file]].
Currently, ~leaf.el~ and ~leaf-keywords.el~ has below rich keywords.
#+begin_src emacs-lisp
(leaf-available-keywords)
;;=> (:disabled
;; :leaf-protect
;; :load-path :load-path*
;; :leaf-autoload
;; :doc :req :tag :file :url
;; :defun :defvar :leaf-defun :leaf-defvar
;; :preface
;; :when :unless :if
;; :emacs< :emacs<= :emacs= :emacs> :emacs>=
;; :ensure :package :vc :feather :straight :el-get
;; :after
;; :commands
;; :bind :bind*
;; :mode :interpreter :magic :magic-fallback
;; :hook
;; :advice :advice-remove
;; :init
;; :pre-setq :pl-pre-setq :auth-pre-setq
;; :custom :custom* :pl-custom :auth-custom :custom-face
;; :require
;; :hydra :transient :combo :combo*
;; :smartrep :smartrep* :chord :chord*
;; :mode-hook
;; :leaf-defer
;; :config
;; :diminish :delight
;; :global-minor-mode
;; :setq :setq-default
;; :pl-setq :auth-setq :pl-setq-default :auth-setq-default)
#+end_src
* Install
~leaf.el~ and ~leaf-keywords.el~ can install with package.el from MELPA.
Please put the following code (~<leaf-install-code>~ to
~</leaf-install-code>~) to the top of your ~init.el~.
Package to be developed
- [[https://github.com/conao3/feather.el][feather.el]] instead of ~package.el~ -> (Achieved! Now available but
it is just a pakcage.el wraper)
- leaf-key.el instead of ~bind-key~ -> (Achieved! Now ~leaf~ builtin)
#+begin_src emacs-lisp
;; <leaf-install-code>
(eval-and-compile
(customize-set-variable
'package-archives '(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless (package-installed-p 'leaf)
(package-refresh-contents)
(package-install 'leaf))
(leaf leaf-keywords
:ensure t
:init
;; optional packages if you want to use :hydra, :el-get, :blackout,,,
(leaf hydra :ensure t)
(leaf el-get :ensure t)
(leaf blackout :ensure t)
:config
;; initialize leaf-keywords.el
(leaf-keywords-init)))
;; </leaf-install-code>
;; Now you can use leaf!
(leaf leaf-tree :ensure t)
(leaf leaf-convert :ensure t)
(leaf transient-dwim
:ensure t
:bind (("M-=" . transient-dwim-dispatch)))
;; You can also configure builtin package via leaf!
(leaf cus-start
:doc "define customization properties of builtins"
:tag "builtin" "internal"
:custom ((user-full-name . "Naoya Yamashita")
(user-mail-address . "conao3@gmail.com")
(user-login-name . "conao3")
(truncate-lines . t)
(menu-bar-mode . t)
(tool-bar-mode . nil)
(scroll-bar-mode . nil)
(indent-tabs-mode . nil)))
(leaf autorevert
:doc "revert buffers when files on disk change"
:tag "builtin"
:custom ((auto-revert-interval . 0.1))
:global-minor-mode global-auto-revert-mode)
;; Nest package configurations
(leaf flycheck
:doc "On-the-fly syntax checking"
:emacs>= 24.3
:ensure t
:bind (("M-n" . flycheck-next-error)
("M-p" . flycheck-previous-error))
:custom ((flycheck-emacs-lisp-initialize-packages . t))
:hook (emacs-lisp-mode-hook lisp-interaction-mode-hook)
:config
(leaf flycheck-package
:doc "A Flycheck checker for elisp package authors"
:ensure t
:config
(flycheck-package-setup))
(leaf flycheck-elsa
:doc "Flycheck for Elsa."
:emacs>= 25
:ensure t
:config
(flycheck-elsa-setup))
;; ...
)
;; ...
#+end_src
* Usage
Use ~leaf~ in your init.el like ~use-package~.
You declaratively tell the ~leaf~ to configure the package using special keywords.
~leaf~ converts your declaration into Elisp for Emacs to understand,
and Emacs executes it to configure the package.
* Customize
- ~leaf-defaults~: Default arguments for all leaf-block.
- ~leaf-expand-{{keyword}}~: If nil, not to expand that keyword.
- ~leaf-expand-minimally~: If nil, disable keywords that are not needed for debugging.
- ~leaf-default-plstore~: default ~plstore~ stored variable
- ~leaf-alias-keyword-alist~: Alist represents keyword alias. Handle KEY is alias of VALUE.
#+begin_src emacs-lisp
(defcustom leaf-alias-keyword-alist '((:ensure . :package))
"The alias keyword. KEY is treated as an alias for VALUE."
:type 'sexp
:group 'leaf)
#+end_src
This default value means ~:ensure~ is alias ~:package~.
If you want to use ~:ensure~ as ~:feather~, please set this value as
~((:ensure . :feather))~. Please more info related feather is [[https://github.com/conao3/feather.el][here]].
* Syntax
All below examples are excerpts from [[https://github.com/conao3/leaf.el/blob/master/leaf-tests.el][leaf-tests.el]].
These examples are defined in the following format.
We expect ~FORM~ will be expanded to ~EXPECT~.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand TESTCASE-NAME
'((FORM ; will be expand by `macroexpand-1'
EXPECT) ; expect FORM's expansion will be EXPECT (test by `equal')
(FORM
EXPECT)
...))
(cort-deftest-with-macroexpand-let TESTCASE-NAME
LETFORM
'((FORM ; will be expand by `macroexpand-1' in LETFORM
EXPECT) ; expect FORM's expansion will be EXPECT (test by `equal')
(FORM
EXPECT)
...))
#+end_src
* Basic keywords
** none (keyword)
*Unlike use-package*, ~leaf~ will convert to ~nil~ when used without any keywords.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/none
'(((leaf leaf)
(prog1 'leaf))))
#+end_src
** :require keyword
If you want to ~require~, you must use the ~:require~ keyword explicitly.
This is ideally the exact opposite of using the ~:no-require~ keyword
in the ~use-package~ if you does not want to ~require~ it.
The leaf's ~:require~ keyword is powerful, specify ~t~ to require the
package, and specify multi symbols to ~require~ all of them.
Since the priority is lower than that of the conditional branch
keyword described later, it is possible to assign whether to ~require~
or not by the conditional branch keyword.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/require
'(
;; 't will be converted leaf--name
((leaf leaf
:init (leaf-pre-init)
:when leaf-workable-p
:require t
:config (leaf-init))
(prog1 'leaf
(when leaf-workable-p
(leaf-pre-init)
(require 'leaf)
(leaf-init))))
;; 'nil will be just ignored it
((leaf leaf
:init (leaf-pre-init)
:require nil
:config (leaf-init))
(prog1 'leaf
(leaf-pre-init)
(leaf-init)))
;; multi symbols will be accepted
((leaf leaf
:init (leaf-pre-init)
:require leaf leaf-polyfill
:config (leaf-init))
(prog1 'leaf
(leaf-pre-init)
(require 'leaf)
(require 'leaf-polyfill)
(leaf-init)))
;; multi keywords will be accepted
((leaf leaf
:init (leaf-pre-init)
:require t
:require leaf-polyfill
:config (leaf-init))
(prog1 'leaf
(leaf-pre-init)
(require 'leaf)
(require 'leaf-polyfill)
(leaf-init)))
;; multi symbols in list will be accepted
((leaf leaf
:init (leaf-pre-init)
:require (leaf leaf-polyfill leaf-sub leaf-subsub)
:config (leaf-init))
(prog1 'leaf
(leaf-pre-init)
(require 'leaf)
(require 'leaf-polyfill)
(require 'leaf-sub)
(require 'leaf-subsub)
(leaf-init)))))
#+end_src
** :package, :ensure keywords
:PROPERTIES:
:CUSTOM_ID: ensure
:END:
~:package~ provide ~package.el~ frontend.
Because [[https://github.com/conao3/leaf-keywords.el][leaf-keywords.el]] has ~:el-get~ keyword, ~:package~ provide ~package.el~ frontend.
Since ~:ensure~ is to use ~package.el~ by default, ~:ensure~ and
~:package~ produce the same result.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/ensure
'(
;; 't will be converted leaf--name
((leaf leaf
:ensure t
:config (leaf-init))
(prog1 'leaf
(leaf-handler-package leaf leaf nil)
(leaf-init)))
;; multi symbols will be accepted
((leaf leaf
:ensure t leaf-browser
:config (leaf-init))
(prog1 'leaf
(leaf-handler-package leaf leaf nil)
(leaf-handler-package leaf leaf-browser nil)
(leaf-init)))
;; multi symbols in list will be accepted
((leaf leaf
:ensure (feather leaf-key leaf-browser)
:config (leaf-init))
(prog1 'leaf
(leaf-handler-package leaf feather nil)
(leaf-handler-package leaf leaf-key nil)
(leaf-handler-package leaf leaf-browser nil)
(leaf-init)))))
(cort-deftest-with-macroexpand leaf/handler-package
'(
;; simple :ensure expandion example
((leaf macrostep :ensure t)
(prog1 'macrostep
(leaf-handler-package macrostep macrostep nil)))
;; `leaf-handler-package' expansion example.
;; If `macrostep' is installed, set it as a selected package;
;; otherwise try to install it.
;; If installation fails, update local cache and retry to install.
((leaf-handler-package macrostep macrostep nil)
(if (package-installed-p 'macrostep)
(package--update-selected-packages '(macrostep) nil)
(unless (assoc 'macrostep package-archive-contents)
(package-refresh-contents))
(condition-case err
(package-install 'macrostep)
(error
(condition-case err
(progn
(package-refresh-contents)
(package-install 'macrostep))
(error
(display-warning 'leaf
(format "In `macrostep' block, failed to :package of macrostep. Error msg: %s"
(error-message-string err)))))))))))
#+end_src
** :vc keyword
~:vc~ provide ~package-vc-install~ frontend.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/vc
'(((leaf bbdb
:vc ( :url "https://git.savannah.nongnu.org/git/bbdb.git"
:lisp-dir "lisp"))
(prog1 'bbdb
(leaf-handler-vc bbdb
(bbdb
(:url "https://git.savannah.nongnu.org/git/bbdb.git" :lisp-dir "lisp")))))
((leaf *bbdb-custom*
:vc (bbdb
:url "https://git.savannah.nongnu.org/git/bbdb.git"
:lisp-dir "lisp"))
(prog1 '*bbdb-custom*
(leaf-handler-vc *bbdb-custom*
(bbdb
(:url "https://git.savannah.nongnu.org/git/bbdb.git" :lisp-dir "lisp")))))))
#+end_src
** :preface, :init, :config keywords
These keywords are provided to directly describe elisp with various
settings that ~leaf~ does not support.
These keywords are provided to control where the arguments expand,
- ~:preface~ expands before the conditional branch keywords; ~:if~, ~when~ and ~unless~.
- ~:init~ expands after the conditional branch keyword before ~:require~.
- ~:config~ expands after ~:require~.
You don't need to put ~progn~ because ~leaf~ can receive multiple
S-expressions, but you can do so if you prefer it.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/preface
'(
;; sexp will be expanded in order of :preface, :when, :require, :init, :config.
((leaf leaf
:require t
:preface (preface-init)
:when (some-condition)
:init (package-preconfig)
:config (package-init))
(prog1 'leaf
(preface-init)
(when (some-condition)
(package-preconfig)
(require 'leaf)
(package-init))))
;; multi sexp will be accepted
((leaf leaf
:preface
(leaf-pre-init)
(leaf-pre-init-after)
:when (some-condition)
:require t
:init (package-preconfig)
:config (package-init))
(prog1 'leaf
(leaf-pre-init)
(leaf-pre-init-after)
(when
(some-condition)
(package-preconfig)
(require 'leaf)
(package-init))))
;; you can use `progn' if you prefer it
((leaf leaf
:preface (progn
(leaf-pre-init)
(leaf-pre-init-after))
:when (some-condition)
:require t
:init (package-preconfig)
:config (package-init))
(prog1 'leaf
(progn
(leaf-pre-init)
(leaf-pre-init-after))
(when
(some-condition)
(package-preconfig)
(require 'leaf)
(package-init))))))
#+end_src
** :defer-config keyword
=:defer-config= is similar to =:config=, but with =eval-after-load= as the argument.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/defer-config
'(((leaf leaf
:init (leaf-pre-init)
:defer-config (leaf-init))
(prog1 'leaf
(leaf-pre-init)
(eval-after-load 'leaf
(progn
(leaf-init)))))
((leaf leaf
:init (leaf-init)
:defer-config
(leaf-pre-init)
(leaf-pre-init-after))
(prog1 'leaf
(leaf-init)
(eval-after-load 'leaf
(progn
(leaf-pre-init)
(leaf-pre-init-after)))))))
#+end_src
** :commands keyword
~commands~ keyword configures ~autoload~ for its leaf-block name.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/commands
'(
;; specify a symbol to set to autoload function
((leaf leaf
:commands leaf
:config (leaf-init))
(prog1 'leaf
(autoload #'leaf "leaf" nil t)
(eval-after-load 'leaf
'(progn
(leaf-init)))))
;; multi symbols will be accepted
((leaf leaf
:commands leaf leaf-pairp leaf-plist-get)
(prog1 'leaf
(autoload #'leaf "leaf" nil t)
(autoload #'leaf-pairp "leaf" nil t)
(autoload #'leaf-plist-get "leaf" nil t)))
;; multi symbols in list will be accepted
((leaf leaf
:commands (leaf leaf-pairp leaf-plist-get))
(prog1 'leaf
(autoload #'leaf "leaf" nil t)
(autoload #'leaf-pairp "leaf" nil t)
(autoload #'leaf-plist-get "leaf" nil t)))
;; It is accepted even if you specify symbol and list at the same time
((leaf leaf
:commands leaf (leaf-pairp leaf-plist-get (leaf-insert-list-after)))
(prog1 'leaf
(autoload #'leaf "leaf" nil t)
(autoload #'leaf-pairp "leaf" nil t)
(autoload #'leaf-plist-get "leaf" nil t)
(autoload #'leaf-insert-list-after "leaf" nil t)))))
#+end_src
** :after keyword
~:after~ keyword configure loading order.
*Currently it does not support :or in :after like use-package.*
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/after
'(
;; 't will be converted leaf--name
((leaf leaf-browser
:after leaf
:require t
:config (leaf-browser-init))
(prog1 'leaf-browser
(eval-after-load 'leaf
'(progn
(require 'leaf-browser)
(leaf-browser-init)))))
;; multi symbols will be accepted
((leaf leaf-browser
:after leaf org orglyth
:require t
:config (leaf-browser-init))
(prog1 'leaf-browser
(eval-after-load 'orglyth
'(eval-after-load 'org
'(eval-after-load 'leaf
'(progn
(require 'leaf-browser)
(leaf-browser-init)))))))
;; multi symbols in list will be accepted
((leaf leaf-browser
:after leaf (org orglyth)
:require t
:config (leaf-browser-init))
(prog1 'leaf-browser
(eval-after-load 'orglyth
'(eval-after-load 'org
'(eval-after-load 'leaf
'(progn
(require 'leaf-browser)
(leaf-browser-init)))))))
;; duplicated symbol will be ignored
((leaf leaf-browser
:after leaf (org orglyth) org org
:require t
:config (leaf-browser-init))
(prog1 'leaf-browser
(eval-after-load 'orglyth
'(eval-after-load 'org
'(eval-after-load 'leaf
'(progn
(require 'leaf-browser)
(leaf-browser-init)))))))
;; if specified t, assume leaf--name specified
((leaf leaf-browser
:after t
:require t
:config (leaf-browser-init))
(prog1 'leaf-browser
(eval-after-load 'leaf-browser
'(progn
(require 'leaf-browser)
(leaf-browser-init)))))))
#+end_src
** :bind, :bind* keywords
~:bind~ and ~:bind*~ provide frontend for keybind manager.
When defined globally, key bindings and their corresponding functions
are specified in dotted pairs.
To set it to a specific map, *place the map name as a keyword or
symbol* at the top of the list.
If you omit ~:package~, use leaf--name as ~:package~ to lazy load.
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/bind
'(
;; cons-cell will be accepted
((leaf macrostep
:ensure t
:bind ("C-c e" . macrostep-expand))
(prog1 'macrostep
(unless (fboundp 'macrostep-expand) (autoload #'macrostep-expand "macrostep" nil t))
(declare-function macrostep-expand "macrostep")
(leaf-handler-package macrostep macrostep nil)
(leaf-keys (("C-c e" . macrostep-expand)))))
;; multi cons-cell will be accepted
((leaf color-moccur
:bind
("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(leaf-keys (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))))
;; multi cons-cell in list will be accepted
((leaf color-moccur
:bind (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(leaf-keys (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))))
;; bind to nil to unbind shortcut
((leaf color-moccur
:bind (("M-s" . nil)
("M-s o" . isearch-moccur)
("M-s i" . isearch-moccur-all)))
(prog1 'color-moccur
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(leaf-keys (("M-s")
("M-s o" . isearch-moccur)
("M-s i" . isearch-moccur-all)))))
;; nested cons-cell list will be accepted
((leaf color-moccur
:bind (("M-s O" . moccur)
(("M-o" . isearch-moccur)
(("M-O" . isearch-moccur-all))
("M-s" . isearch-moccur-some))))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-some) (autoload #'isearch-moccur-some "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(declare-function isearch-moccur-some "color-moccur")
(leaf-keys (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)
("M-s" . isearch-moccur-some)))))
;; use keyword at first element to bind specific map
((leaf color-moccur
:bind (("M-s O" . moccur)
(:isearch-mode-map
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(defvar isearch-mode-map)
(leaf-keys (("M-s O" . moccur)
(:isearch-mode-map
:package color-moccur
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))))
;; specific map at top-level will be accepted
((leaf color-moccur
:bind
("M-s O" . moccur)
(:isearch-mode-map
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(defvar isearch-mode-map)
(leaf-keys (("M-s O" . moccur)
(:isearch-mode-map
:package color-moccur
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))))
;; use :package to deffering :isearch-mode-map declared
((leaf color-moccur
:bind (("M-s O" . moccur)
(:isearch-mode-map
:package isearch
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(defvar isearch-mode-map)
(leaf-keys (("M-s O" . moccur)
(:isearch-mode-map
:package isearch
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))))
;; you can use symbol instead of keyword to specify map
((leaf color-moccur
:bind (("M-s O" . moccur)
(isearch-mode-map
:package isearch
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(defvar isearch-mode-map)
(leaf-keys (("M-s O" . moccur)
(isearch-mode-map
:package isearch
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))))
;; you can use vectors to remap etc
((leaf swiper
:ensure t
:bind (([remap isearch-forward] . swiper)))
(prog1 'swiper
(unless (fboundp 'swiper) (autoload #'swiper "swiper" nil t))
(declare-function swiper "swiper")
(leaf-handler-package swiper swiper nil)
(leaf-keys (([remap isearch-forward] . swiper)))))
((leaf files
:bind (([(control ?x) (control ?f)] . find-file)))
(prog1 'files
(unless (fboundp 'find-file) (autoload #'find-file "files" nil t))
(declare-function find-file "files")
(leaf-keys (([(control ?x) (control ?f)] . find-file)))))
;; you can bind the lambda.
((leaf color-moccur
:bind ("M-s O" . (lambda () "color-moccur" (interactive) (color-moccur))))
(prog1 'color-moccur
(leaf-keys (("M-s O" . (lambda () "color-moccur" (interactive) (color-moccur)))))))))
(cort-deftest-with-macroexpand leaf/bind*
'(
;; bind* to bind override any key-bind map
((leaf color-moccur
:bind*
("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))
(prog1 'color-moccur
(autoload #'moccur "color-moccur" nil t)
(autoload #'isearch-moccur "color-moccur" nil t)
(autoload #'isearch-moccur-all "color-moccur" nil t)
(leaf-keys* (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))))))
#+end_src
** :bind-keymap, :bind-keymap* keywords
~:bind-keymap~ and ~:bind-keymap*~ provide frontend for keybind manager for binding keymap.
Basic usage is same as ~:bind~ and ~:bind*~
#+begin_src emacs-lisp
(cort-deftest-with-macroexpand leaf/bind
'(
;; cons-cell will be accepted
((leaf macrostep
:ensure t
:bind ("C-c e" . macrostep-expand))
(prog1 'macrostep
(unless (fboundp 'macrostep-expand) (autoload #'macrostep-expand "macrostep" nil t))
(declare-function macrostep-expand "macrostep")
(leaf-handler-package macrostep macrostep nil)
(leaf-keys (("C-c e" . macrostep-expand)))))
;; multi cons-cell will be accepted
((leaf color-moccur
:bind
("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(leaf-keys (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))))
;; multi cons-cell in list will be accepted
((leaf color-moccur
:bind (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(leaf-keys (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)))))
;; bind to nil to unbind shortcut
((leaf color-moccur
:bind (("M-s" . nil)
("M-s o" . isearch-moccur)
("M-s i" . isearch-moccur-all)))
(prog1 'color-moccur
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(leaf-keys (("M-s")
("M-s o" . isearch-moccur)
("M-s i" . isearch-moccur-all)))))
;; nested cons-cell list will be accepted
((leaf color-moccur
:bind (("M-s O" . moccur)
(("M-o" . isearch-moccur)
(("M-O" . isearch-moccur-all))
("M-s" . isearch-moccur-some))))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-some) (autoload #'isearch-moccur-some "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(declare-function isearch-moccur-some "color-moccur")
(leaf-keys (("M-s O" . moccur)
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all)
("M-s" . isearch-moccur-some)))))
;; use keyword at first element to bind specific map
((leaf color-moccur
:bind (("M-s O" . moccur)
(:isearch-mode-map
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))
(prog1 'color-moccur
(unless (fboundp 'moccur) (autoload #'moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur) (autoload #'isearch-moccur "color-moccur" nil t))
(unless (fboundp 'isearch-moccur-all) (autoload #'isearch-moccur-all "color-moccur" nil t))
(declare-function moccur "color-moccur")
(declare-function isearch-moccur "color-moccur")
(declare-function isearch-moccur-all "color-moccur")
(defvar isearch-mode-map)
(leaf-keys (("M-s O" . moccur)
(:isearch-mode-map
:package color-moccur
("M-o" . isearch-moccur)
("M-O" . isearch-moccur-all))))))
;; specific map at top-level will be accepted