diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-16 04:01:04 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-16 04:01:04 -0500 |
| commit | 500687f8d7d5b87ceb33fd959e545746ec9db1ba (patch) | |
| tree | 9959d3641259a7299893c99db0c5da55d3b8e942 /modules/markdown-config.el | |
| parent | d84aa4374af5e3447445377a836c66cc07d7a223 (diff) | |
| download | dotemacs-500687f8d7d5b87ceb33fd959e545746ec9db1ba.tar.gz dotemacs-500687f8d7d5b87ceb33fd959e545746ec9db1ba.zip | |
refactor(integrations): five hygiene fixes from the module-by-module re-review
- markdown-config.el: two related fixes on `markdown-preview'.
First, the URL was `https://localhost:8080/imp' but simple-httpd
serves plaintext on port 8080 -- the browser hit a TLS handshake
against a non-TLS listener and the preview never rendered. Changed
to `http://' and switched from `browse-url-generic' to plain
`browse-url' so the user's default protocol handler picks the
browser. Second, the function used to start the network listener
as a side effect of opening a preview; that's split into a
separate `cj/markdown-preview-server-start' command and
`markdown-preview' now signals a `user-error' (with the recovery
command in the message) when the server isn't running.
- slack-config.el: wrap the
`which-key-add-keymap-based-replacements' call in
`with-eval-after-load 'which-key'. Matches the pattern other
config modules use and means a slow / missing which-key load
won't block requiring slack-config.
- ai-vterm.el: pass the inner shell-command-string through
`shell-quote-argument' before wrapping in the tmux invocation.
The default value with embedded double quotes was safe under the
prior literal-single-quote wrap, but a user-customized
`cj/ai-vterm-agent-command' containing a single quote silently
broke the shell parse. Two existing tests updated to tolerate
the post-quote escape shape; new regression test asserts a
single-quote-bearing custom command survives.
- eshell-config.el: scope the `TERM=xterm-256color' override to
eshell-spawned processes only via an `eshell-mode' hook that
prepends to a buffer-local `process-environment'. The previous
global `setenv' at config-time changed `TERM' for every
subsequent `start-process' across the Emacs session, so any
subprocess (not just eshell pipelines) inherited
`xterm-256color' regardless of whether the receiver could
interpret the escapes.
Diffstat (limited to 'modules/markdown-config.el')
| -rw-r--r-- | modules/markdown-config.el | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/modules/markdown-config.el b/modules/markdown-config.el index 2536904a..1fc4cb0e 100644 --- a/modules/markdown-config.el +++ b/modules/markdown-config.el @@ -33,16 +33,34 @@ ;;;; --------------------- WIP: Markdown-Preview --------------------- +(defun cj/markdown-preview-server-start () + "Start the simple-httpd listener that serves the live markdown preview. +Idempotent: re-running while the server is already up is a no-op." + (interactive) + (require 'simple-httpd) + (httpd-start) + (message "markdown preview server running on http://localhost:8080/imp")) + ;; the filter to apply to markdown before impatient-mode pushes it to the server (defun markdown-preview () + "Open the current buffer as a live HTML preview at http://localhost:8080/imp. +The simple-httpd listener must already be running -- see +`cj/markdown-preview-server-start'. Starting a network listener as a +side effect of opening a preview is surprising, so the server start +lives in a separate command." (interactive) - (httpd-start) + (unless (and (boundp 'httpd-process) httpd-process) + (user-error "markdown preview server not running; run `M-x cj/markdown-preview-server-start' first")) (impatient-mode 1) (setq imp-user-filter #'cj/markdown-html) (cl-incf imp-last-state) (imp--notify-clients) - ;; (browse-url-generic-function 'browse-url-xdg-open) - (browse-url-generic "https://localhost:8080/imp" 1)) + ;; Use plain `browse-url' (not `browse-url-generic') so the user's + ;; default protocol handler picks the browser, and use `http://' -- + ;; simple-httpd serves plaintext; the previous `https://' URL caused + ;; a TLS handshake against a non-TLS listener and the preview never + ;; rendered. + (browse-url "http://localhost:8080/imp")) (defun cj/markdown-html (buffer) (princ (with-current-buffer buffer |
