Skip to content

ghostel should block while performing ghostel_cmd? #209

@ackerleytng

Description

@ackerleytng

I'm using b4 prep --edit-cover and with vterm, opening the file using OSC51 works as expected - when I run b4 prep --edit-cover, an emacs window pops up, allowing me to edit the text, then when I close the window, the contents is saved for b4.

I've extracted the relevant code here:

#!/usr/bin/env python3

import os
import subprocess
import tempfile
import shlex

bdata = b'foobar'

with tempfile.TemporaryDirectory(prefix='b4-editor') as temp_dir:
    temp_fpath = os.path.join(temp_dir, "COMMIT_EDITMSG")
    with open(temp_fpath, 'xb') as edit_file:
        edit_file.write(bdata)

    cmdargs = ["printf", r"\e]51;E%s\e\\", f"find-file {temp_fpath}"]
    sp = subprocess.Popen(cmdargs)
    # ghostel should block here until the file is closed
    sp.wait()

    with open(temp_fpath, 'rb') as edited_file:
        bdata = edited_file.read()

    print(bdata)

In vterm, this would have opened the emacs buffer containing "foobar", and then it would print the new edited contents at the end.

In ghostel, this doesn't open a buffer. IIUC ghostel doesn't block while handling OSC 51, so the python script goes on to just read the edited file and declare there are no changes. Emacs then starts to handle the open request and declares that it cannot find the temporary directory in *Messages*

ghostel: error calling find-file: Setting current directory: No such file or directory, /tmp/b4-editordhiklqrq/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions