Skip to content

Commit d49df3f

Browse files
committed
Add: autoloads
I think the macros should have them too, because if the user hasn't called one of the autoloaded commands yet, or hasn't explicitly REQUIREd the library, the macros won't be loaded.
1 parent b31c1f5 commit d49df3f

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

README.org

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ Chemacs tries to implement this idea in a user-friendly way, taking care of the
704704
Byte-compile and load all elisp files in ~DIRECTORY~. Interactively, directory defaults to ~default-directory~ and asks for confirmation.
705705

706706
#+BEGIN_SRC elisp :exports code :tangle epdh.el
707+
;;;###autoload
707708
(defun epdh/byte-compile-and-load-directory (directory)
708709
"Byte-compile and load all elisp files in DIRECTORY.
709710
Interactively, directory defaults to `default-directory' and asks
@@ -723,6 +724,7 @@ Byte-compile and load all elisp files in ~DIRECTORY~. Interactively, directory
723724
Replace macro form before or after point with its expansion.
724725

725726
#+BEGIN_SRC elisp :exports code :eval no-export :tangle epdh.el
727+
;;;###autoload
726728
(defun epdh/emacs-lisp-macroreplace ()
727729
"Replace macro form before or after point with its expansion."
728730
(interactive)
@@ -1451,6 +1453,7 @@ Chris Wellons explains five ways to write faster Emacs Lisp code.
14511453
From Phil Lord's [[http://phillord.github.io/m-buffer-el/#sec-5-1-2][m-buffer-el]]:
14521454

14531455
#+BEGIN_SRC elisp :exports code :tangle epdh.el
1456+
;;;###autoload
14541457
(cl-defmacro bench (&optional (times 100000) &rest body)
14551458
"Call `benchmark-run-compiled' on BODY with TIMES iterations, returning list suitable for Org source block evaluation.
14561459
Garbage is collected before calling `benchmark-run-compiled' to
@@ -1484,6 +1487,7 @@ When called from an Org source block, it gives output like this:
14841487
These macros make comparing multiple forms easy:
14851488

14861489
#+BEGIN_SRC elisp :exports code :results silent :tangle epdh.el
1490+
;;;###autoload
14871491
(cl-defmacro bench-multi (&key (times 1) forms ensure-equal raw)
14881492
"Return Org table as a list with benchmark results for FORMS.
14891493
Runs FORMS with `benchmark-run-compiled' for TIMES iterations.
@@ -1668,6 +1672,7 @@ So this macro showed which code is faster and helped catch a subtle bug.
16681672
To evaluate forms with lexical binding enabled, use this macro:
16691673

16701674
#+BEGIN_SRC elisp :exports code :tangle epdh.el
1675+
;;;###autoload
16711676
(cl-defmacro bench-multi-lexical (&key (times 1) forms ensure-equal raw)
16721677
"Return Org table as a list with benchmark results for FORMS.
16731678
Runs FORMS from a byte-compiled temp file with `lexical-binding'
@@ -1758,6 +1763,7 @@ The ~buffer-local-value~ form improved by about 24% when using lexical binding.
17581763
This macro compares dynamic and lexical binding.
17591764

17601765
#+BEGIN_SRC elisp :exports code :tangle epdh.el
1766+
;;;###autoload
17611767
(cl-defmacro bench-dynamic-vs-lexical-binding (&key (times 1) forms ensure-equal)
17621768
"Benchmark FORMS with both dynamic and lexical binding.
17631769
Calls `bench-multi' and `bench-multi-lexical', which see."
@@ -1803,6 +1809,7 @@ Example:
18031809
Call this macro from an Org source block and you'll get a results block showing which 20 functions were called the most times, how long they took to run, etc. =prefixes= should be a list of symbols matching the prefixes of the functions you want to instrument.
18041810

18051811
#+BEGIN_SRC elisp :exports both :eval no-export :tangle epdh.el
1812+
;;;###autoload
18061813
(defmacro elp-profile (times prefixes &rest body)
18071814
(declare (indent defun))
18081815
`(let (output)

epdh.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
;;;; General tools
3939

40+
;;;###autoload
4041
(defun epdh/byte-compile-and-load-directory (directory)
4142
"Byte-compile and load all elisp files in DIRECTORY.
4243
Interactively, directory defaults to `default-directory' and asks
@@ -50,6 +51,7 @@ for confirmation."
5051
(dolist (file files)
5152
(byte-compile-file file 'load)))))
5253

54+
;;;###autoload
5355
(defun epdh/emacs-lisp-macroreplace ()
5456
"Replace macro form before or after point with its expansion."
5557
(interactive)
@@ -70,6 +72,7 @@ for confirmation."
7072

7173
;;;; Profiling / Optimization
7274

75+
;;;###autoload
7376
(cl-defmacro bench (&optional (times 100000) &rest body)
7477
"Call `benchmark-run-compiled' on BODY with TIMES iterations, returning list suitable for Org source block evaluation.
7578
Garbage is collected before calling `benchmark-run-compiled' to
@@ -83,6 +86,7 @@ avoid counting existing garbage which needs collection."
8386
(progn
8487
,@body)))))
8588

89+
;;;###autoload
8690
(cl-defmacro bench-multi (&key (times 1) forms ensure-equal raw)
8791
"Return Org table as a list with benchmark results for FORMS.
8892
Runs FORMS with `benchmark-run-compiled' for TIMES iterations.
@@ -179,6 +183,7 @@ avoid counting existing garbage which needs collection."
179183
(format "%.6f" (fourth (nth i results)))
180184
0)))))
181185

186+
;;;###autoload
182187
(cl-defmacro bench-multi-lexical (&key (times 1) forms ensure-equal raw)
183188
"Return Org table as a list with benchmark results for FORMS.
184189
Runs FORMS from a byte-compiled temp file with `lexical-binding'
@@ -201,6 +206,7 @@ the benchmark is uninterned."
201206
(delete-file temp-file)
202207
(unintern (symbol-name fn) nil))))
203208

209+
;;;###autoload
204210
(cl-defmacro bench-dynamic-vs-lexical-binding (&key (times 1) forms ensure-equal)
205211
"Benchmark FORMS with both dynamic and lexical binding.
206212
Calls `bench-multi' and `bench-multi-lexical', which see."
@@ -218,6 +224,7 @@ Calls `bench-multi' and `bench-multi-lexical', which see."
218224
(list 'hline)
219225
(bench-multi-process-results (append dynamic lexical)))))
220226

227+
;;;###autoload
221228
(defmacro elp-profile (times prefixes &rest body)
222229
(declare (indent defun))
223230
`(let (output)

index.html

Lines changed: 16 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)