fix: restore playground shortcuts and preview display
Show the Ebox DSL render shortcut in the source header line and route C-c C-c through the public display API so the generated preview is automatically shown. Verification: make check EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs; GUI daemon key-path smoke test with clean source and preview screenshots.
This commit is contained in:
parent
1e0568c7f9
commit
9af3dc9e5f
@ -9,7 +9,7 @@ The gallery owns one definite 720 px canvas so its nested Grid examples cannot e
|
||||
(ebox-playground-open)
|
||||
```
|
||||
|
||||
The package also owns the `.ebox` file boundary. Visiting an Ebox DSL file selects `ebox-dsl-mode`; press `C-c C-c` to build the single DSL form and render a preview through the public Ebox API.
|
||||
The package also owns the `.ebox` file boundary. Visiting an Ebox DSL file selects `ebox-dsl-mode`; its header line shows `C-c C-c Render preview`. Press `C-c C-c` to build the single DSL form, render it through the public Ebox API, and automatically display the preview buffer.
|
||||
|
||||
```elisp
|
||||
(add-to-list 'auto-mode-alist '("\\.ebox\\'" . ebox-dsl-mode))
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
(ebox-playground-open)
|
||||
```
|
||||
|
||||
这个包也拥有 `.ebox` 文件入口。访问 Ebox DSL 文件时会自动进入 `ebox-dsl-mode`;按 `C-c C-c` 会通过 Ebox 公开 API 构建单个 DSL form 并渲染预览。
|
||||
这个包也拥有 `.ebox` 文件入口。访问 Ebox DSL 文件时会自动进入 `ebox-dsl-mode`,header line 会显示 `C-c C-c Render preview`;按 `C-c C-c` 会通过 Ebox 公开 API 构建单个 DSL form、渲染并自动弹出预览 buffer。
|
||||
|
||||
```elisp
|
||||
(add-to-list 'auto-mode-alist '("\\.ebox\\'" . ebox-dsl-mode))
|
||||
|
||||
@ -29,6 +29,10 @@
|
||||
map)
|
||||
"Keymap used by `ebox-dsl-mode'.")
|
||||
|
||||
(defconst ebox-playground--dsl-header-line
|
||||
"Ebox DSL | C-c C-c Render preview"
|
||||
"Header line shown by `ebox-dsl-mode'.")
|
||||
|
||||
(defun ebox-playground--source-form ()
|
||||
"Read the single Ebox DSL form from the current buffer."
|
||||
(ebox-playground--evaluate-form
|
||||
@ -38,6 +42,7 @@
|
||||
;;;###autoload
|
||||
(define-derived-mode ebox-dsl-mode emacs-lisp-mode "EboxDSL"
|
||||
"Major mode for Ebox DSL source files."
|
||||
(setq-local header-line-format ebox-playground--dsl-header-line)
|
||||
(setq-local truncate-lines nil)
|
||||
(setq-local bidi-display-reordering nil)
|
||||
(setq-local bidi-paragraph-direction 'left-to-right))
|
||||
@ -50,7 +55,7 @@
|
||||
(name (format "*Ebox Preview: %s*"
|
||||
(or (buffer-file-name) (buffer-name))))
|
||||
(node (ebox-build source)))
|
||||
(ebox-render-to-buffer name node)
|
||||
(ebox-display-buffer name node)
|
||||
(message "Rendered Ebox DSL into %s" name)
|
||||
(get-buffer name)))
|
||||
|
||||
|
||||
@ -95,7 +95,9 @@
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name "/tmp/ebox-playground-mode-test.ebox")
|
||||
(set-auto-mode)
|
||||
(should (eq major-mode 'ebox-dsl-mode))))
|
||||
(should (eq major-mode 'ebox-dsl-mode))
|
||||
(should (eq (key-binding (kbd "C-c C-c")) #'ebox-dsl-render))
|
||||
(should (string-match-p "C-c C-c" header-line-format))))
|
||||
|
||||
(ert-deftest ebox-playground-renders-ebox-file-mode-source ()
|
||||
"Render a file-mode buffer through the public Ebox build path."
|
||||
@ -106,6 +108,8 @@
|
||||
(insert "(box :content \"Rendered from .ebox\" :width '(240))")
|
||||
(ebox-dsl-mode)
|
||||
(ebox-dsl-render)
|
||||
(should (eq (window-buffer (selected-window))
|
||||
(get-buffer preview)))
|
||||
(with-current-buffer preview
|
||||
(should (string-match-p "Rendered from .ebox" (buffer-string)))))
|
||||
(when (get-buffer preview)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user