* Convert the shell command used in emacs init-file into its normal version.
@ 2021-06-09 6:49 Hongyi Zhao
2021-06-09 6:58 ` Jean Louis
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Hongyi Zhao @ 2021-06-09 6:49 UTC (permalink / raw)
To: help-gnu-emacs
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?
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 6:49 Convert the shell command used in emacs init-file into its normal version Hongyi Zhao
@ 2021-06-09 6:58 ` Jean Louis
2021-06-09 8:03 ` Hongyi Zhao
2021-06-09 7:23 ` Yuri Khan
2021-06-09 11:37 ` Eli Zaretskii
2 siblings, 1 reply; 14+ messages in thread
From: Jean Louis @ 2021-06-09 6:58 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
* 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/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 6:49 Convert the shell command used in emacs init-file into its normal version Hongyi Zhao
2021-06-09 6:58 ` Jean Louis
@ 2021-06-09 7:23 ` Yuri Khan
2021-06-09 7:57 ` Hongyi Zhao
2021-06-09 11:37 ` Eli Zaretskii
2 siblings, 1 reply; 14+ messages in thread
From: Yuri Khan @ 2021-06-09 7:23 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
On Wed, 9 Jun 2021 at 13:49, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
> 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 have basically two options:
1. Knowing the string syntax rules, you can interpret the escapes in
your head, removing the double quotes at start and end and replacing
each \" → " and \\ → \.
2. Or you can use an Emacs function that accepts a string and causes
its interpreted contents to be inserted into some buffer, e.g.
(message "…") or (insert "…").
$ emacs -Q
(insert "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\\\"]}}}\"")
Either way, you get:
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\"]}}}"
Before you can try this in your terminal, you’ll need to substitute
the %s placeholders.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 7:23 ` Yuri Khan
@ 2021-06-09 7:57 ` Hongyi Zhao
0 siblings, 0 replies; 14+ messages in thread
From: Hongyi Zhao @ 2021-06-09 7:57 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs
On Wed, Jun 9, 2021 at 3:23 PM Yuri Khan <yuri.v.khan@gmail.com> wrote:
>
> On Wed, 9 Jun 2021 at 13:49, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> > 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 have basically two options:
>
> 1. Knowing the string syntax rules, you can interpret the escapes in
> your head, removing the double quotes at start and end and replacing
> each \" → " and \\ → \.
>
> 2. Or you can use an Emacs function that accepts a string and causes
> its interpreted contents to be inserted into some buffer, e.g.
> (message "…") or (insert "…").
>
> $ emacs -Q
>
> (insert "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\\\"]}}}\"")
>
> Either way, you get:
I checked them with C-j, the (message "…") method won't do the trick
while the (insert "…") does.
>
> 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\"]}}}"
>
> Before you can try this in your terminal, you’ll need to substitute
> the %s placeholders.
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 6:58 ` Jean Louis
@ 2021-06-09 8:03 ` Hongyi Zhao
2021-06-09 8:13 ` tomas
2021-06-09 8:26 ` Jean Louis
0 siblings, 2 replies; 14+ messages in thread
From: Hongyi Zhao @ 2021-06-09 8:03 UTC (permalink / raw)
To: Hongyi Zhao, help-gnu-emacs
On Wed, Jun 9, 2021 at 3:01 PM Jean Louis <bugs@gnu.support> wrote:
>
> * 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\"]}}}")
You've stripped the escaping characters out manually in the above code.
>
> The data part I would format before it arrives to function `call-process'
I still can't figure out what do mean in this specific case.
>
> 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/
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 8:03 ` Hongyi Zhao
@ 2021-06-09 8:13 ` tomas
2021-06-09 8:22 ` Hongyi Zhao
2021-06-09 8:26 ` Jean Louis
1 sibling, 1 reply; 14+ messages in thread
From: tomas @ 2021-06-09 8:13 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2251 bytes --]
On Wed, Jun 09, 2021 at 04:03:09PM +0800, Hongyi Zhao wrote:
> On Wed, Jun 9, 2021 at 3:01 PM Jean Louis <bugs@gnu.support> wrote:
> >
> > * 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\"]}}}")
>
> You've stripped the escaping characters out manually in the above code.
It's a bit more complex than that: The above is one big string in Emacs
lisp which is to be passed to a shell. So it has an "outer" syntax,
to be interpreted by the Emacs lisp reader, and an "inner" to be
interpreted by the shell reader.
The below is split into several strings (call-process takes a list
of arguments, which are passed to exec), so no "shell escaping" is
necessary. But since the individual arguments are represented as
Emacs lisp strings, they need that escaping.
So in a way yes, one layer of escaping has been removed, but it's
the lower layer, the shell escaping. It just looks very similar to
the upper (lisp) layer :-)
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 8:13 ` tomas
@ 2021-06-09 8:22 ` Hongyi Zhao
2021-06-09 8:50 ` tomas
0 siblings, 1 reply; 14+ messages in thread
From: Hongyi Zhao @ 2021-06-09 8:22 UTC (permalink / raw)
To: tomas; +Cc: help-gnu-emacs
On Wed, Jun 9, 2021 at 4:13 PM <tomas@tuxteam.de> wrote:
>
> On Wed, Jun 09, 2021 at 04:03:09PM +0800, Hongyi Zhao wrote:
> > On Wed, Jun 9, 2021 at 3:01 PM Jean Louis <bugs@gnu.support> wrote:
> > >
> > > * 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\"]}}}")
> >
> > You've stripped the escaping characters out manually in the above code.
>
> It's a bit more complex than that: The above is one big string in Emacs
> lisp which is to be passed to a shell. So it has an "outer" syntax,
> to be interpreted by the Emacs lisp reader, and an "inner" to be
> interpreted by the shell reader.
>
> The below is split into several strings (call-process takes a list
> of arguments, which are passed to exec), so no "shell escaping" is
> necessary. But since the individual arguments are represented as
> Emacs lisp strings, they need that escaping.
Is this way more efficient than the original version?
> So in a way yes, one layer of escaping has been removed, but it's
> the lower layer, the shell escaping. It just looks very similar to
> the upper (lisp) layer :-)
>
> Cheers
> - t
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 8:03 ` Hongyi Zhao
2021-06-09 8:13 ` tomas
@ 2021-06-09 8:26 ` Jean Louis
1 sibling, 0 replies; 14+ messages in thread
From: Jean Louis @ 2021-06-09 8:26 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
* Hongyi Zhao <hongyi.zhao@gmail.com> [2021-06-09 11:04]:
> > (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\"]}}}")
>
> You've stripped the escaping characters out manually in the above
> code.
Yes, that is how I would use that, too much escaping is difficult
> > The data part I would format before it arrives to function `call-process'
>
> I still can't figure out what do mean in this specific case.
The "--data" part I would format this way:
(let ((data (use function to format data here)))
(call-process "curl" nil nil nil ................. "--data" data))
that way I would not fiddle with the data part in `call-process'
rather pass it to `call-process' and this may be what you anyway do.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 8:22 ` Hongyi Zhao
@ 2021-06-09 8:50 ` tomas
0 siblings, 0 replies; 14+ messages in thread
From: tomas @ 2021-06-09 8:50 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 733 bytes --]
On Wed, Jun 09, 2021 at 04:22:38PM +0800, Hongyi Zhao wrote:
[...]
> > The below is split into several strings (call-process takes a list
> > of arguments [...]
> Is this way more efficient than the original version?
Probably yes -- it calls directly curl instead of invoking a shell.
But efficiency is not very important here. The important thing is
what you are trying to achieve.
Calling a shell emulates more the environment you have when using
a shell (e.g. PATH, locales, variable expansion, etc). Sometimes
you want to achieve exactly that.
Calling the subprocess directly via exec is simpler, easier to understand,
but bypasses the services afforded by the shell. Sometimes this is
exactly what you want.
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 6:49 Convert the shell command used in emacs init-file into its normal version Hongyi Zhao
2021-06-09 6:58 ` Jean Louis
2021-06-09 7:23 ` Yuri Khan
@ 2021-06-09 11:37 ` Eli Zaretskii
2021-06-09 14:21 ` Hongyi Zhao
2 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2021-06-09 11:37 UTC (permalink / raw)
To: help-gnu-emacs
> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Wed, 9 Jun 2021 14:49:00 +0800
>
> 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?
Did you try using split-string-and-unquote?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 11:37 ` Eli Zaretskii
@ 2021-06-09 14:21 ` Hongyi Zhao
2021-06-09 17:17 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Hongyi Zhao @ 2021-06-09 14:21 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On Wed, Jun 9, 2021 at 7:37 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Wed, 9 Jun 2021 14:49:00 +0800
> >
> > 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?
>
> Did you try using split-string-and-unquote?
To be frank, no. It's an eshell command, and I'm unfamiliar with it.
Any hints for using it in this case?
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 14:21 ` Hongyi Zhao
@ 2021-06-09 17:17 ` Eli Zaretskii
2021-06-10 2:26 ` Hongyi Zhao
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2021-06-09 17:17 UTC (permalink / raw)
To: help-gnu-emacs
> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Wed, 9 Jun 2021 22:21:58 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
>
> > > "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?
> >
> > Did you try using split-string-and-unquote?
>
> To be frank, no. It's an eshell command, and I'm unfamiliar with it.
> Any hints for using it in this case?
Sorry, I don't understand: you want hints for using what?
And how does eshell come into play here, I don't think you mentioned
that before.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-09 17:17 ` Eli Zaretskii
@ 2021-06-10 2:26 ` Hongyi Zhao
2021-06-10 6:59 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Hongyi Zhao @ 2021-06-10 2:26 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On Thu, Jun 10, 2021 at 1:18 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Hongyi Zhao <hongyi.zhao@gmail.com>
> > Date: Wed, 9 Jun 2021 22:21:58 +0800
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > > "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?
> > >
> > > Did you try using split-string-and-unquote?
> >
> > To be frank, no. It's an eshell command, and I'm unfamiliar with it.
> > Any hints for using it in this case?
>
> Sorry, I don't understand: you want hints for using what?
>
> And how does eshell come into play here, I don't think you mentioned
> that before.
>
Sorry for my misunderstanding of your meaning. I just want to know the
exact Emacs command sequence for stripping out the black slashes and
quotes of the following string with the function
split-string-and-unquote.
"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\\\"]}}}\""
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Convert the shell command used in emacs init-file into its normal version.
2021-06-10 2:26 ` Hongyi Zhao
@ 2021-06-10 6:59 ` Eli Zaretskii
0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2021-06-10 6:59 UTC (permalink / raw)
To: help-gnu-emacs
> From: Hongyi Zhao <hongyi.zhao@gmail.com>
> Date: Thu, 10 Jun 2021 10:26:36 +0800
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
>
> > > > Did you try using split-string-and-unquote?
> > >
> > > To be frank, no. It's an eshell command, and I'm unfamiliar with it.
> > > Any hints for using it in this case?
> >
> > Sorry, I don't understand: you want hints for using what?
> >
> > And how does eshell come into play here, I don't think you mentioned
> > that before.
> >
>
> Sorry for my misunderstanding of your meaning. I just want to know the
> exact Emacs command sequence for stripping out the black slashes and
> quotes of the following string with the function
> split-string-and-unquote.
>
> "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\\\"]}}}\""
My proposal is to use split-string-and-unquote, then concatenate the
members of the resulting list, separated by spaces, with mapconcat or
somesuch.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-06-10 6:59 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-09 6:49 Convert the shell command used in emacs init-file into its normal version Hongyi Zhao
2021-06-09 6:58 ` Jean Louis
2021-06-09 8:03 ` Hongyi Zhao
2021-06-09 8:13 ` tomas
2021-06-09 8:22 ` Hongyi Zhao
2021-06-09 8:50 ` tomas
2021-06-09 8:26 ` Jean Louis
2021-06-09 7:23 ` Yuri Khan
2021-06-09 7:57 ` Hongyi Zhao
2021-06-09 11:37 ` Eli Zaretskii
2021-06-09 14:21 ` Hongyi Zhao
2021-06-09 17:17 ` Eli Zaretskii
2021-06-10 2:26 ` Hongyi Zhao
2021-06-10 6:59 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).