emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: "Christopher M. Miles" <numbchild@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>, Matt <matt@excalamus.com>
Subject: ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively (was: [Need Help] Error to evaluate "mpv" command in inline src block)
Date: Mon, 01 May 2023 11:39:24 +0000	[thread overview]
Message-ID: <877cts8emr.fsf@localhost> (raw)
In-Reply-To: <m2pm7kpbpc.fsf@numbchild@gmail.com>

"Christopher M. Miles" <numbchild@gmail.com> writes:

>> So, it looks to me like mpv is somehow trying to interpret "echo" commands the
>> ob-shell is sending after "mpv ...." is executed:
> ...
> Don't know ob-shell which part did your said "echo" commands. I don't
> know where to dig this issue. Hope you can help. Thanks for your
> reproducing problem and dive in.

The underlying issue lies within how comint works + the fact that mpv
reads key input from terminal.

Try the following:

1. emacs -Q
2. M-x shell
3. cd /path/to/your/video <RET>
4. Copy the following into kill ring
-----
mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"
m_
-----
5. (in the shell buffer): C-y <RET>
6. Observe mpv playing no sound and video
7. Press m_ to restore video and sound.

I am not sure if we can do much about this though.
We run async shell commands in sessions using

(insert (format ob-shell-async-indicator "start" uuid))
(comint-send-input nil t)
(insert (org-trim body))
(comint-send-input nil t)
(insert (format ob-shell-async-indicator "end" uuid))
(comint-send-input nil t)

which sends

"echo '....'
<your command>
echo '...'"

to comint terminal session.

The last echo '...' in this case is interpreted as key input by mpv -
symbol by symbol.

The only way I know how to work around this is a giant one-liner like
echo '....'; <your command>; echo '...'

However, (1) ";" may not work in some shells; (2) <your command> may
contain multiple lines, leading to the same issue.

Matt, maybe you have some ideas about this edge case?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2023-05-01 11:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30  4:27 [Need Help] Error to evaluate "mpv" command in inline src block stardiviner
2023-04-30  4:46 ` Ruijie Yu via General discussions about Org-mode.
2023-04-30 10:59   ` Christopher M. Miles
2023-04-30 14:52 ` Ihor Radchenko
2023-05-01  3:39   ` Christopher M. Miles
2023-05-01  7:45     ` Ihor Radchenko
2023-05-01 10:46       ` Christopher M. Miles
2023-05-01 11:39         ` Ihor Radchenko [this message]
2023-05-01 12:50           ` ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively Christopher M. Miles
2023-05-01 13:14             ` Ihor Radchenko
2023-05-01 13:41               ` Christopher M. Miles
2023-05-01 14:20                 ` Ihor Radchenko
2023-05-01 19:06                   ` Christopher M. Miles
2023-05-01 13:08           ` [SOLUTION] a temporary workaround solution using another language like "python" Christopher M. Miles
     [not found]           ` <35881.2693202466$1682946783@news.gmane.org>
2023-05-01 13:35             ` Max Nikulin
2023-05-01 19:01               ` Christopher M. Miles
2023-05-01 19:16                 ` Ihor Radchenko
2023-05-02  4:17                   ` [CLOSED] [ANSWER] " Christopher M. Miles
2023-05-02 20:31           ` ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively (was: [Need Help] Error to evaluate "mpv" command in inline src block) Matt
2023-05-03 10:41             ` Ihor Radchenko
2023-05-03 11:01               ` ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively Christopher M. Miles
2023-05-03 12:01                 ` Ihor Radchenko
2023-05-03 16:31                   ` Christopher M. Miles
2023-05-01 10:50       ` [Need Help] Error to evaluate "mpv" command in inline src block Christopher M. Miles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cts8emr.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=matt@excalamus.com \
    --cc=numbchild@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).