66
66
; ; by `sdml-mode' and when typing one of the abbreviations below type space to
67
67
; ; expand.
68
68
; ;
69
- ; ; Typing `d t SPC ' will prompt for a name and expand into the SDML declaration
69
+ ; ; Typing `d t SPCA ' will prompt for a name and expand into the SDML declaration
70
70
; ; `datatype MyName ← opaque _' where the underscore character represents the new
71
71
; ; cursor position.
72
72
; ;
92
92
; ;
93
93
; ; `(add-hook 'after-save-hook 'sdml-validate-current-buffer)'
94
94
; ;
95
- ; ; `sdml-mode-current-buffer-dependencies ' (\\ [sdml-mode-current-buffer-dependencies ])
95
+ ; ; `sdml-mode-current-buffer-dependency-tree ' (\\ [sdml-mode-current-buffer-dependency-tree ])
96
96
; ; to display the dependencies of the curtent buffer's module.
97
97
; ;
98
98
132
132
133
133
(defcustom sdml-mode-prettify-symbols-alist
134
134
'((" ->" . ?→ ) (" <-" . ?← ) (" forall" ?∀ ) (" exists" ?∃ ) (" in" ?∈ ) (" :=" ?≔ ))
135
- " An alist of symbol prettifications used for `prettify-symbols-alist' ."
135
+ " An alist of symbol replacements used for `prettify-symbols-alist' ."
136
136
:tag " Symbol mapping for prettify"
137
137
:type '(repeat (cons string character))
138
138
:group 'sdml )
154
154
; ; --------------------------------------------------------------------------
155
155
156
156
(defun sdml-mode--tree-sitter-setup (&optional dylib-file )
157
- " Load and connect the parser library in DYLIB-FILE.
157
+ " Internal: Load and connect the parser library in DYLIB-FILE.
158
158
159
159
Load the dynamic library, either with the explicit path
160
160
in DYLIB-FILE, or by searching the path in `tree-sitter-load-path' .
@@ -189,48 +189,92 @@ platform-specific extension in `tree-sitter-load-suffixes'."
189
189
?\n ))
190
190
191
191
(defun sdml-mode--command-setup ()
192
- " Setup buffer commands."
192
+ " Internal: Setup buffer commands."
193
193
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter )
194
194
(setq-local ansi-color-for-compilation-mode t )
195
195
(add-to-list 'compilation-error-regexp-alist-alist
196
196
`(sdml , sdml-mode-validation-error-regexp 5 6 7 (2 . 3 )))
197
197
(add-to-list 'compilation-error-regexp-alist 'sdml ))
198
198
199
- (defun sdml-mode-validate-file (file-name )
200
- " Validate FILE-NAME using the `compile' command."
201
- (interactive " fSDML File name: " sdml-mode)
199
+ (defun sdml-mode--exec-validator (file-name )
200
+ " Internal: execute the command-line validator for FILE-NAME."
202
201
(let ((cmd-line (sdml-mode-cli-make-command
203
202
" validate"
204
203
(sdml-mode-cli-make-arg 'level sdml-mode-validation-level)
205
204
(sdml-mode-cli-make-arg 'input file-name))))
206
205
(when cmd-line
207
206
(compile cmd-line))))
208
207
208
+ (defun sdml-mode-validate-file (file-name )
209
+ " Validate FILE-NAME using the `compile' command.
210
+
211
+ This command executes the SDML command-line tool's validation
212
+ tool, on the file FILE-NAME, using the value of
213
+ `sdml-mode-validation-level' to determine the level of messages
214
+ output. The command uses the `compile' function and the resulting
215
+ window supports error navigation and source highlighting as
216
+ usual."
217
+ (interactive " fSDML File name: " )
218
+ (sdml-mode--exec-validator file-name))
219
+
209
220
(defun sdml-mode-validate-current-buffer ()
210
- " Validate the current buffer using the `compile' command."
221
+ " Validate the current buffer using the `compile' command.
222
+
223
+ This command executes the SDML command-line tool's validation
224
+ tool, on the current buffer's underlying file, using the value of
225
+ `sdml-mode-validation-level' to determine the level of messages
226
+ output. The command uses the `compile' function and the resulting
227
+ window supports error navigation and source highlighting as
228
+ usual."
211
229
(interactive nil sdml-mode)
212
- (let ((cmd-line (sdml-mode-cli-make-command
213
- " validate"
214
- (sdml-mode-cli-make-arg 'level sdml-mode-validation-level)
215
- 'current-buffer )))
216
- (when cmd-line
217
- (compile cmd-line))))
230
+ (sdml-mode--exec-validator (buffer-file-name )))
218
231
219
232
220
233
; ; --------------------------------------------------------------------------
221
234
; ; Buffer Commands Dependencies
222
235
; ; --------------------------------------------------------------------------
223
236
237
+
238
+ (defun sdml-mode-current-buffer-dependency-graph ()
239
+ " Show full dependency graph in SVG of the current buffer.
240
+
241
+ This command generates an SVG representing the current buffer's
242
+ dependencies as a directed graph. The command uses the SDML
243
+ command-line tool to generate a temporary file which is then
244
+ opened in a new window. The resulting image window may be dismissed
245
+ using the key `q' ."
246
+ (interactive nil sdml-mode)
247
+ (cond
248
+ (window-system
249
+ (let* ((output-file-name (concat (make-temp-file " sdml-mode" ) " .svg" ))
250
+ (cmd-line (sdml-mode-cli-make-command
251
+ " deps"
252
+ (sdml-mode-cli-make-arg 'output output-file-name)
253
+ (sdml-mode-cli-make-arg 'output-format 'graph )
254
+ (sdml-mode-cli-make-arg 'depth 0 )
255
+ 'current-buffer )))
256
+ (when cmd-line
257
+ (sdml-mode-cli-run-command cmd-line)
258
+ (find-file-other-window output-file-name))))
259
+ (t (message " Command only available if window-system is set " ))))
260
+
224
261
(defun sdml-mode-current-buffer-dependency-tree (depth )
225
- " Dependency of the current buffer, to a max DEPTH."
262
+ " Show the dependency tree of the current buffer, to a max DEPTH.
263
+
264
+ This command generates a textual tree representing the current
265
+ buffer's dependencies. The command uses the SDML command-line
266
+ tool to generate the tree, using DEPTH to denote how many levels
267
+ of dependencies to display. The resulting window may be dismissed
268
+ using the key `q' , and it's content may be refreshed with the key
269
+ `g' ."
226
270
(interactive " nMax depth of tree (0=all): " sdml-mode)
227
- (when (derived-mode-p 'sdml-mode )
228
- (let ((cmd-line (sdml-mode-cli-make-command
271
+ (let ((cmd-line (sdml-mode-cli-make-command
229
272
" deps"
273
+ (sdml-mode-cli-make-arg 'output-format 'tree )
230
274
(sdml-mode-cli-make-arg 'depth depth)
231
275
'current-buffer )))
232
276
(when cmd-line
233
- (sdml-mode-cli-run-command cmd-line " *SDML Dependencies*" nil t )))))
277
+ (sdml-mode-cli-run-command cmd-line " *SDML Dependencies*" nil t ))))
234
278
235
279
236
280
; ; --------------------------------------------------------------------------
@@ -242,8 +286,9 @@ platform-specific extension in `tree-sitter-load-suffixes'."
242
286
(define-key map (kbd " C-c C-s d" ) 'tree-sitter-debug-mode )
243
287
(define-key map (kbd " C-c C-s q" ) 'tree-sitter-query-builder )
244
288
(define-key map (kbd " C-c C-s v" ) 'sdml-mode-validate-current-buffer )
245
- (define-key map (kbd " C-c C-s V " ) 'sdml-mode-validate-file )
289
+ (define-key map (kbd " C-c C-s M-v " ) 'sdml-mode-validate-file )
246
290
(define-key map (kbd " C-c C-s t" ) 'sdml-mode-current-buffer-dependency-tree )
291
+ (define-key map (kbd " C-c C-s M-t" ) 'sdml-mode-current-buffer-dependency-graph )
247
292
map)
248
293
" Keymap for SDML major mode." )
249
294
@@ -267,7 +312,16 @@ platform-specific extension in `tree-sitter-load-suffixes'."
267
312
sdml-mode
268
313
prog-mode
269
314
" SDML"
270
- " Major mode for editing SDML files.
315
+ " A major mode for editing SDML (Simple Domain Modeling Language) files.
316
+
317
+ This major mode will, by default, enable the following minor modes:
318
+
319
+ - `abbrev-mode'
320
+ - `prettify-symbols-mode' (see `sdml-mode-prettify-symbols-alist' )
321
+ - `tree-sitter-mode'
322
+ - `sdml-mode-hl-mode'
323
+ - `sdml-mode-indent-mode'
324
+ - `sdml-mode-ctags-mode'
271
325
272
326
Key bindings:
273
327
\\ {sdml-mode-map}"
0 commit comments