Skip to content

Commit be09aed

Browse files
committed
feat: add validation by file not buffer
1 parent a1cc942 commit be09aed

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,36 @@ used as the completion UI for type completion when editing.
9292

9393
![Completion](./images/emacs-completion.png)
9494

95+
Command `sdml-mode-ctags-generate` has the default binding `C-c C-s T`. It uses the
96+
variables `sdml-mode-ctags-command` and `sdml-mode-ctags-output-file-name` to
97+
generate the tag file.
98+
9599
## Tool Commands
96100

97101
A number of the tools provided by the SDML command-line tool are exposed as
98102
Emacs commands. The following image shows two tools in use, the module
99-
dependency tree and the validation tool. The tree view can be refreshed using
100-
the common binding of `g` and quit with `q`.
103+
dependency tree and the validation tool.
104+
105+
![Tool Commands](./images/emacs-tools.png)
106+
107+
### Dependency Tree
108+
109+
* Command `sdml-mode-current-buffer-dependency-tree` has the default binding `C-c
110+
C-s t`.
111+
* The command will prompt for the maximum depth of the tree where 0 means
112+
unbounded. This is a command prefix and can therefore be specified with the
113+
usual `C-u` binding.
114+
* The resulting tree view can be refreshed using the common binding of `g` and quit
115+
with `q`.
116+
117+
### Full Validation
101118

102-
[Tool Commands](./images/emacs-tools.png)
119+
* Command `sdml-mode-validate-current-buffer` has the default binding `C-c C-s v`.
120+
* Command `sdml-mode-validate` has the default binding `C-c C-s V`.
121+
* The variable `sdml-mode-validation-level` denotes the level of messages produced
122+
by the validator, with a default of `warnings`.
123+
* The output uses the standard `compilation-mode` with all the common bindings are
124+
available.
103125

104126
### Abbreviations and Skeletons
105127

@@ -130,9 +152,12 @@ will add the value of the Emacs variable `locale-language` as the language tag.
130152

131153
* `C-c C-s d` -- open the tree-sitter debug view
132154
* `C-c C-s q` -- open the tree-sitter query builder
133-
* `C-c C-s t` -- open a dependency tree view
134-
* `C-c C-s v` -- run the validator in a compilation window
135-
* `C-c C-s g` -- run u-ctags for the current project
155+
* `C-c C-s t` -- open a dependency tree view for the current buffer
156+
* `C-c C-s v` -- run the validator, on the current buffer, and show the results in
157+
a compilation window
158+
* `C-c C-s V` -- run the validator, on a specified file, and show the results in
159+
a compilation window
160+
* `C-c C-s T` -- run u-ctags for the current project
136161

137162
## Add-Ons
138163

sdml-mode.el

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,25 @@ platform-specific extension in `tree-sitter-load-suffixes'."
196196
`(sdml ,sdml-mode-validation-error-regexp 5 6 7 (2 . 3)))
197197
(add-to-list 'compilation-error-regexp-alist 'sdml))
198198

199+
(defun sdml-mode-validate-file (file-name)
200+
"Validate FILE-NAME using the `compile' command."
201+
(interactive "fSDML File name: " sdml-mode)
202+
(let ((cmd-line (sdml-mode-cli-make-command
203+
"validate"
204+
(sdml-mode-cli-make-arg 'level sdml-mode-validation-level)
205+
(sdml-mode-cli-make-arg 'input file-name))))
206+
(when cmd-line
207+
(compile cmd-line))))
208+
199209
(defun sdml-mode-validate-current-buffer ()
200210
"Validate the current buffer using the `compile' command."
201211
(interactive nil sdml-mode)
202-
(when (derived-mode-p 'sdml-mode)
203-
(let ((cmd-line (sdml-mode-cli-make-command
204-
"validate"
205-
(sdml-mode-cli-make-arg 'level sdml-mode-validation-level)
206-
'current-buffer)))
207-
(when cmd-line
208-
(compile cmd-line)))))
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))))
209218

210219

211220
;; --------------------------------------------------------------------------
@@ -233,6 +242,7 @@ platform-specific extension in `tree-sitter-load-suffixes'."
233242
(define-key map (kbd "C-c C-s d") 'tree-sitter-debug-mode)
234243
(define-key map (kbd "C-c C-s q") 'tree-sitter-query-builder)
235244
(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)
236246
(define-key map (kbd "C-c C-s t") 'sdml-mode-current-buffer-dependency-tree)
237247
map)
238248
"Keymap for SDML major mode.")

0 commit comments

Comments
 (0)