60
60
; ;; requires
61
61
62
62
(defun racket-tidy-requires ()
63
- " Make a single \" require\" form, modules sorted, one per line .
63
+ " Make a single, sorted \" require\" form.
64
64
65
- The scope of this command is the innermost module around point,
66
- including the outermost module for a file using a \" #lang\" line.
67
- All require forms within that module are combined into a single
68
- form. Within that form:
65
+ The scope of this command is the innermost module around point --
66
+ whether an explicit submodule form or the outermost module for a
67
+ file that has a \" #lang\" line.
69
68
70
- - A single subform is used for each phase level, sorted in this
71
- order: for-syntax, for-template, for-label, for-meta, and
72
- plain (phase 0).
69
+ Merge all require forms within that module to one form.
73
70
74
- - Within each level subform, the modules are sorted:
71
+ Use a single require-spec for each phase-level, sorted in this
72
+ order: for-syntax, for-template, for-label, for-meta, and
73
+ plain (phase 0).
75
74
76
- - Collection path modules -- sorted alphabetically .
75
+ Within each phase-level, sort require-specs by module name .
77
76
78
- - Subforms such as only-in .
77
+ Format at most one module per line .
79
78
80
- - Quoted relative requires -- sorted alphabetically.
81
-
82
- At most one required module is listed per line.
79
+ Simplify gratuitous require-specs. For example reduce (only-in m)
80
+ to m and elide (combine-in).
83
81
84
82
See also: `racket-trim-requires' and `racket-base-requires' ."
85
83
(interactive )
@@ -110,16 +108,21 @@ See also: `racket-trim-requires' and `racket-base-requires'."
110
108
(funcall callback result))))))
111
109
112
110
(defun racket-trim-requires ()
113
- " Like `racket-tidy-requires' but also deletes unnecessary requires.
111
+ " Like `racket-tidy-requires' but also delete unnecessary requires.
112
+
113
+ Use macro-debugger/analysis/check-requires to analyze.
114
+
115
+ The analysis:
116
+
117
+ - Needs the `macro-debugger-lib` package.
114
118
115
- Note: This only works when the source file can be fully expanded
116
- with no errors.
119
+ - Only works when the source file can be fully expanded with no
120
+ errors.
117
121
118
- Note: This only works for requires at the top level of a source
119
- file using #lang. It does NOT work for require forms inside
120
- module forms. Furthermore, it is not smart about module+ or
121
- module* forms -- it might delete top level requires that are
122
- actually needed by such submodules.
122
+ - Only works for requires at the top level of a source file using
123
+ #lang -- not for requires inside submodule forms. Furthermore, it
124
+ is not smart about module+ or module* forms -- it might delete
125
+ outer requires that are actually needed by such submodules.
123
126
124
127
See also: `racket-base-requires' ."
125
128
(interactive )
@@ -143,24 +146,16 @@ See also: `racket-base-requires'."
143
146
(defun racket-base-requires ()
144
147
" Change from \" #lang racket\" to \" #lang racket/base\" .
145
148
146
- Adds explicit requires for imports that are provided by
147
- \" racket\" but not by \" racket/base\" .
149
+ Using \" racket/base\" is a recommended optimization for Racket
150
+ applications. Loading all of \" racket\" is slower and uses more
151
+ memory.
148
152
149
- This is a recommended optimization for Racket applications.
150
- Avoiding loading all of \" racket\" can reduce load time and
151
- memory footprint.
153
+ Add explicit requires for imports that are provided by \" racket\"
154
+ but not by \" racket/base\" .
152
155
153
- Also, as does `racket-trim-requires' , this removes unneeded
154
- modules and tidies everything into a single, sorted require form.
155
-
156
- Note: This only works when the source file can be fully expanded
157
- with no errors.
158
-
159
- Note: This only works for requires at the top level of a source
160
- file using #lang. It does NOT work for require forms inside
161
- module forms. Furthermore, it is not smart about module+ or
162
- module* forms -- it might delete top level requires that are
163
- actually needed by such submodules.
156
+ Also do the equivalent of `racket-trim-requires' and
157
+ `racket-tidy-require' . See those commands for additional notes
158
+ and caveats.
164
159
165
160
Note: Currently this only helps change \" #lang racket\" to
166
161
\" #lang racket/base\" . It does not help with other similar
@@ -268,29 +263,23 @@ module form, meaning the outermost, file module."
268
263
Useful when you know the name of an export but don't remember
269
264
from what module it is exported.
270
265
271
- At the prompt:
266
+ 1 At the prompt, you may :
272
267
\\ <minibuffer-local-map>
273
268
274
- Use \\ [next-history-element] to load the identifier at point.
275
- You may also need to \\ [move-end-of-line] to see candidates.
276
-
277
- Or type anything.
269
+ - Use \\ [next-history-element] to load the identifier at point.
270
+ You might also need to \\ [move-end-of-line] to see candidates.
278
271
279
- After you choose:
272
+ - Or, type anything.
280
273
281
- The identifier you chose is inserted at point if not already
282
- there.
274
+ 2. After you choose, this command will:
283
275
284
- A \" require\" form is inserted, followed by doing a
285
- `racket-tidy-requires' .
276
+ - Insert the identifier at point if not already there.
286
277
287
- When more than one module supplies an identifer with the same
288
- name, the first is used -- for example \" racket/base\" instead of
289
- \" racket\" .
278
+ - Insert a \" require\" form and do `racket-tidy-requires' .
290
279
291
- Caveat: This works in terms of identifiers that are documented.
292
- The mechanism is similar to that used for Racket's \" Search
293
- Manuals \" feature. Today there exists no system-wide database of
280
+ Caveat: This works only for identifiers that are documented. The
281
+ mechanism is similar to that used for Racket's \" Search Manuals \"
282
+ feature. Today there exists no system-wide database of
294
283
identifiers that are exported but not documented."
295
284
(interactive )
296
285
(racket--assert-sexp-edit-mode)
0 commit comments