[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert the shell command used in emacs init-file into its normal ve
From: |
Jean Louis |
Subject: |
Re: Convert the shell command used in emacs init-file into its normal version. |
Date: |
Wed, 9 Jun 2021 09:58:31 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-06-09 09:50]:
> I found the following command from
> <https://github.com/jethrokuan/mathpix.el/blob/02016ca4aee9ffce32e730372f45de35c00a3657/mathpix.el#L49>:
>
> "curl -s https://api.mathpix.com/v3/latex -X POST -H \"app_id: %s\" -H
> \"app_key: %s\" -H \"Content-Type: application/json\" --data
> \"{\\\"src\\\":\\\"%s\\\",\\\"formats\\\":
> [\\\"latex_styled\\\"],\\\"format_options\\\":{\\\"latex_styled\\\":
> {\\\"transforms\\\": [\\\"rm_spaces\\\"]}}}\""
>
> I want to obtain its normal version and test it under the system's
> shell terminal. Any hints for deleting the escape characters correctly
> from the above command in Emacs way?
You should use the function `call-process' as it will help with
quoting:
(call-process "curl" nil nil nil "-s" "https://api.mathpix.com/v3/latex"
"-X" "POST" "-H" (format "app_id: %s" id)
"-H" (format "app_key: %s" key)
"-H" "Content-Type: application/json"
"--data" "{\"src\":\"%s\",
\"formats\": [\"latex_styled\"],
\"format_options\": {\"latex_styled\":
{\"transforms\":
[\"rm_spaces\"]}}}")
The data part I would format before it arrives to function `call-process'
Please study the function definition with {C-h f call-process RET}
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
Re: Convert the shell command used in emacs init-file into its normal version., Yuri Khan, 2021/06/09
Re: Convert the shell command used in emacs init-file into its normal version., Eli Zaretskii, 2021/06/09