-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated markdown in message buffer #83
Comments
I suppose markdown-mode can avoid this issue by calling Use call-process-region directlydiff --git a/markdown-mode.el b/markdown-mode.el
index bad960d..59fcdfa 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -5270,8 +5270,15 @@ Return the name of the output buffer used."
output-buffer-name)))
;; Pass region to `markdown-command' via stdin
(t
- (shell-command-on-region begin-region end-region markdown-command
- output-buffer-name))))
+ (let ((buf (get-buffer-create output-buffer-name)))
+ (with-current-buffer buf
+ (setq buffer-read-only nil)
+ (erase-buffer))
+ (let ((ret (call-process-region begin-region end-region
+ shell-file-name nil buf nil
+ shell-command-switch markdown-command)))
+ (unless (zerop ret)
+ (error "Failed: '%s'" markdown-command)))))))
output-buffer-name))
(defun markdown-standalone (&optional output-buffer-name) Using start-processThis is asynchronous execution. diff --git a/markdown-mode.el b/markdown-mode.el
index bad960d..8573698 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -5270,8 +5270,16 @@ Return the name of the output buffer used."
output-buffer-name)))
;; Pass region to `markdown-command' via stdin
(t
- (shell-command-on-region begin-region end-region markdown-command
- output-buffer-name))))
+ (let ((buf (get-buffer-create output-buffer-name)))
+ (with-current-buffer buf
+ (setq buffer-read-only nil)
+ (erase-buffer))
+ (let ((input (buffer-substring-no-properties begin-region end-region))
+ (proc (start-process-shell-command "markdown" buf markdown-command)))
+ (set-process-sentinel proc #'ignore)
+ (set-process-query-on-exit-flag proc nil)
+ (process-send-string proc input)
+ (process-send-eof proc))))))
output-buffer-name))
(defun markdown-standalone (&optional output-buffer-name) |
I think the synchronous version is probably better. Minor modes like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
markdown
function usesshell-command-on-region
, which in addition to writing to the destination buffer, apparently also prints the output to the echo area and the*Messages*
buffer. Maybecall-process-region
or something similar should be used instead.The text was updated successfully, but these errors were encountered: